coresight: removing bind/unbind options from sysfs
authorMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 2 Feb 2016 21:14:00 +0000 (14:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2019 04:23:29 +0000 (06:23 +0200)
[ Upstream commit b15f0fb657e040401d875d11ae13b269af8a16e0 ]

The coresight drivers have absolutely no control over bind and unbind
operations triggered from sysfs. The operations simply can't be
cancelled or denied event when one or several tracing sessions are
under way.  Since the memory associated to individual device is
invariably freed, the end result is a kernel crash when the path from
source to sink is travelled again as demonstrated here[1].

One solution could be to keep track of all the path (i.e tracing
session) that get created and iterate through the elements of those path
looking for the coresight device that is being removed.  This proposition
doesn't scale well since there is no upper bound on the amount of
concurrent trace session that can be created.

With the above in mind, this patch prevent devices from being unbounded
from their driver by using the driver->suppress_bind_attr option.  That way
trace sessions can be managed without fearing to loose devices.

Since device can't be removed anymore the xyz_remove() functions found in
each driver is also removed.

[1]. http://www.spinics.net/lists/arm-kernel/msg474952.html

Reported-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Mathieu Poirier <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-etb10.c
drivers/hwtracing/coresight/coresight-etm3x.c
drivers/hwtracing/coresight/coresight-etm4x.c
drivers/hwtracing/coresight/coresight-funnel.c
drivers/hwtracing/coresight/coresight-replicator-qcom.c
drivers/hwtracing/coresight/coresight-replicator.c
drivers/hwtracing/coresight/coresight-tmc.c
drivers/hwtracing/coresight/coresight-tpiu.c

index 77d0f9c1118dfdfcc29a2d0435f3311a12793414..92969dae739d837f416bd8824363baacea39efc4 100644 (file)
@@ -489,15 +489,6 @@ err_misc_register:
        return ret;
 }
 
-static int etb_remove(struct amba_device *adev)
-{
-       struct etb_drvdata *drvdata = amba_get_drvdata(adev);
-
-       misc_deregister(&drvdata->miscdev);
-       coresight_unregister(drvdata->csdev);
-       return 0;
-}
-
 #ifdef CONFIG_PM
 static int etb_runtime_suspend(struct device *dev)
 {
@@ -537,10 +528,10 @@ static struct amba_driver etb_driver = {
                .name   = "coresight-etb10",
                .owner  = THIS_MODULE,
                .pm     = &etb_dev_pm_ops,
+               .suppress_bind_attrs = true,
 
        },
        .probe          = etb_probe,
-       .remove         = etb_remove,
        .id_table       = etb_ids,
 };
 
index d630b7ece73521ccf8cd7b320ebd75ecc92eb1d3..5981fcc699601af4ee6914b6687e38d0cb118e43 100644 (file)
@@ -1877,17 +1877,6 @@ err_arch_supported:
        return ret;
 }
 
-static int etm_remove(struct amba_device *adev)
-{
-       struct etm_drvdata *drvdata = amba_get_drvdata(adev);
-
-       coresight_unregister(drvdata->csdev);
-       if (--etm_count == 0)
-               unregister_hotcpu_notifier(&etm_cpu_notifier);
-
-       return 0;
-}
-
 #ifdef CONFIG_PM
 static int etm_runtime_suspend(struct device *dev)
 {
@@ -1948,9 +1937,9 @@ static struct amba_driver etm_driver = {
                .name   = "coresight-etm3x",
                .owner  = THIS_MODULE,
                .pm     = &etm_dev_pm_ops,
+               .suppress_bind_attrs = true,
        },
        .probe          = etm_probe,
-       .remove         = etm_remove,
        .id_table       = etm_ids,
 };
 
index 1ec6798b21e8759f21faa7046ec52c5cbda4c9b4..0edc10b440044057285170758352073ccb57ce8e 100644 (file)
@@ -2684,17 +2684,6 @@ err_coresight_register:
        return ret;
 }
 
-static int etm4_remove(struct amba_device *adev)
-{
-       struct etmv4_drvdata *drvdata = amba_get_drvdata(adev);
-
-       coresight_unregister(drvdata->csdev);
-       if (--etm4_count == 0)
-               unregister_hotcpu_notifier(&etm4_cpu_notifier);
-
-       return 0;
-}
-
 static struct amba_id etm4_ids[] = {
        {       /* ETM 4.0 - Qualcomm */
                .id     = 0x0003b95d,
@@ -2712,9 +2701,9 @@ static struct amba_id etm4_ids[] = {
 static struct amba_driver etm4x_driver = {
        .drv = {
                .name   = "coresight-etm4x",
+               .suppress_bind_attrs = true,
        },
        .probe          = etm4_probe,
-       .remove         = etm4_remove,
        .id_table       = etm4_ids,
 };
 
index 2e36bde7fcb41bbfe3972502be5d1d11aa4c49a5..25e8ea140a099f9a9de706b95fa4c8f1b2b28a63 100644 (file)
@@ -226,14 +226,6 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id)
        return 0;
 }
 
-static int funnel_remove(struct amba_device *adev)
-{
-       struct funnel_drvdata *drvdata = amba_get_drvdata(adev);
-
-       coresight_unregister(drvdata->csdev);
-       return 0;
-}
-
 #ifdef CONFIG_PM
 static int funnel_runtime_suspend(struct device *dev)
 {
@@ -273,9 +265,9 @@ static struct amba_driver funnel_driver = {
                .name   = "coresight-funnel",
                .owner  = THIS_MODULE,
                .pm     = &funnel_dev_pm_ops,
+               .suppress_bind_attrs = true,
        },
        .probe          = funnel_probe,
-       .remove         = funnel_remove,
        .id_table       = funnel_ids,
 };
 
index 584059e9e8660f228f785cb87b9200e3b315d675..4448151794605d849ff0fc344a8af07734b76fec 100644 (file)
@@ -156,15 +156,6 @@ static int replicator_probe(struct amba_device *adev, const struct amba_id *id)
        return 0;
 }
 
