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>, Anil Kumar Reddy <areddy3@marvell.com>,
"Tanmay Jagdale" <tanmay@marvell.com>
Subject: Re: [PATCH v10 5/8] coresight: tmc: Add support for reading crash data
Date: Wed, 30 Oct 2024 11:04:19 +0530 [thread overview]
Message-ID: <20241030053419.GA984012@hyd1403.caveonetworks.com> (raw)
In-Reply-To: <20241029062112.GA978396@hyd1403.caveonetworks.com>
Hi Suzuki,
On 2024-10-29 at 11:51:12, Linu Cherian (lcherian@marvell.com) wrote:
> Hi Suzuki,
>
> On 2024-10-21 at 18:10:40, Linu Cherian (lcherian@marvell.com) wrote:
> > Hi Suzuki,
> >
> > On 2024-10-18 at 15:16:17, Suzuki K Poulose (suzuki.poulose@arm.com) wrote:
> > > On 17/10/2024 12:40, Linu Cherian wrote:
> > > > On 2024-10-03 at 18:55:54, Suzuki K Poulose (suzuki.poulose@arm.com) wrote:
> > > > > Hi Linu
> > > > >
> > > > > On 16/09/2024 11:34, Linu Cherian wrote:
> > > > > > * Add support for reading crashdata using special device files.
> > > > > > The special device files /dev/crash_tmc_xxx would be available
> > > > > > for read file operation only when the crash data is valid.
> > > > > >
> > > > > > * User can read the crash data as below
> > > > > >
> > > > > > For example, for reading crash data from tmc_etf sink
> > > > > >
> > > > > > #dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
> > > > >
> > > > > There are some comments below, please take a look.
> > > > >
> > > > > >
> > > > > > Signed-off-by: Anil Kumar Reddy <areddy3@marvell.com>
> > > > > > Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
> > > > > > Signed-off-by: Linu Cherian <lcherian@marvell.com>
> > > > > > ---
> > > > > > Changelog from v9:
> > > > > > - Removed READ_CRASHDATA mode meant for special casing crashdata read
> > > > > > - Added new fields full, len, offset to struct tmc_resrv_buf
> > > > >
> > > > > Why do we need "full" ? See more on that below.
> > > > >
> > > > > > so as to have a common read function for ETR and ETF
> > > > > > - Introduced read file operation, tmc_crashdata_read
> > > > > > specific to crashdata reads common for both ETR and ETF
> > > > > > - Introduced is_tmc_crashdata_valid function
> > > > > > Special device file /dev/crash_tmc_xxx will be available only when
> > > > > > crashdata is valid.
> > > > > > - Version checks added to crashdata validity checks
> > > > > > - Mark crashdata as invalid when user starts tracing with ETR sink in
> > > > > > "resrv" buffer mode
> > > > > >
> > > > > > .../hwtracing/coresight/coresight-tmc-core.c | 206 +++++++++++++++++-
> > > > > > .../hwtracing/coresight/coresight-tmc-etf.c | 36 +++
> > > > > > .../hwtracing/coresight/coresight-tmc-etr.c | 63 ++++++
> > > > > > drivers/hwtracing/coresight/coresight-tmc.h | 18 +-
> > > > > > include/linux/coresight.h | 12 +
> > > > > > 5 files changed, 333 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
> > > > > > index 54bf8ae2bff8..47b6b3f88750 100644
> > > > > > --- a/drivers/hwtracing/coresight/coresight-tmc-core.c
> > > > > > +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
> > > > > > @@ -105,6 +105,125 @@ u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)
> > > > > > return mask;
> > > > > > }
> > > > > > +bool is_tmc_crashdata_valid(struct tmc_drvdata *drvdata)
> > > > > > +{
> > > > > > + struct tmc_crash_metadata *mdata;
> > > > > > +
> > > > > > + if (!tmc_has_reserved_buffer(drvdata) ||
> > > > > > + !tmc_has_crash_mdata_buffer(drvdata))
> > > > > > + return false;
> > > > > > +
> > > > > > + mdata = drvdata->crash_mdata.vaddr;
> > > > > > +
> > > > > > + /* Check version match */
> > > > > > + if (mdata->version != CS_CRASHDATA_VERSION)
> > > > > > + return false;
> > > > > > +
> > > > > > + /* Check data integrity of metadata */
> > > > > > + if (mdata->crc32_mdata != find_crash_metadata_crc(mdata)) {
> > > > > > + dev_dbg(&drvdata->csdev->dev,
> > > > > > + "CRC mismatch in tmc crash metadata\n");
> > > > > > + return false;
> > > > > > + }
> > > > > > + /* Check data integrity of tracedata */
> > > > > > + if (mdata->crc32_tdata != find_crash_tracedata_crc(drvdata, mdata)) {
> > > > > > + dev_dbg(&drvdata->csdev->dev,
> > > > > > + "CRC mismatch in tmc crash tracedata\n");
> > > > > > + return false;
> > > > > > + }
> > > > > > + /* Check for valid metadata */
> > > > > > + if (!mdata->valid) {
> > > > >
> > > > > minor nit: This could be checked right after the VERSION and we verify
> > > > > the CRC anyway later and thus could skip all the CRC calculations if
> > > > > !valid.
> > > >
> > > >
> > > > Ack.
> > > >
> > > > >
> > > > > > + dev_dbg(&drvdata->csdev->dev,
> > > > > > + "Data invalid in tmc crash metadata\n");
> > > > > > + return false;
> > > > > > + }
> > > > > > +
> > > > > > + return true;
> > > > > > +}
> > > > > > +
> > > > > > +int tmc_read_prepare_crashdata(struct tmc_drvdata *drvdata)
> > > > > > +{
> > > > > > + int ret = 0;
> > > > > > + unsigned long flags;
> > > > > > + struct tmc_crash_metadata *mdata;
> > > > > > + struct coresight_device *csdev = drvdata->csdev;
> > > > > > +
> > > > > > + spin_lock_irqsave(&drvdata->spinlock, flags);
> > > > > > +
> > > > > > + if (!is_tmc_crashdata_valid(drvdata)) {
> > > > > > + ret = -ENXIO;
> > > > > > + goto out;
> > > > > > + }
> > > > > > +
> > > > > > + mdata = drvdata->crash_mdata.vaddr;
> > > > > > + /*
> > > > > > + * Buffer address given by metadata for retrieval of trace data
> > > > > > + * from previous boot is expected to be same as the reserved
> > > > > > + * trace buffer memory region provided through DTS
> > > > > > + */
> > > > > > + if (drvdata->resrv_buf.paddr != mdata->trace_paddr) {
> > > > > > + dev_dbg(&csdev->dev, "Trace buffer address of previous boot invalid\n");
> > > > >
> > > > > Couldn't this be made part of the "is_tmc_crashdata_valid()" and not
> > > > > repeated everytime we do the read ? Surely, this can't change after
> > > > > boot.
> > > >
> > > > Ack. Will move.
> > > >
> > > > >
> > > > > > + ret = -EINVAL;
> > > > > > + goto out;
> > > > > > + }
> > > > > > +
> > > > > > + /* Sink specific crashdata mode preparation */
> > > > > > + ret = crashdata_ops(csdev)->prepare(csdev);
> > > > > > + if (ret)
> > > > > > + goto out;
> > > > > > +
> > > > > > + if (mdata->sts & 0x1)
> > > > > > + coresight_insert_barrier_packet(drvdata->buf);
> > > > > > +
> > > > > > + drvdata->reading = true;
> > > > >
> > > > > Why are we dealing with drvdata->reading ? That is supposed to be only
> > > > > for the normal trace reading ?
> > > >
> > > > Ack. Will remove, we dont need this.
> > > >
Looked into this further and it seems like, retaining the
drvdata->reading flags would be useful to avoid simultaneous crashdata reads
and regular trace capture sessions using reserve buffers.
Something like this,
+static int buf_mode_set_resrv(struct tmc_drvdata *drvdata)
+{
+ unsigned long flags;
+ int err = 0;
+
+ /* Ensure there are no active crashdata read sessions */
+ spin_lock_irqsave(&drvdata->spinlock, flags);
+ if (!drvdata->reading) {
+ tmc_crashdata_set_invalid(drvdata);
+ drvdata->etr_mode = ETR_MODE_RESRV;
+
+ } else
+ err = -EINVAL;
+ spin_unlock_irqrestore(&drvdata->spinlock, flags);
+ return err;
+}
+
static ssize_t buf_mode_preferred_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct etr_buf_hw buf_hw;
get_etr_buf_hw(dev, &buf_hw);
@@ -2039,7 +2050,7 @@ static ssize_t buf_mode_preferred_store(struct device *dev,
else if (sysfs_streq(buf, buf_modes_str[ETR_MODE_CATU]) && buf_hw.has_catu)
drvdata->etr_mode = ETR_MODE_CATU;
else if (sysfs_streq(buf, buf_modes_str[ETR_MODE_RESRV]) && buf_hw.has_resrv)
- drvdata->etr_mode = ETR_MODE_RESRV;
+ return buf_mode_set_resrv(drvdata);
else if (sysfs_streq(buf, buf_modes_str[ETR_MODE_AUTO]))
drvdata->etr_mode = ETR_MODE_AUTO;
else
Was acutally calling the tmc_crashdata_set_invalid in the wrong place in v10 patch.
next prev parent reply other threads:[~2024-10-30 5:34 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
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 [this message]
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=20241030053419.GA984012@hyd1403.caveonetworks.com \
--to=lcherian@marvell.com \
--cc=areddy3@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 \
--cc=tanmay@marvell.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;
as well as URLs for NNTP newsgroup(s).