mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linu Cherian <lcherian@marvell.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: <mike.leach@linaro.org>, <james.clark@arm.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<coresight@lists.linaro.org>, <linux-kernel@vger.kernel.org>,
	<linux-doc@vger.kernel.org>, <robh@kernel.org>,
	<krzk+dt@kernel.org>, <conor+dt@kernel.org>, <corbet@lwn.net>,
	<devicetree@vger.kernel.org>, <sgoutham@marvell.com>,
	<gcherian@marvell.com>
Subject: Re: [PATCH v10 4/8] coresight: tmc: Enable panic sync handling
Date: Tue, 29 Oct 2024 13:57:58 +0530	[thread overview]
Message-ID: <20241029082758.GA980241@hyd1403.caveonetworks.com> (raw)
In-Reply-To: <20241029062441.GB978396@hyd1403.caveonetworks.com>

Hi,

Please ignore this message, was sent by mistake.
Atually a repetition of message sent earlier.

Thanks.

On 2024-10-29 at 11:54:41, Linu Cherian (lcherian@marvell.com) wrote:
> Hi Suzuki,
> 
> On 2024-10-17 at 17:42:21, Linu Cherian (lcherian@marvell.com) wrote:
> > Hi Suzuki,
> > 
> > On 2024-10-01 at 22:13:12, Suzuki K Poulose (suzuki.poulose@arm.com) wrote:
> > > Hi Linu
> > > 
> > > On 16/09/2024 11:34, Linu Cherian wrote:
> > > > - Get reserved region from device tree node for metadata
> > > > - Define metadata format for TMC
> > > > - Add TMC ETR panic sync handler that syncs register snapshot
> > > >    to metadata region
> > > > - Add TMC ETF panic sync handler that syncs register snapshot
> > > >    to metadata region and internal SRAM to reserved trace buffer
> > > >    region.
> > > 
> > > The patch looks good overall. Some minor comments below.
> > > 
> > > > 
> > > > Signed-off-by: Linu Cherian <lcherian@marvell.com>
> > > > ---
> > > > Changelog from v9:
> > > > - Add common helper function of_tmc_get_reserved_resource_by_name
> > > >    for better code reuse
> > > > - Inorder to keep the reserved buffer validity and crashdata validity
> > > >    independent, is_tmc_reserved_region_valid renamed to tmc_has_reserved_buffer
> > > > - drvdata->crash_tbuf renamed to drvdata->resrv_buf
> > > > - New fields added to crash metadata: version, ffcr, ffsr, mode
> > > > - Defined crashdata version with Major version 1, Minor version 0
> > > > - Set version while creating crashdata record
> > > > - Removed Reviewed-by tag due to the above changes
> > > >   .../hwtracing/coresight/coresight-tmc-core.c  | 14 ++++
> > > >   .../hwtracing/coresight/coresight-tmc-etf.c   | 77 ++++++++++++++++++
> > > >   .../hwtracing/coresight/coresight-tmc-etr.c   | 78 +++++++++++++++++++
> > > >   drivers/hwtracing/coresight/coresight-tmc.h   | 66 ++++++++++++++++
> > > >   4 files changed, 235 insertions(+)
> > > > 
> > > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
> > > > index 0764c21aba0f..54bf8ae2bff8 100644
> > > > --- a/drivers/hwtracing/coresight/coresight-tmc-core.c
> > > > +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
> > > > @@ -445,6 +445,20 @@ static void tmc_get_reserved_region(struct device *parent)
> > > >   	drvdata->resrv_buf.paddr = res.start;
> > > >   	drvdata->resrv_buf.size  = resource_size(&res);
> > > > +
> > > > +	if (of_tmc_get_reserved_resource_by_name(parent, "metadata", &res))
> > > > +		return;
> > > > +
> > > > +	drvdata->crash_mdata.vaddr = memremap(res.start,
> > > > +					       resource_size(&res),
> > > > +					       MEMREMAP_WC);
> > > > +	if (IS_ERR_OR_NULL(drvdata->crash_mdata.vaddr)) {
> > > > +		dev_err(parent, "Metadata memory mapping failed\n");
> > > > +		return;
> > > > +	}
> > > > +
> > > > +	drvdata->crash_mdata.paddr = res.start;
> > > > +	drvdata->crash_mdata.size  = resource_size(&res);
> > > >   }
> > > >   /* Detect and initialise the capabilities of a TMC ETR */
> > > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> > > > index d4f641cd9de6..d77ec9307e98 100644
> > > > --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
> > > > +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> > > > @@ -590,6 +590,78 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,
> > > >   	return to_read;
> > > >   }
> > > > +static int tmc_panic_sync_etf(struct coresight_device *csdev)
> > > > +{
> > > > +	u32 val;
> > > > +	struct csdev_access *csa;
> > > > +	struct tmc_crash_metadata *mdata;
> > > > +	struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
> > > > +
> > > > +	csa = &drvdata->csdev->access;
> > > > +	mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr;
> > > > +
> > > > +	/* Make sure we have valid reserved memory */
> > > > +	if (!tmc_has_reserved_buffer(drvdata) ||
> > > > +	    !tmc_has_crash_mdata_buffer(drvdata))
> > > > +		return 0;
> > > > +
> > > > +	tmc_crashdata_set_invalid(drvdata);
> > > > +
> > > > +	CS_UNLOCK(drvdata->base);
> > > > +
> > > > +	/* Proceed only if ETF is enabled or configured as sink */
> > > > +	val = readl(drvdata->base + TMC_CTL);
> > > > +	if (!(val & TMC_CTL_CAPT_EN))
> > > > +		goto out;
> > > > +
> > > 
> > > minor nit : Since the check below is "covered" by the same comment
> > > above, please drop the extra line here to make it clear that "we check
> > > for sink" by checking the "MODE == CIRCULAR_BUFFER".
> > 
> > Ack.
> > 
> > > 
> > > > +	val = readl(drvdata->base + TMC_MODE);
> > > > +	if (val != TMC_MODE_CIRCULAR_BUFFER)
> > > > +		goto out;
> > > > +
> > > > +	val = readl(drvdata->base + TMC_FFSR);
> > > > +	/* Do manual flush and stop only if its not auto-stopped */
> > > > +	if (!(val & TMC_FFSR_FT_STOPPED)) {
> > > > +		dev_info(&csdev->dev,
> > > > +			 "%s: Triggering manual flush\n", __func__);
> > > 
> > > Please drop the ^^^ line. We don't want to do anything like that from a
> > > panic callback.
> > 
> > Ack.
> 
> Are we okay with converting this to dev_dbg, as this could be quite
> helpful to understand if the CTI trigger has occured or not.
> 
> 
> > 
> > > 
> > > > +		tmc_flush_and_stop(drvdata);
> > > > +	} else
> > > > +		tmc_wait_for_tmcready(drvdata);
> > > > +
> > > > +	/* Sync registers from hardware to metadata region */
> > > > +	mdata->sts = csdev_access_relaxed_read32(csa, TMC_STS);
> > > 
> > > Why are we using "csa" here and not for TMC_CTL etc ? Simply drop the "csa"
> > > and use the raw reads like above. TMC doesn't have anyother modes
> > > of access.
> > > 
> > 
> > Okay.
> > 
> > > > +	mdata->mode = csdev_access_relaxed_read32(csa, TMC_MODE);
> > > > +	mdata->ffcr = csdev_access_relaxed_read32(csa, TMC_FFCR);
> > > > +	mdata->ffsr = csdev_access_relaxed_read32(csa, TMC_FFSR);
> > > > +	mdata->trace_paddr = drvdata->resrv_buf.paddr;
> > > > +
> > > > +	/* Sync Internal SRAM to reserved trace buffer region */
> > > > +	drvdata->buf = drvdata->resrv_buf.vaddr;
> > > > +	tmc_etb_dump_hw(drvdata);
> > > > +	/* Store as per RSZ register convention */
> > > > +	mdata->size = drvdata->len >> 2;
> > > > +	mdata->version = CS_CRASHDATA_VERSION;
> > > > +
> > > > +	/*
> > > > +	 * Make sure all previous writes are completed,
> > > > +	 * before we mark valid
> > > > +	 */
> > > > +	dsb(sy);
> > > 
> > > I don't think this matters much, as this would only be read by a
> > > secondary kernel. In the worst case, you only need `dmb(ish)` to make
> > > sure the writes are visible before valid is set to true.
> > 
> > Ack. Will change that.
> > 
> > > 
> > > > +	mdata->valid = true;
> > > > +	/*
> > > > +	 * Below order need to maintained, since crc of metadata
> > > > +	 * is dependent on first
> > > > +	 */
> > > > +	mdata->crc32_tdata = find_crash_tracedata_crc(drvdata, mdata);
> > > > +	mdata->crc32_mdata = find_crash_metadata_crc(mdata);
> > > > +
> > > > +	tmc_disable_hw(drvdata);
> > > > +
> > > > +	dev_info(&csdev->dev, "%s: success\n", __func__);
> > > 
> > > Please no "prints" from a panic call back, unless it absolutely CRITICAL.
> > 
> > Ack.
> 
> Are we okay with converting this to dev_dbg, as this could aid in
> debugging to understand if kernel has populated valid metadata.
> 
> Thanks.
> Linu Cherian.
>  
> 

  reply	other threads:[~2024-10-29  8:28 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-16 10:34 [PATCH v10 0/8] Coresight for Kernel panic and watchdog reset Linu Cherian
2024-09-16 10:34 ` [PATCH v10 1/8] dt-bindings: arm: coresight-tmc: Add "memory-region" property Linu Cherian
2024-09-16 10:34 ` [PATCH v10 2/8] coresight: tmc-etr: Add support to use reserved trace memory Linu Cherian
2024-09-16 10:34 ` [PATCH v10 3/8] coresight: core: Add provision for panic callbacks Linu Cherian
2024-09-16 10:34 ` [PATCH v10 4/8] coresight: tmc: Enable panic sync handling Linu Cherian
2024-10-01 16:43   ` Suzuki K Poulose
2024-10-17 12:12     ` Linu Cherian
2024-10-28  9:40       ` Linu Cherian
2024-10-29  6:24       ` Linu Cherian
2024-10-29  8:27         ` Linu Cherian [this message]
2024-10-29  6:59       ` Linu Cherian
2024-09-16 10:34 ` [PATCH v10 5/8] coresight: tmc: Add support for reading crash data Linu Cherian
2024-10-03 13:25   ` Suzuki K Poulose
2024-10-17 11:40     ` Linu Cherian
2024-10-18  9:46       ` Suzuki K Poulose
2024-10-21 12:40         ` Linu Cherian
2024-10-29  6:21           ` Linu Cherian
2024-10-30  5:34             ` Linu Cherian
2024-09-16 10:34 ` [PATCH v10 6/8] coresight: tmc: Stop trace capture on FlIn Linu Cherian
2024-09-16 10:34 ` [PATCH v10 7/8] coresight: config: Add preloaded configuration Linu Cherian
2024-10-03 13:29   ` Suzuki K Poulose
2024-10-16 10:11     ` Linu Cherian
2024-09-16 10:34 ` [PATCH v10 8/8] Documentation: coresight: Panic support Linu Cherian
2024-09-17  1:46   ` Bagas Sanjaya
2024-09-19  2:09     ` Linu Cherian
2024-10-03 13:43   ` Suzuki K Poulose
2024-10-16  9:28     ` Linu Cherian
2024-09-16 11:16 ` [PATCH v10 0/8] Coresight for Kernel panic and watchdog reset Linu Cherian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241029082758.GA980241@hyd1403.caveonetworks.com \
    --to=lcherian@marvell.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gcherian@marvell.com \
    --cc=james.clark@arm.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@linaro.org \
    --cc=robh@kernel.org \
    --cc=sgoutham@marvell.com \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®