]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
coresight: cti: Fix bug clearing sysfs links on callback
authorMike Leach <mike.leach@linaro.org>
Mon, 28 Sep 2020 16:35:06 +0000 (10:35 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:07:45 +0000 (10:07 +0100)
[ Upstream commit cab280bf3533c72f95ebdb65ce534b5cdc4729dc ]

During module unload, a coresight driver module will call back into
the CTI driver to remove any links between the two devices.

The current code has 2 issues:-
1) in the CTI driver the matching code is matching to the wrong device
so misses all the links.
2) The callback is called too late in the unload process resulting in a
crash.

This fixes both the issues.

Fixes: 177af8285b59 ("coresight: cti: Enable CTI associated with devices")
Reported-by: Tingwei Zhang <tingwei@codeaurora.org>
Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Tingwei Zhang <tingwei@codeaurora.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20200928163513.70169-19-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwtracing/coresight/coresight-cti.c
drivers/hwtracing/coresight/coresight.c

index 92aa535f9e1349a3ef5d7a8667227395067ff372..167fbc2e7033fdef3c41d178ec7819f4ab2de7c4 100644 (file)
@@ -592,7 +592,7 @@ void cti_remove_assoc_from_csdev(struct coresight_device *csdev)
                ctidrv = csdev_to_cti_drvdata(csdev->ect_dev);
                ctidev = &ctidrv->ctidev;
                list_for_each_entry(tc, &ctidev->trig_cons, node) {
-                       if (tc->con_dev == csdev->ect_dev) {
+                       if (tc->con_dev == csdev) {
                                cti_remove_sysfs_link(ctidrv, tc);
                                tc->con_dev = NULL;
                                break;
index f3efbb3b2b4d185bd792274abfd739f1437347e0..cf03af09c6ced8fe105ad513051f0c9d85f4712b 100644 (file)
@@ -1023,7 +1023,6 @@ static void coresight_device_release(struct device *dev)
 {
        struct coresight_device *csdev = to_coresight_device(dev);
 
-       cti_remove_assoc_from_csdev(csdev);
        fwnode_handle_put(csdev->dev.fwnode);
        kfree(csdev->refcnt);
        kfree(csdev);
@@ -1357,6 +1356,7 @@ void coresight_unregister(struct coresight_device *csdev)
 {
        etm_perf_del_symlink_sink(csdev);
        /* Remove references of that device in the topology */
+       cti_remove_assoc_from_csdev(csdev);
        coresight_remove_conns(csdev);
        coresight_release_platform_data(csdev, csdev->pdata);
        device_unregister(&csdev->dev);