public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yeoreum Yun <yeoreum.yun@arm.com>
To: Leo Yan <leo.yan@arm.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, suzuki.poulose@arm.com,
	mike.leach@arm.com, james.clark@linaro.org,
	alexander.shishkin@linux.intel.com, jie.gan@oss.qualcomm.com
Subject: Re: [PATCH v4 1/9] coresight: etm4x: introduce struct etm4_caps
Date: Tue, 14 Apr 2026 08:55:39 +0100	[thread overview]
Message-ID: <ad3y+1XttodP0rVc@e129823.arm.com> (raw)
In-Reply-To: <20260413172104.GD356832@e132581.arm.com>

Hi Leo!

> On Mon, Apr 13, 2026 at 03:19:54PM +0100, Yeoreum Yun wrote:
> > Introduce struct etm4_caps to describe ETMv4 capabilities
> > and move capabilities information into it.
> >
> > Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
>
> LGTM:
>
> Reviewed-by: Leo Yan <leo.yan@arm.com>

Thanks.

>
> FWIW, two comments from Sashiko are valuable for me, please see below.
>
> > ---
> >  .../coresight/coresight-etm4x-core.c          | 234 +++++++++---------
> >  .../coresight/coresight-etm4x-sysfs.c         | 190 ++++++++------
> >  drivers/hwtracing/coresight/coresight-etm4x.h | 176 ++++++-------
> >  3 files changed, 328 insertions(+), 272 deletions(-)
> >
> > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > index d565a73f0042..6443f3717b37 100644
> > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> > @@ -88,8 +88,9 @@ static int etm4_probe_cpu(unsigned int cpu);
> >   */
> >  static bool etm4x_sspcicrn_present(struct etmv4_drvdata *drvdata, int n)
> >  {
> > -	return (n < drvdata->nr_ss_cmp) &&
> > -	       drvdata->nr_pe &&
> > +	const struct etmv4_caps *caps = &drvdata->caps;
> > +
> > +	return (n < caps->nr_ss_cmp) && caps->nr_pe &&
> >  	       (drvdata->config.ss_status[n] & TRCSSCSRn_PC);
>
> As Sashiko suggests:
>
>   "This isn't a regression introduced by this patch, but should this be
>    checking caps->nr_pe_cmp instead of caps->nr_pe?"
>
> I confirmed the ETMv4 specification (ARM IHI0064H.b), the comment
> above is valid as the we should check caps->nr_pe_cmp instead.
>
> Could you first use a patch to fix the typo and then apply
> capabilities afterwards?  This is helpful for porting to stable
> kernels.

Sashiko finds valid point. And I'm bit of surprised no body find it.
Okay. I'll send it next round.

>
> [...]
>
> > @@ -525,14 +530,14 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
> >  	if (etm4x_wait_status(csa, TRCSTATR_IDLE_BIT, 1))
> >  		dev_err(etm_dev,
> >  			"timeout while waiting for Idle Trace Status\n");
> > -	if (drvdata->nr_pe)
> > +	if (caps->nr_pe)
> >  		etm4x_relaxed_write32(csa, config->pe_sel, TRCPROCSELR);
> >  	etm4x_relaxed_write32(csa, config->cfg, TRCCONFIGR);
> >  	/* nothing specific implemented */
> >  	etm4x_relaxed_write32(csa, 0x0, TRCAUXCTLR);
> >  	etm4x_relaxed_write32(csa, config->eventctrl0, TRCEVENTCTL0R);
> >  	etm4x_relaxed_write32(csa, config->eventctrl1, TRCEVENTCTL1R);
> > -	if (drvdata->stallctl)
> > +	if (caps->stallctl)
> >  		etm4x_relaxed_write32(csa, config->stall_ctrl, TRCSTALLCTLR);
> >  	etm4x_relaxed_write32(csa, config->ts_ctrl, TRCTSCTLR);
> >  	etm4x_relaxed_write32(csa, config->syncfreq, TRCSYNCPR);
> > @@ -542,17 +547,17 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
> >  	etm4x_relaxed_write32(csa, config->vinst_ctrl, TRCVICTLR);
> >  	etm4x_relaxed_write32(csa, config->viiectlr, TRCVIIECTLR);
> >  	etm4x_relaxed_write32(csa, config->vissctlr, TRCVISSCTLR);
> > -	if (drvdata->nr_pe_cmp)
> > +	if (caps->nr_pe_cmp)
> >  		etm4x_relaxed_write32(csa, config->vipcssctlr, TRCVIPCSSCTLR);
> > -	for (i = 0; i < drvdata->nrseqstate - 1; i++)
> > +	for (i = 0; i < caps->nrseqstate - 1; i++)
> >  		etm4x_relaxed_write32(csa, config->seq_ctrl[i], TRCSEQEVRn(i));
>
> Sashiko's comment:
>
>   "If the hardware does not implement a sequencer, caps->nrseqstate (a u8)
>    will be 0. Does 0 - 1 evaluate to -1 as an int, which then gets promoted
>    to ULONG_MAX against val (an unsigned long)?"
>
> This is a good catch.  The condition check should be:
>
>   for (i = 0; i < caps->nrseqstate; i++)
>        ...;
>
> The issue is irrelevant to your patch, but could you use a patch to fix
> "nrseqstate - 1" first and then apply the cap refactoring on it?  This
> would be friendly for porting to stable kernel.

Okay. I'll send it next round.

Thanks!

--
Sincerely,
Yeoreum Yun

  reply	other threads:[~2026-04-14  7:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13 14:19 [PATCH v4 0/9] fix several inconsistencies with sysfs configuration in etmX Yeoreum Yun
2026-04-13 14:19 ` [PATCH v4 1/9] coresight: etm4x: introduce struct etm4_caps Yeoreum Yun
2026-04-13 17:21   ` Leo Yan
2026-04-14  7:55     ` Yeoreum Yun [this message]
2026-04-13 14:19 ` [PATCH v4 2/9] coresight: etm4x: exclude ss_status from drvdata->config Yeoreum Yun
2026-04-14  8:02   ` Jie Gan
2026-04-14 16:04   ` Leo Yan
2026-04-14 16:59     ` Yeoreum Yun
2026-04-13 14:19 ` [PATCH v4 3/9] coresight: etm4x: fix leaked trace id Yeoreum Yun
2026-04-14  8:04   ` Jie Gan
2026-04-14 16:32   ` Leo Yan
2026-04-14 16:50     ` Yeoreum Yun
2026-04-15  1:21       ` Jie Gan
2026-04-15  7:29         ` Leo Yan
2026-04-15  8:01           ` Yeoreum Yun
2026-04-15  8:32             ` Leo Yan
2026-04-15  8:45               ` Jie Gan
2026-04-15  8:56                 ` Suzuki K Poulose
2026-04-13 14:19 ` [PATCH v4 4/9] coresight: etm4x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-04-15  4:25   ` Jie Gan
2026-04-15  5:36     ` Yeoreum Yun
2026-04-13 14:19 ` [PATCH v4 5/9] coresight: etm4x: remove redundant call etm4_enable_hw() with hotplug Yeoreum Yun
2026-04-15 11:59   ` Jie Gan
2026-04-13 14:19 ` [PATCH v4 6/9] coresight: etm3x: change drvdata->spinlock type to raw_spin_lock_t Yeoreum Yun
2026-04-15 12:05   ` Jie Gan
2026-04-13 14:20 ` [PATCH v4 7/9] coresight: etm3x: introduce struct etm_caps Yeoreum Yun
2026-04-15 12:17   ` Jie Gan
2026-04-15 16:45     ` Yeoreum Yun
2026-04-13 14:20 ` [PATCH v4 8/9] coresight: etm3x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-04-13 14:20 ` [PATCH v4 9/9] coresight: etm3x: remove redundant call etm4_enable_hw with hotplug Yeoreum Yun
2026-04-13 14:20 ` [PATCH v4 9/9] coresight: etm3x: remove redundant call etm_enable_hw() " Yeoreum Yun

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=ad3y+1XttodP0rVc@e129823.arm.com \
    --to=yeoreum.yun@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=james.clark@linaro.org \
    --cc=jie.gan@oss.qualcomm.com \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@arm.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