Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@arm.com>
Reviewed-by: Mike Leach <mike.leach@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260224-arm_coresight_refactor_cti_resource_release-v1-1-ff1b2bca9176@arm.com

authored by

Leo Yan and committed by
Suzuki K Poulose
55bf8be6 6de23f81

+3 -23
+3 -21
drivers/hwtracing/coresight/coresight-cti-core.c
··· 823 823 .helper_ops = &cti_ops_ect, 824 824 }; 825 825 826 - /* 827 - * Free up CTI specific resources 828 - * called by dev->release, need to call down to underlying csdev release. 829 - */ 830 - static void cti_device_release(struct device *dev) 826 + static void cti_remove(struct amba_device *adev) 831 827 { 832 - struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); 828 + struct cti_drvdata *drvdata = dev_get_drvdata(&adev->dev); 833 829 struct cti_drvdata *ect_item, *ect_tmp; 834 830 835 831 mutex_lock(&ect_mutex); 832 + cti_remove_conn_xrefs(drvdata); 836 833 cti_pm_release(drvdata); 837 834 838 835 /* remove from the list */ ··· 839 842 break; 840 843 } 841 844 } 842 - mutex_unlock(&ect_mutex); 843 - 844 - if (drvdata->csdev_release) 845 - drvdata->csdev_release(dev); 846 - } 847 - static void cti_remove(struct amba_device *adev) 848 - { 849 - struct cti_drvdata *drvdata = dev_get_drvdata(&adev->dev); 850 - 851 - mutex_lock(&ect_mutex); 852 - cti_remove_conn_xrefs(drvdata); 853 845 mutex_unlock(&ect_mutex); 854 846 855 847 coresight_unregister(drvdata->csdev); ··· 932 946 /* set any cross references */ 933 947 cti_update_conn_xrefs(drvdata); 934 948 mutex_unlock(&ect_mutex); 935 - 936 - /* set up release chain */ 937 - drvdata->csdev_release = drvdata->csdev->dev.release; 938 - drvdata->csdev->dev.release = cti_device_release; 939 949 940 950 /* all done - dec pm refcount */ 941 951 pm_runtime_put(&adev->dev);
-2
drivers/hwtracing/coresight/coresight-cti.h
··· 170 170 * @spinlock: Control data access to one at a time. 171 171 * @config: Configuration data for this CTI device. 172 172 * @node: List entry of this device in the list of CTI devices. 173 - * @csdev_release: release function for underlying coresight_device. 174 173 */ 175 174 struct cti_drvdata { 176 175 void __iomem *base; ··· 178 179 raw_spinlock_t spinlock; 179 180 struct cti_config config; 180 181 struct list_head node; 181 - void (*csdev_release)(struct device *dev); 182 182 }; 183 183 184 184 /*