[PATCH v11 25/27] coresight: sysfs: Increment refcount only for system tracers

Leo Yan leo.yan at arm.com
Wed May 6 03:18:41 PDT 2026


On Wed, May 06, 2026 at 10:57:20AM +0100, Suzuki K Poulose wrote:
> On 01/05/2026 17:48, Leo Yan wrote:
> > Except for system tracers (e.g. STM), other sources treat multiple
> > enables as equivalent to a single enable. The device mode already
> > tracks the binary state, so it is redundant to operate refcount.
> > 
> > Refactor to maintain the refcount only for system sources. This
> > simplifies future CPU PM handling without refcount logic.
> > 
> > Tested-by: James Clark <james.clark at linaro.org>
> > Reviewed-by: Yeoreum Yun <yeoreum.yun at arm.com>
> > Reviewed-by: James Clark <james.clark at linaro.org>
> > Tested-by: Jie Gan <jie.gan at oss.qualcomm.com>
> > Signed-off-by: Leo Yan <leo.yan at arm.com>
> > ---
> >   drivers/hwtracing/coresight/coresight-sysfs.c | 41 ++++++++++++++++++---------
> >   1 file changed, 27 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c
> > index 0aebafcb8d0e8e699652244af5202e7c4dc4e9b1..42cf07b8d15a420e963650000dc32bbb38f0aa62 100644
> > --- a/drivers/hwtracing/coresight/coresight-sysfs.c
> > +++ b/drivers/hwtracing/coresight/coresight-sysfs.c
> > @@ -39,6 +39,28 @@ ssize_t coresight_simple_show32(struct device *_dev,
> >   }
> >   EXPORT_SYMBOL_GPL(coresight_simple_show32);
> > +static void coresight_source_get_refcnt(struct coresight_device *csdev)
> > +{
> > +	/*
> > +	 * There could be multiple applications driving the software
> > +	 * source. So keep the refcount for each such user when the
> > +	 * source is already enabled.
> > +	 *
> > +	 * No need to increment the reference counter for other source
> > +	 * types, as multiple enables are the same as a single enable.
> > +	 */
> > +	if (csdev->subtype.source_subtype ==
> > +			CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE)
> 
> Minor nit: You must check the csdev->type == DEV_TYPE_SOURCE before
> check the subtype.

I will add a helper coresight_is_software_source().

Thanks,
Leo



More information about the linux-arm-kernel mailing list