The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Yeoreum Yun <yeoreum.yun@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 v9 04/13] coresight: etm4x: fix inconsistencies with sysfs configuration
Date: Tue, 11 Aug 2026 16:45:21 +0100	[thread overview]
Message-ID: <20260811154521.GF15499@e132581.arm.com> (raw)
In-Reply-To: <20260725113645.57519-5-yeoreum.yun@arm.com>

On Sat, Jul 25, 2026 at 12:36:36PM +0100, Yeoreum Yun wrote:

[...]

> As the active_config is used for cfg-configfs, etmv4 doesn't need to set
> its lock for the cfg-configfs since the active_config is proceted by cs_mode
> otherwise it would make a possible cpu-stall when it get interrupt while
> setting the sysfs configuration.
> 
> Therefore, set the drv_spinlock for cfg-configfs as NULL and
> let the cfg-configfs disable irq without grap drv_spinlock when it is NULL.

I understand that this patch tries to put all the changes (active_config
and drv_spinlock) into a single patch so that it can be backported to
stable kernels.

However, the change is now quite large, and I suspect it will also be
difficult for maintainers to backport it to stable kernels. The fixes
tag 54ff892b76c6 is quite old, while this patch also touches cfgfs
which was introduced much later.

Can we treat this as a refactoring instead and split it into at least
two patches? This would make it easier to review now and easier to
understand later if someone will read the changes.

 - Lock refactoring
 - SMP call refactoring
 - active_config refactoring

