public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Leo Yan <leo.yan@arm.com>, Mike Leach <mike.leach@arm.com>,
	James Clark <james.clark@linaro.org>,
	Yeoreum Yun <yeoreum.yun@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>, Yabin Cui <yabinc@google.com>,
	Keita Morisaki <keyz@google.com>,
	Jie Gan <jie.gan@oss.qualcomm.com>,
	Yuanfang Zhang <quic_yuanfang@quicinc.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Tamas Petz <tamas.petz@arm.com>,
	Thomas Gleixner <tglx@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v11 25/27] coresight: sysfs: Increment refcount only for system tracers
Date: Wed, 6 May 2026 10:57:20 +0100	[thread overview]
Message-ID: <c7e4349a-3c47-4908-b677-15a5360ce7a9@arm.com> (raw)
In-Reply-To: <20260501-arm_coresight_path_power_management_improvement-v11-25-fc7fb9d5af1c@arm.com>

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@linaro.org>
> Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
> Reviewed-by: James Clark <james.clark@linaro.org>
> Tested-by: Jie Gan <jie.gan@oss.qualcomm.com>
> Signed-off-by: Leo Yan <leo.yan@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.

Rest looks fine to me.

Suzuki


> +		csdev->refcnt++;
> +}
> +
> +static void coresight_source_put_refcnt(struct coresight_device *csdev)
> +{
> +	if (csdev->subtype.source_subtype ==
> +			CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE)
> +		csdev->refcnt--;
> +}
> +
>   static int coresight_enable_source_sysfs(struct coresight_device *csdev,
>   					 enum cs_mode mode,
>   					 struct coresight_path *path)
> @@ -57,14 +79,14 @@ static int coresight_enable_source_sysfs(struct coresight_device *csdev,
>   			return ret;
>   	}
>   
> -	csdev->refcnt++;
> +	coresight_source_get_refcnt(csdev);
>   
>   	return 0;
>   }
>   
>   /**
> - *  coresight_disable_source_sysfs - Drop the reference count by 1 and disable
> - *  the device if there are no users left.
> + *  coresight_disable_source_sysfs - Drop the reference count by 1 for software
> + *  sources. Disable the device if there are no users left.
>    *
>    *  @csdev: The coresight device to disable
>    *  @data: Opaque data to pass on to the disable function of the source device.
> @@ -79,7 +101,7 @@ static bool coresight_disable_source_sysfs(struct coresight_device *csdev,
>   	if (coresight_get_mode(csdev) != CS_MODE_SYSFS)
>   		return false;
>   
> -	csdev->refcnt--;
> +	coresight_source_put_refcnt(csdev);
>   	if (csdev->refcnt == 0) {
>   		coresight_disable_source(csdev, data);
>   		return true;
> @@ -156,9 +178,6 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
>   	int ret = 0;
>   	struct coresight_device *sink;
>   	struct coresight_path *path;
> -	enum coresight_dev_subtype_source subtype;
> -
> -	subtype = csdev->subtype.source_subtype;
>   
>   	mutex_lock(&coresight_mutex);
>   
> @@ -173,13 +192,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
>   	 * doesn't hold coresight_mutex.
>   	 */
>   	if (coresight_get_mode(csdev) == CS_MODE_SYSFS) {
> -		/*
> -		 * There could be multiple applications driving the software
> -		 * source. So keep the refcount for each such user when the
> -		 * source is already enabled.
> -		 */
> -		if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE)
> -			csdev->refcnt++;
> +		coresight_source_get_refcnt(csdev);
>   		goto out;
>   	}
>   
> 



  reply	other threads:[~2026-05-06  9:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01 16:47 [PATCH v11 00/27] CoreSight: Refactor power management for CoreSight path Leo Yan
2026-05-01 16:47 ` [PATCH v11 01/27] coresight: Handle helper enable failure properly Leo Yan
2026-05-01 16:47 ` [PATCH v11 02/27] coresight: Extract device init into coresight_init_device() Leo Yan
2026-05-01 16:47 ` [PATCH v11 03/27] coresight: Populate CPU ID into coresight_device Leo Yan
2026-05-01 16:47 ` [PATCH v11 04/27] coresight: Remove .cpu_id() callback from source ops Leo Yan
2026-05-01 16:47 ` [PATCH v11 05/27] coresight: Take hotplug lock in enable_source_store() for Sysfs mode Leo Yan
2026-05-01 16:47 ` [PATCH v11 06/27] coresight: perf: Retrieve path and source from event data Leo Yan
2026-05-01 16:47 ` [PATCH v11 07/27] coresight: Take a reference on csdev Leo Yan
2026-05-01 16:47 ` [PATCH v11 08/27] coresight: Move per-CPU source pointer to core layer Leo Yan
2026-05-01 16:47 ` [PATCH v11 09/27] coresight: Grab per-CPU source device during AUX setup Leo Yan
2026-05-06  9:08   ` Suzuki K Poulose
2026-05-01 16:47 ` [PATCH v11 10/27] coresight: Register CPU PM notifier in core layer Leo Yan
2026-05-01 16:47 ` [PATCH v11 11/27] coresight: etm4x: Hook CPU PM callbacks Leo Yan
2026-05-01 16:47 ` [PATCH v11 12/27] coresight: etm4x: Remove redundant checks in PM save and restore Leo Yan
2026-05-01 16:47 ` [PATCH v11 13/27] coresight: syscfg: Use IRQ-safe spinlock to protect active variables Leo Yan
2026-05-01 16:47 ` [PATCH v11 14/27] coresight: Move source helper disabling to coresight_disable_path() Leo Yan
2026-05-06  9:05   ` Suzuki K Poulose
2026-05-06  9:33     ` Leo Yan
2026-05-01 16:47 ` [PATCH v11 15/27] coresight: Control path with range Leo Yan
2026-05-01 16:47 ` [PATCH v11 16/27] coresight: Use helpers to fetch first and last nodes Leo Yan
2026-05-01 16:47 ` [PATCH v11 17/27] coresight: Introduce coresight_enable_source() helper Leo Yan
2026-05-01 16:47 ` [PATCH v11 18/27] coresight: Save active path for system tracers Leo Yan
2026-05-01 16:48 ` [PATCH v11 19/27] coresight: etm4x: Set active path on target CPU Leo Yan
2026-05-01 16:48 ` [PATCH v11 20/27] coresight: etm3x: " Leo Yan
2026-05-01 16:48 ` [PATCH v11 21/27] coresight: sysfs: Use source's path pointer for path control Leo Yan
2026-05-01 16:48 ` [PATCH v11 22/27] coresight: Control path during CPU idle Leo Yan
2026-05-01 16:48 ` [PATCH v11 23/27] coresight: Add PM callbacks for sink device Leo Yan
2026-05-01 16:48 ` [PATCH v11 24/27] coresight: trbe: Save and restore state across CPU low power state Leo Yan
2026-05-01 16:48 ` [PATCH v11 25/27] coresight: sysfs: Increment refcount only for system tracers Leo Yan
2026-05-06  9:57   ` Suzuki K Poulose [this message]
2026-05-06 10:18     ` Leo Yan
2026-05-01 16:48 ` [PATCH v11 26/27] coresight: Move CPU hotplug callbacks to core layer Leo Yan
2026-05-01 16:48 ` [PATCH v11 27/27] coresight: sysfs: Validate CPU online status for per-CPU sources Leo Yan
2026-05-06  7:33 ` [PATCH v11 00/27] CoreSight: Refactor power management for CoreSight path Jie Gan
2026-05-06  9:38   ` Leo Yan

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=c7e4349a-3c47-4908-b677-15a5360ce7a9@arm.com \
    --to=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=keyz@google.com \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@arm.com \
    --cc=peterz@infradead.org \
    --cc=quic_yuanfang@quicinc.com \
    --cc=tamas.petz@arm.com \
    --cc=tglx@kernel.org \
    --cc=will@kernel.org \
    --cc=yabinc@google.com \
    --cc=yeoreum.yun@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