[PATCH] coresight: cti: Move resource release to cti_remove()

Mike Leach Mike.Leach at arm.com
Tue Feb 24 14:27:54 PST 2026



> -----Original Message-----
> From: Leo Yan <leo.yan at arm.com>
> Sent: Tuesday, February 24, 2026 10:56 AM
> 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>
> 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] coresight: cti: Move resource release to cti_remove()
> 
> Currently, CTI driver releases resource by deferring
> cti_device_release() to the device unregistration:
> 
>   cti_remove()
>    `> coresight_unregister()
>        `> cti_remove_assoc_from_csdev()
>        `> device_unregister()
>            `> cti_device_release()
>                `> mutex_lock(&ect_mutex)
>                `> release CTI resource
>                `> mutex_unlock(&ect_mutex)
> 
> In the above flow, two different CTI release callbacks are involved:
> cti_remove_assoc_from_csdev() and cti_device_release().  The former is
> used by a CoreSight device to unbind its associated CTI helper device,
> while the latter releases resources for the CTI device itself.  Since
> there is no dependency between them, it is unnecessary to defer the CTI
> resource release until device unregistration.
> 
> This commit releases the resources directly in cti_remove() and remove
> the injected release callback.
> 
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
>  drivers/hwtracing/coresight/coresight-cti-core.c | 24 +++---------------------
>  drivers/hwtracing/coresight/coresight-cti.h      |  2 --
>  2 files changed, 3 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c
> b/drivers/hwtracing/coresight/coresight-cti-core.c
> index
> bfbc365bb2ef2744efab11c056b8450472957005..7a8f1ef6b94e8ab3363ea
> 62db95b0bc302292cd7 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-core.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-core.c
> @@ -823,16 +823,13 @@ static const struct coresight_ops cti_ops = {
>  	.helper_ops = &cti_ops_ect,
>  };
> 
> -/*
> - * Free up CTI specific resources
> - * called by dev->release, need to call down to underlying csdev release.
> - */
> -static void cti_device_release(struct device *dev)
> +static void cti_remove(struct amba_device *adev)
>  {
> -	struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
> +	struct cti_drvdata *drvdata = dev_get_drvdata(&adev->dev);
>  	struct cti_drvdata *ect_item, *ect_tmp;
> 
>  	mutex_lock(&ect_mutex);
> +	cti_remove_conn_xrefs(drvdata);
>  	cti_pm_release(drvdata);
> 
>  	/* remove from the list */
> @@ -844,17 +841,6 @@ static void cti_device_release(struct device *dev)
>  	}
>  	mutex_unlock(&ect_mutex);
> 
> -	if (drvdata->csdev_release)
> -		drvdata->csdev_release(dev);
> -}
> -static void cti_remove(struct amba_device *adev)
> -{
> -	struct cti_drvdata *drvdata = dev_get_drvdata(&adev->dev);
> -
> -	mutex_lock(&ect_mutex);
> -	cti_remove_conn_xrefs(drvdata);
> -	mutex_unlock(&ect_mutex);
> -
>  	coresight_unregister(drvdata->csdev);
>  }
> 
> @@ -947,10 +933,6 @@ static int cti_probe(struct amba_device *adev, const
> struct amba_id *id)
>  	cti_update_conn_xrefs(drvdata);
>  	mutex_unlock(&ect_mutex);
> 
> -	/* set up release chain */
> -	drvdata->csdev_release = drvdata->csdev->dev.release;
> -	drvdata->csdev->dev.release = cti_device_release;
> -
>  	/* all done - dec pm refcount */
>  	pm_runtime_put(&adev->dev);
>  	dev_info(&drvdata->csdev->dev, "CTI initialized\n");
> diff --git a/drivers/hwtracing/coresight/coresight-cti.h
> b/drivers/hwtracing/coresight/coresight-cti.h
> index
> 4f89091ee93f5fb046d93b97a4085051fca6b39d..daff9e32a6daca90f4d5f4
> 726f163fdd9106191c 100644
> --- a/drivers/hwtracing/coresight/coresight-cti.h
> +++ b/drivers/hwtracing/coresight/coresight-cti.h
> @@ -170,7 +170,6 @@ struct cti_config {
>   * @spinlock:	Control data access to one at a time.
>   * @config:	Configuration data for this CTI device.
>   * @node:	List entry of this device in the list of CTI devices.
> - * @csdev_release: release function for underlying coresight_device.
>   */
>  struct cti_drvdata {
>  	void __iomem *base;
> @@ -179,7 +178,6 @@ struct cti_drvdata {
>  	raw_spinlock_t spinlock;
>  	struct cti_config config;
>  	struct list_head node;
> -	void (*csdev_release)(struct device *dev);
>  };
> 
>  /*
> 
> ---
> base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
> change-id: 20260224-arm_coresight_refactor_cti_resource_release-
> 24d9bde4f13c
> 
> Best regards,
> --
> Leo Yan <leo.yan at arm.com>

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


More information about the linux-arm-kernel mailing list