-static int replicator_remove(struct amba_device *adev)
-{
-       struct replicator_state *drvdata = amba_get_drvdata(adev);
-
-       pm_runtime_disable(&adev->dev);
-       coresight_unregister(drvdata->csdev);
-       return 0;
-}
-
 #ifdef CONFIG_PM
 static int replicator_runtime_suspend(struct device *dev)
 {
@@ -206,9 +197,9 @@ static struct amba_driver replicator_driver = {
        .drv = {
                .name   = "coresight-replicator-qcom",
                .pm     = &replicator_dev_pm_ops,
+               .suppress_bind_attrs = true,
        },
        .probe          = replicator_probe,
-       .remove         = replicator_remove,
        .id_table       = replicator_ids,
 };
 
index 963ac197c2535caf202960af34490e6abd02d4cb..b77d700a3f0e04b66e2276661e9d9a8831e1ea6f 100644 (file)
@@ -127,20 +127,6 @@ out_disable_pm:
        return ret;
 }
 
-static int replicator_remove(struct platform_device *pdev)
-{
-       struct replicator_drvdata *drvdata = platform_get_drvdata(pdev);
-
-       coresight_unregister(drvdata->csdev);
-       pm_runtime_get_sync(&pdev->dev);
-       if (!IS_ERR(drvdata->atclk))
-               clk_disable_unprepare(drvdata->atclk);
-       pm_runtime_put_noidle(&pdev->dev);
-       pm_runtime_disable(&pdev->dev);
-
-       return 0;
-}
-
 #ifdef CONFIG_PM
 static int replicator_runtime_suspend(struct device *dev)
 {
@@ -175,11 +161,11 @@ static const struct of_device_id replicator_match[] = {
 
 static struct platform_driver replicator_driver = {
        .probe          = replicator_probe,
-       .remove         = replicator_remove,
        .driver         = {
                .name   = "coresight-replicator",
                .of_match_table = replicator_match,
                .pm     = &replicator_dev_pm_ops,
+               .suppress_bind_attrs = true,
        },
 };
 
index 62f9d7372e3a55221c288138137242eff344492d..c4fa70ed14cedabbdab3e9da0d704914aac6ddf7 100644 (file)
@@ -770,19 +770,6 @@ err_devm_kzalloc:
        return ret;
 }
 
-static int tmc_remove(struct amba_device *adev)
-{
-       struct tmc_drvdata *drvdata = amba_get_drvdata(adev);
-
-       misc_deregister(&drvdata->miscdev);
-       coresight_unregister(drvdata->csdev);
-       if (drvdata->config_type == TMC_CONFIG_TYPE_ETR)
-               dma_free_coherent(drvdata->dev, drvdata->size,
-                                 &drvdata->paddr, GFP_KERNEL);
-
-       return 0;
-}
-
 static struct amba_id tmc_ids[] = {
        {
                .id     = 0x0003b961,
@@ -795,9 +782,9 @@ static struct amba_driver tmc_driver = {
        .drv = {
                .name   = "coresight-tmc",
                .owner  = THIS_MODULE,
+               .suppress_bind_attrs = true,
        },
        .probe          = tmc_probe,
-       .remove         = tmc_remove,
        .id_table       = tmc_ids,
 };
 
index fe3a2b19a5dbf39ca6af7cf1eee60ce2fd12a67c..105c192eb2c10402e71dc1b783b2c79e5ad74436 100644 (file)
@@ -180,14 +180,6 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
        return 0;
 }
 
-static int tpiu_remove(struct amba_device *adev)
-{
-       struct tpiu_drvdata *drvdata = amba_get_drvdata(adev);
-
-       coresight_unregister(drvdata->csdev);
-       return 0;
-}
-
 #ifdef CONFIG_PM
 static int tpiu_runtime_suspend(struct device *dev)
 {
@@ -231,9 +223,9 @@ static struct amba_driver tpiu_driver = {
                .name   = "coresight-tpiu",
                .owner  = THIS_MODULE,
                .pm     = &tpiu_dev_pm_ops,
+               .suppress_bind_attrs = true,
        },
        .probe          = tpiu_probe,
-       .remove         = tpiu_remove,
        .id_table       = tpiu_ids,
 };