[PATCH 6/8] coresight: cti: Remove hw_powered flag

Mike Leach Mike.Leach at arm.com
Fri Feb 20 06:25:57 PST 2026



> -----Original Message-----
> From: Leo Yan <leo.yan at arm.com>
> Sent: Monday, February 9, 2026 6:01 PM
> To: Suzuki Poulose <Suzuki.Poulose at arm.com>; Mike Leach
> <Mike.Leach at arm.com>; James Clark <james.clark at linaro.org>; Alexander
> Shishkin <alexander.shishkin at linux.intel.com>; Greg Kroah-Hartman
> <gregkh at linuxfoundation.org>; Mathieu Poirier
> <mathieu.poirier at linaro.org>; Tingwei Zhang <quic_tingwei at quicinc.com>;
> Yingchao Deng <yingchao.deng at oss.qualcomm.com>; Jie Gan
> <jie.gan at oss.qualcomm.com>
> Cc: coresight at lists.linaro.org; linux-arm-kernel at lists.infradead.org; linux-
> kernel at vger.kernel.org; Leo Yan <Leo.Yan at arm.com>
> Subject: [PATCH 6/8] coresight: cti: Remove hw_powered flag
> 
> Since the CPU PM code has been removed from the CTI driver and the device
> is enabled via runtime PM, pm_runtime_active() can be used to check
> whether the device is powered.
> 
> As a result, the hw_powered flag is redundant, remove it.
> 
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
>  drivers/hwtracing/coresight/coresight-cti-core.c  | 11 ++++-----
>  drivers/hwtracing/coresight/coresight-cti-sysfs.c | 29 ++++++-----------------
>  drivers/hwtracing/coresight/coresight-cti.h       |  6 ++---
>  3 files changed, 13 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c
> b/drivers/hwtracing/coresight/coresight-cti-core.c
> index
> 48db87e2fd0f1a669f2d20a0014108da215e26fd..3b3b851a018851a8656e
> ba64e638c61f3d04b99f 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-core.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-core.c
> @@ -89,8 +89,8 @@ static int cti_enable_hw(struct cti_drvdata *drvdata)
> 
>  	guard(raw_spinlock_irqsave)(&drvdata->spinlock);
> 
> -	/* no need to do anything if enabled or unpowered*/
> -	if (config->hw_enabled || !config->hw_powered)
> +	/* no need to do anything if enabled */
> +	if (config->hw_enabled)
>  		goto cti_state_unchanged;
> 
>  	/* claim the device */
> @@ -123,8 +123,8 @@ static int cti_disable_hw(struct cti_drvdata *drvdata)
>  	if (--drvdata->config.enable_req_count > 0)
>  		return 0;
> 
> -	/* no need to do anything if disabled or cpu unpowered */
> -	if (!config->hw_enabled || !config->hw_powered)
> +	/* no need to do anything if disabled */
> +	if (!config->hw_enabled)
>  		return 0;
> 
>  	CS_UNLOCK(drvdata->base);
> @@ -725,9 +725,6 @@ static int cti_probe(struct amba_device *adev, const
> struct amba_id *id)
>  		return  PTR_ERR(pdata);
>  	}
> 
> -	/* default to powered - could change on PM notifications */
> -	drvdata->config.hw_powered = true;
> -
>  	/* set up device name - will depend if cpu bound or otherwise */
>  	if (drvdata->ctidev.cpu >= 0)
>  		cti_desc.name = devm_kasprintf(dev, GFP_KERNEL,
> "cti_cpu%d",
> diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> index
> a22cc9a2bee24eb6115e7adb61880cc86d03e12e..9ab586a5c9a4fd2a64c54
> 2aaaaa625e2299edd62 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> @@ -81,19 +81,12 @@ static ssize_t enable_show(struct device *dev,
>  			   char *buf)
>  {
>  	int enable_req;
> -	bool enabled, powered;
>  	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
> 
> -	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
> +	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock)
>  		enable_req = drvdata->config.enable_req_count;
> -		powered = drvdata->config.hw_powered;
> -		enabled = drvdata->config.hw_enabled;
> -	}
> 
> -	if (powered)
> -		return sprintf(buf, "%d\n", enabled);
> -	else
> -		return sprintf(buf, "%d\n", !!enable_req);
> +	return sprintf(buf, "%d\n", !!enable_req);
>  }
> 
>  static ssize_t enable_store(struct device *dev,
> @@ -131,11 +124,7 @@ static ssize_t powered_show(struct device *dev,
>  			    struct device_attribute *attr,
>  			    char *buf)
>  {
> -	bool powered;
> -	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
> -
> -	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock)
> -		powered = drvdata->config.hw_powered;
> +	bool powered = pm_runtime_active(dev->parent);
> 
>  	return sprintf(buf, "%d\n", powered);
>  }
> @@ -181,10 +170,8 @@ static ssize_t coresight_cti_reg_show(struct device
> *dev,
> 
>  	pm_runtime_get_sync(dev->parent);
> 
> -	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
> -		if (drvdata->config.hw_powered)
> -			val = cti_read_single_reg(drvdata, cti_attr->off);
> -	}
> +	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock)
> +		val = cti_read_single_reg(drvdata, cti_attr->off);
> 
>  	pm_runtime_put_sync(dev->parent);
>  	return sysfs_emit(buf, "0x%x\n", val);
> @@ -204,10 +191,8 @@ static __maybe_unused ssize_t
> coresight_cti_reg_store(struct device *dev,
> 
>  	pm_runtime_get_sync(dev->parent);
> 
> -	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
> -		if (drvdata->config.hw_powered)
> -			cti_write_single_reg(drvdata, cti_attr->off, val);
> -	}
> +	scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock)
> +		cti_write_single_reg(drvdata, cti_attr->off, val);
> 
>  	pm_runtime_put_sync(dev->parent);
>  	return size;
> diff --git a/drivers/hwtracing/coresight/coresight-cti.h
> b/drivers/hwtracing/coresight/coresight-cti.h
> index
> 400c1545b22bfe631144d24faceb354ff2d49166..c858847a5b80036fb4818
> 0ff7fbbfe684028cb89 100644
> --- a/drivers/hwtracing/coresight/coresight-cti.h
> +++ b/drivers/hwtracing/coresight/coresight-cti.h
> @@ -122,7 +122,6 @@ struct cti_device {
>   * @asicctl_impl: true if asicctl is implemented.
>   * @enable_req_count: CTI is enabled alongside >=1 associated devices.
>   * @hw_enabled: true if hw is currently enabled.
> - * @hw_powered: true if associated cpu powered on, or no cpu.
>   * @trig_in_use: bitfield of in triggers registered as in use.
>   * @trig_out_use: bitfield of out triggers registered as in use.
>   * @trig_out_filter: bitfield of out triggers that are blocked if filter
> @@ -146,7 +145,6 @@ struct cti_config {
>  	/* cti enable control */
>  	int enable_req_count;
>  	bool hw_enabled;
> -	bool hw_powered;
> 
>  	/* registered triggers and filtering */
>  	u32 trig_in_use;
> @@ -237,10 +235,10 @@ struct coresight_platform_data *
>  coresight_cti_get_platform_data(struct device *dev);
>  const char *cti_plat_get_node_name(struct fwnode_handle *fwnode);
> 
> -/* cti powered and enabled */
> +/* Check if a cti device is enabled */
>  static inline bool cti_is_active(struct cti_config *cfg)
>  {
> -	return cfg->hw_powered && cfg->hw_enabled;
> +	return cfg->hw_enabled;
>  }
> 
>  #endif  /* _CORESIGHT_CORESIGHT_CTI_H */
> 
> --
> 2.34.1

Reviewed-by: Mike Leach <mike.leach at arm.com>


More information about the linux-arm-kernel mailing list