>  static int cscfg_set_on_enable(struct cscfg_feature_csdev *feat_csdev)
>  {
> -	unsigned long flags;
>  	int i;
>  
> -	raw_spin_lock_irqsave(feat_csdev->drv_spinlock, flags);
> -	for (i = 0; i < feat_csdev->nr_regs; i++)
> -		cscfg_set_reg(&feat_csdev->regs_csdev[i]);
> -	raw_spin_unlock_irqrestore(feat_csdev->drv_spinlock, flags);
> +	scoped_guard (feat_csdev_lock, feat_csdev) {

scoped_guard(feat_csdev_lock, feat_csdev) {

> +		for (i = 0; i < feat_csdev->nr_regs; i++)
> +			cscfg_set_reg(&feat_csdev->regs_csdev[i]);
> +	}
>  	dev_dbg(&feat_csdev->csdev->dev, "Feature %s: %s",
>  		feat_csdev->feat_desc->name, "set on enable");
>  	return 0;
> @@ -88,13 +87,12 @@ static int cscfg_set_on_enable(struct cscfg_feature_csdev *feat_csdev)
>  /* copy back values from the driver locations referenced in cscfg_reg_csdev */
>  static void cscfg_save_on_disable(struct cscfg_feature_csdev *feat_csdev)
>  {
> -	unsigned long flags;
>  	int i;
>  
> -	raw_spin_lock_irqsave(feat_csdev->drv_spinlock, flags);
> -	for (i = 0; i < feat_csdev->nr_regs; i++)
> -		cscfg_save_reg(&feat_csdev->regs_csdev[i]);
> -	raw_spin_unlock_irqrestore(feat_csdev->drv_spinlock, flags);
> +	scoped_guard (feat_csdev_lock, feat_csdev) {

scoped_guard(feat_csdev_lock, feat_csdev) {

> +		for (i = 0; i < feat_csdev->nr_regs; i++)
> +			cscfg_save_reg(&feat_csdev->regs_csdev[i]);
> +	}
>  	dev_dbg(&feat_csdev->csdev->dev, "Feature %s: %s",
>  		feat_csdev->feat_desc->name, "save on disable");
>  }
> diff --git a/drivers/hwtracing/coresight/coresight-config.h b/drivers/hwtracing/coresight/coresight-config.h
> index 90fd937d3bd8..0782db3b1b74 100644
> --- a/drivers/hwtracing/coresight/coresight-config.h
> +++ b/drivers/hwtracing/coresight/coresight-config.h
> @@ -8,6 +8,7 @@
>  #define _CORESIGHT_CORESIGHT_CONFIG_H
>  
>  #include <linux/coresight.h>
> +#include <linux/cleanup.h>

Alphabet order. Move cleanup.h above coresight.h.

>  #include <linux/types.h>
>  
>  /* CoreSight Configuration Management - component and system wide configuration */
> @@ -259,4 +260,29 @@ void cscfg_csdev_disable_config(struct cscfg_config_csdev *config_csdev);
>  /* reset a feature to default values */
>  void cscfg_reset_feat(struct cscfg_feature_csdev *feat_csdev);
>  
> +#define feat_csdev_lock(feat_csdev, flags)				\

Could use inline here?

static inline void feat_csdev_lock_irqsave(..., unsigned long *flags)
{
    ...
}

> +	do {								\
> +		raw_spinlock_t *__lock = feat_csdev->drv_spinlock;	\
> +		typecheck(unsigned long, flags);			\

After using inline, no need typecheck.

> +		if (__lock)						\
> +			raw_spin_lock_irqsave(__lock, flags);		\
> +		else							\
> +			local_irq_save(flags);				\

If __lock is NULL, do we still need local_irq_save()? Seems to me, if
lock is NULL pointer, it means no race condition.

> +	} while (0)

> +
> +#define feat_csdev_unlock(feat_csdev, flags)				\
> +	do {								\
> +		raw_spinlock_t *__lock = feat_csdev->drv_spinlock;	\
> +		typecheck(unsigned long, flags);			\
> +		if (__lock)						\
> +			raw_spin_unlock_irqrestore(__lock, flags);	\
> +		else							\
> +			local_irq_restore(flags);			\
> +	} while (0)

Use inline for feat_csdev_unlock() and rename it to
feat_csdev_unlock_irqrestore().

Otherwise, LGTM.

Thanks,
Leo

  reply	other threads:[~2026-08-11 15:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25 11:36 [PATCH v9 00/13] fix several inconsistencies with sysfs configuration in etmX Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 01/13] coresight: etm4x: fix wrong check of etm4x_sspcicrn_present() Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 02/13] coresight: etm4x: fix underflow for usage of (nrseqstate - 1) Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 03/13] coresight: etm4x: fix leaked trace id Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 04/13] coresight: etm4x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-08-11 15:45   ` Leo Yan [this message]
2026-08-11 16:56     ` Yeoreum Yun
2026-08-11 17:45       ` Leo Yan
2026-08-11 18:01         ` Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 05/13] coresight: etm4x: missing cscfg_csdev_disable_active_config() in perf enable Yeoreum Yun
2026-08-11 16:25   ` Leo Yan
2026-07-25 11:36 ` [PATCH v9 06/13] coresight: etm3x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 07/13] coresight: etm3x: change drvdata->spinlock type to raw_spin_lock_t Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 08/13] coresight: etm3x: remove redundant cpu online check on etm_enable_sysfs() Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 09/13] coresight: etm4x: introduce struct etm4_caps Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 10/13] coresight: etm4x: exclude ss_status from drvdata->config Yeoreum Yun
2026-08-11 17:02   ` Leo Yan
2026-08-11 17:08     ` Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 11/13] coresight: etm4x: remove s_ex_level from config Yeoreum Yun
2026-08-11 17:25   ` Leo Yan
2026-08-11 17:47     ` Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 12/13] coresight: etm4x: remove redundant fields in etmv4_save_state Yeoreum Yun
2026-07-25 11:36 ` [PATCH v9 13/13] coresight: etm3x: introduce struct etm_caps Yeoreum Yun
2026-08-06 13:29 ` (subset) [PATCH v9 00/13] fix several inconsistencies with sysfs configuration in etmX Suzuki K Poulose
2026-08-06 13:49   ` 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=20260811154521.GF15499@e132581.arm.com \
    --to=leo.yan@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=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@arm.com \
    --cc=suzuki.poulose@arm.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