From: James Clark <james.clark@linaro.org>
To: Leo Yan <leo.yan@arm.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
Yeoreum Yun <yeoreum.yun@arm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Yabin Cui <yabinc@google.com>,
Yuanfang Zhang <quic_yuanfang@quicinc.com>
Subject: Re: [PATCH v4 07/15] coresight: syscfg: Use spinlock to protect active variables
Date: Mon, 10 Nov 2025 11:09:17 +0000 [thread overview]
Message-ID: <56344438-5730-4dfe-86ca-738aa94ef483@linaro.org> (raw)
In-Reply-To: <20251104-arm_coresight_path_power_management_improvement-v4-7-3d4bba674709@arm.com>
On 04/11/2025 3:21 pm, Leo Yan wrote:
> To support dynamically enabling and disabling the CoreSight path during
> CPU idle, cscfg_config_sysfs_get_active_cfg() may be called by the ETM
> driver in an atomic context. However, the function currently acquires a
> mutex, which is a sleepable lock, and this is not allowed in atomic
> context.
>
> To make cscfg_config_sysfs_get_active_cfg() called in the idle flow,
> replace the mutex with a raw spinlock to protect the active
> variables.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
> ---
> drivers/hwtracing/coresight/coresight-syscfg.c | 22 +++++++++++++---------
> drivers/hwtracing/coresight/coresight-syscfg.h | 2 ++
> 2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
> index 6836b05986e8091b4f8ad7d082d6a016f8cf7d74..53aa1a44f9ac8f65b4e3cce06a33255abfc17351 100644
> --- a/drivers/hwtracing/coresight/coresight-syscfg.c
> +++ b/drivers/hwtracing/coresight/coresight-syscfg.c
> @@ -957,15 +957,19 @@ int cscfg_config_sysfs_activate(struct cscfg_config_desc *config_desc, bool acti
>
> cfg_hash = (unsigned long)config_desc->event_ea->var;
>
> + raw_spin_lock(&cscfg_mgr->spinlock);
> +
> if (activate) {
> +
> /* cannot be a current active value to activate this */
> if (cscfg_mgr->sysfs_active_config) {
> err = -EBUSY;
> - goto exit_unlock;
> + } else {
> + err = _cscfg_activate_config(cfg_hash);
> + if (!err)
> + cscfg_mgr->sysfs_active_config = cfg_hash;
> }
> - err = _cscfg_activate_config(cfg_hash);
> - if (!err)
> - cscfg_mgr->sysfs_active_config = cfg_hash;
> +
> } else {
> /* disable if matching current value */
> if (cscfg_mgr->sysfs_active_config == cfg_hash) {
> @@ -975,7 +979,8 @@ int cscfg_config_sysfs_activate(struct cscfg_config_desc *config_desc, bool acti
> err = -EINVAL;
> }
>
> -exit_unlock:
> + raw_spin_unlock(&cscfg_mgr->spinlock);
> +
> mutex_unlock(&cscfg_mutex);
> return err;
> }
> @@ -983,9 +988,8 @@ int cscfg_config_sysfs_activate(struct cscfg_config_desc *config_desc, bool acti
> /* set the sysfs preset value */
> void cscfg_config_sysfs_set_preset(int preset)
> {
> - mutex_lock(&cscfg_mutex);
> + guard(raw_spinlock)(&cscfg_mgr->spinlock);
> cscfg_mgr->sysfs_active_preset = preset;
> - mutex_unlock(&cscfg_mutex);
> }
>
> /*
> @@ -994,10 +998,9 @@ void cscfg_config_sysfs_set_preset(int preset)
> */
> void cscfg_config_sysfs_get_active_cfg(unsigned long *cfg_hash, int *preset)
> {
> - mutex_lock(&cscfg_mutex);
> + guard(raw_spinlock)(&cscfg_mgr->spinlock);
> *preset = cscfg_mgr->sysfs_active_preset;
> *cfg_hash = cscfg_mgr->sysfs_active_config;
> - mutex_unlock(&cscfg_mutex);
> }
> EXPORT_SYMBOL_GPL(cscfg_config_sysfs_get_active_cfg);
>
> @@ -1201,6 +1204,7 @@ static int cscfg_create_device(void)
> INIT_LIST_HEAD(&cscfg_mgr->load_order_list);
> atomic_set(&cscfg_mgr->sys_active_cnt, 0);
> cscfg_mgr->load_state = CSCFG_NONE;
> + raw_spin_lock_init(&cscfg_mgr->spinlock);
>
> /* setup the device */
> dev = cscfg_device();
> diff --git a/drivers/hwtracing/coresight/coresight-syscfg.h b/drivers/hwtracing/coresight/coresight-syscfg.h
> index 66e2db890d8203853a0c3c907b48aa66dd8014e6..f52aba4608dadc1c7666e0e28c9b43dc1c33d1eb 100644
> --- a/drivers/hwtracing/coresight/coresight-syscfg.h
> +++ b/drivers/hwtracing/coresight/coresight-syscfg.h
> @@ -42,6 +42,7 @@ enum cscfg_load_ops {
> * @sysfs_active_config:Active config hash used if CoreSight controlled from sysfs.
> * @sysfs_active_preset:Active preset index used if CoreSight controlled from sysfs.
> * @load_state: A multi-stage load/unload operation is in progress.
> + * @spinlock: Exclusive access sysfs_active_* variables.
> */
> struct cscfg_manager {
> struct device dev;
> @@ -54,6 +55,7 @@ struct cscfg_manager {
> u32 sysfs_active_config;
> int sysfs_active_preset;
> enum cscfg_load_ops load_state;
> + raw_spinlock_t spinlock;
> };
>
> /* get reference to dev in cscfg_manager */
>
next prev parent reply other threads:[~2025-11-10 11:09 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 15:21 [PATCH v4 00/15] CoreSight: Refactor power management for CoreSight path Leo Yan
2025-11-04 15:21 ` [PATCH v4 01/15] coresight: sysfs: Validate CPU online status for per-CPU sources Leo Yan
2025-11-04 15:21 ` [PATCH v4 02/15] coresight: Set per CPU source pointer Leo Yan
2025-11-04 15:21 ` [PATCH v4 03/15] coresight: Register CPU PM notifier in core layer Leo Yan
2025-11-10 10:49 ` James Clark
2025-11-11 12:13 ` Suzuki K Poulose
2025-11-12 18:09 ` Leo Yan
2025-11-04 15:21 ` [PATCH v4 04/15] coresight: etm4x: Hook CPU PM callbacks Leo Yan
2025-11-10 10:50 ` James Clark
2025-11-04 15:21 ` [PATCH v4 05/15] coresight: Add callback to determine if PM is needed Leo Yan
2025-11-10 10:54 ` James Clark
2025-11-04 15:21 ` [PATCH v4 06/15] coresight: etm4x: Remove redundant condition checks in save and restore Leo Yan
2025-11-04 15:21 ` [PATCH v4 07/15] coresight: syscfg: Use spinlock to protect active variables Leo Yan
2025-11-10 11:09 ` James Clark [this message]
2025-11-04 15:21 ` [PATCH v4 08/15] coresight: Introduce coresight_enable_source() helper Leo Yan
2025-11-10 11:09 ` James Clark
2025-11-04 15:21 ` [PATCH v4 09/15] coresight: Save activated path into source device Leo Yan
2025-11-10 11:18 ` James Clark
2025-11-17 14:19 ` Leo Yan
2025-11-10 12:29 ` James Clark
2025-11-11 14:10 ` Suzuki K Poulose
2025-11-17 15:16 ` Leo Yan
2025-11-04 15:21 ` [PATCH v4 10/15] coresight: Add 'in_idle' argument to enable/disable path functions Leo Yan
2025-11-10 11:25 ` James Clark
2025-11-10 11:48 ` James Clark
2025-11-18 9:25 ` Leo Yan
2025-11-04 15:21 ` [PATCH v4 11/15] coresight: Control path during CPU idle Leo Yan
2025-11-10 11:44 ` James Clark
2025-11-04 15:21 ` [PATCH v4 12/15] coresight: Add PM callbacks for percpu sink Leo Yan
2025-11-04 15:21 ` [PATCH v4 13/15] coresight: trbe: Save and restore state across CPU low power state Leo Yan
2025-11-10 12:01 ` James Clark
2025-11-11 14:16 ` Suzuki K Poulose
2025-11-04 15:21 ` [PATCH v4 14/15] coresight: Take hotplug lock in enable_source_store() for Sysfs mode Leo Yan
2025-11-04 15:21 ` [PATCH v4 15/15] coresight: Move CPU hotplug callbacks to core layer Leo Yan
2025-11-10 12:20 ` James Clark
2025-11-19 14:48 ` Leo Yan
2025-11-19 15:19 ` James Clark
2025-11-19 15:36 ` Leo Yan
2025-11-19 15:41 ` James Clark
2025-11-10 15:33 ` [PATCH v4 00/15] CoreSight: Refactor power management for CoreSight path James Clark
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=56344438-5730-4dfe-86ca-738aa94ef483@linaro.org \
--to=james.clark@linaro.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mike.leach@linaro.org \
--cc=quic_yuanfang@quicinc.com \
--cc=suzuki.poulose@arm.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.