]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: Protect unregistration with mutex
authorLeo Yan <leo.yan@arm.com>
Mon, 9 Feb 2026 12:44:35 +0000 (12:44 +0000)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Wed, 25 Feb 2026 11:14:44 +0000 (11:14 +0000)
The device registration is protected by CoreSight mutex to ensure the
atomic operations when adding a device onto bus.  One the other hand,
the locking is absent when unregister a device.

Use mutex to ensure atomicity on device unregistration.  During
unregistration, unbinding the associated CTI device is not included in
the locking region, as CTI has its own locking mechanism.

Fixes: 8c1d3f79d9ca ("coresight: core: Fix coresight device probe failure issue")
Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260209-arm_coresight_refactor_dev_register-v4-3-62d6042f76f7@arm.com
drivers/hwtracing/coresight/coresight-core.c

index e2c0f971eccffb303995e0af854d6d92448e4ff9..c228c27e8517b84d1e77dfefde3c8c3aac569db2 100644 (file)
@@ -1432,14 +1432,17 @@ EXPORT_SYMBOL_GPL(coresight_register);
 
 void coresight_unregister(struct coresight_device *csdev)
 {
-       etm_perf_del_symlink_sink(csdev);
        /* Remove references of that device in the topology */
        if (cti_assoc_ops && cti_assoc_ops->remove)
                cti_assoc_ops->remove(csdev);
+
+       mutex_lock(&coresight_mutex);
+       etm_perf_del_symlink_sink(csdev);
        coresight_remove_conns(csdev);
        coresight_clear_default_sink(csdev);
        coresight_release_platform_data(csdev, csdev->dev.parent, csdev->pdata);
        device_unregister(&csdev->dev);
+       mutex_unlock(&coresight_mutex);
 }
 EXPORT_SYMBOL_GPL(coresight_unregister);