public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Mike Leach <Mike.Leach@arm.com>
Cc: Suzuki Poulose <Suzuki.Poulose@arm.com>,
	James Clark <james.clark@linaro.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Yingchao Deng <yingchao.deng@oss.qualcomm.com>,
	Jie Gan <jie.gan@oss.qualcomm.com>,
	"coresight@lists.linaro.org" <coresight@lists.linaro.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 8/8] coresight: cti: Refactor cti_reg32_{show|store}()
Date: Fri, 20 Feb 2026 17:35:49 +0000	[thread overview]
Message-ID: <20260220173549.GI136967@e132581.arm.com> (raw)
In-Reply-To: <PAVPR08MB96744050482081B274E6E4BB8C68A@PAVPR08MB9674.eurprd08.prod.outlook.com>

Hi Mike,

On Fri, Feb 20, 2026 at 02:44:03PM +0000, Mike Leach wrote:

[...]

> > @@ -252,14 +252,14 @@ static ssize_t cti_reg32_show(struct device *dev,
> > char *buf,
> >  	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
> >  	struct cti_config *config = &drvdata->config;
> > 
> > +	if (reg_offset < 0)
> > +		return -EINVAL;
> > +
> >  	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
> > -		if ((reg_offset >= 0) && cti_is_active(config)) {
> > +		if (cti_is_active(config))
> >  			val = cti_read_single_reg(drvdata, reg_offset);
> > -			if (pcached_val)
> > -				*pcached_val = val;
> 
> I think we still need this. If a register with an none-zero default
> value / status that can change over time is read when active, then
> read when inactive, but never written, then the inactive value will
> not reflect the last read value.

Let us consider below operations using your suggested approach:

  echo 0xab > /sys/bus/coresight/devices/cti_cpu0/regs/gate
  cat /sys/bus/coresight/devices/cti_cpu0/regs/gate

  echo 1 > /sys/bus/coresight/devices/cti_cpu0/enable
  cat /sys/bus/coresight/devices/cti_cpu0/regs/gate

  echo 0 > /sys/bus/coresight/devices/cti_cpu0/enable
  cat /sys/bus/coresight/devices/cti_cpu0/regs/gate

If a user reads the "gate" knob three times in the above flow, it ends
up having three different semantics.

 - The first "cat ../gate" outputs the user specified value (0xab).
 - The second "cat" outputs the real-time register value after the
   module has been enabled.
 - The third "cat" outputs the last read value before disabling.

This could be confusing for users (even for ourseleves), as it needs to
understand the meaning of the value under specific conditions and based
on prior operations.

To simplify the semantics in this patch, the "cat" returns the realtime
register value when the module is enabled; otherwise, it returns the
user configured value.  Since "*pcached_val" always stores the user
configuration, it remains consistent configurations across multiple
enable/disable cycles.

> Relatively minor issue but does represent a potential change in
> functionality for the driver - even if I cannot see specific issues
> for current ARM CTIs. This is a R/W cache so should be updated on
> both R and W.

"R/W cache" mixes the cached user configured value with the hardware
register dump and may become inconsistent across multiple
enable/disable cycles.

It seems to me that this is a bit overdesigned and complex. thoughts?

Thanks a lot for review!

Leo


  reply	other threads:[~2026-02-20 17:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-09 18:01 [PATCH 0/8] coresight: cti: Miscellaneous fixes and CPU PM cleanup Leo Yan
2026-02-09 18:01 ` [PATCH 1/8] coresight: cti: Make spinlock usage consistent Leo Yan
2026-02-19 16:58   ` Mike Leach
2026-02-09 18:01 ` [PATCH 2/8] coresight: cti: Fix register reads Leo Yan
2026-02-20  8:10   ` Mike Leach
2026-02-09 18:01 ` [PATCH 3/8] coresight: cti: Access ASICCTL only when implemented Leo Yan
2026-02-20  8:16   ` Mike Leach
2026-02-09 18:01 ` [PATCH 4/8] coresight: cti: Remove CPU power management code Leo Yan
2026-02-20 13:19   ` Mike Leach
2026-02-09 18:01 ` [PATCH 5/8] coresight: cti: Rename cti_active() to cti_is_active() Leo Yan
2026-02-20 13:47   ` Mike Leach
2026-02-09 18:01 ` [PATCH 6/8] coresight: cti: Remove hw_powered flag Leo Yan
2026-02-20 14:25   ` Mike Leach
2026-02-09 18:01 ` [PATCH 7/8] coresight: cti: Remove hw_enabled flag Leo Yan
2026-02-20 14:31   ` Mike Leach
2026-02-25 16:02     ` Leo Yan
2026-02-09 18:01 ` [PATCH 8/8] coresight: cti: Refactor cti_reg32_{show|store}() Leo Yan
2026-02-20 14:44   ` Mike Leach
2026-02-20 17:35     ` Leo Yan [this message]
2026-02-25 13:48       ` Mike Leach

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=20260220173549.GI136967@e132581.arm.com \
    --to=leo.yan@arm.com \
    --cc=Mike.Leach@arm.com \
    --cc=Suzuki.Poulose@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.clark@linaro.org \
    --cc=jie.gan@oss.qualcomm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=yingchao.deng@oss.qualcomm.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