coresight: Adding return code to sink::disable() operation
authorMathieu Poirier <mathieu.poirier@linaro.org>
Thu, 25 Apr 2019 19:52:55 +0000 (13:52 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Apr 2019 20:00:16 +0000 (22:00 +0200)
In preparation to handle device reference counting inside of the sink
drivers, add a return code to the sink::disable() operation so that
proper action can be taken if a sink has not been disabled.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight-etb10.c
drivers/hwtracing/coresight/coresight-tmc-etf.c
drivers/hwtracing/coresight/coresight-tmc-etr.c
drivers/hwtracing/coresight/coresight-tpiu.c
drivers/hwtracing/coresight/coresight.c
include/linux/coresight.h

index 13c0a601d3bee1e40268fb299a99117f8fe3fe72..23b049cef19a4be3f1ceb04a70b7528b7d8f1817 100644 (file)
@@ -317,7 +317,7 @@ static void etb_disable_hw(struct etb_drvdata *drvdata)
        coresight_disclaim_device(drvdata->base);
 }
 
-static void etb_disable(struct coresight_device *csdev)
+static int etb_disable(struct coresight_device *csdev)
 {
        struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
        unsigned long flags;
@@ -332,6 +332,7 @@ static void etb_disable(struct coresight_device *csdev)
        spin_unlock_irqrestore(&drvdata->spinlock, flags);
 
        dev_dbg(drvdata->dev, "ETB disabled\n");
+       return 0;
 }
 
 static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu,
index a5f053f2db2c531c39d9b7a58b83f789d3c655b1..d4213e7c2c4535254626fe80a4665eb90fa5e134 100644 (file)
@@ -273,7 +273,7 @@ static int tmc_enable_etf_sink(struct coresight_device *csdev,
        return 0;
 }
 
-static void tmc_disable_etf_sink(struct coresight_device *csdev)
+static int tmc_disable_etf_sink(struct coresight_device *csdev)
 {
        unsigned long flags;
        struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
@@ -281,7 +281,7 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev)
        spin_lock_irqsave(&drvdata->spinlock, flags);
        if (drvdata->reading) {
                spin_unlock_irqrestore(&drvdata->spinlock, flags);
-               return;
+               return -EBUSY;
        }
 
        /* Disable the TMC only if it needs to */
@@ -293,6 +293,7 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev)
        spin_unlock_irqrestore(&drvdata->spinlock, flags);
 
        dev_dbg(drvdata->dev, "TMC-ETB/ETF disabled\n");
+       return 0;
 }
 
 static int tmc_enable_etf_link(struct coresight_device *csdev,
index cf7a32ce209d3e27f7191d01853fe85f2bf14080..c6a0f589768434765960e22d4659c19af933c8ab 100644 (file)
@@ -1393,7 +1393,7 @@ static int tmc_enable_etr_sink(struct coresight_device *csdev,
        return -EINVAL;
 }
 
-static void tmc_disable_etr_sink(struct coresight_device *csdev)
+static int tmc_disable_etr_sink(struct coresight_device *csdev)
 {
        unsigned long flags;
        struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
@@ -1401,7 +1401,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)
        spin_lock_irqsave(&drvdata->spinlock, flags);
        if (drvdata->reading) {
                spin_unlock_irqrestore(&drvdata->spinlock, flags);
-               return;
+               return -EBUSY;
        }
 
        /* Disable the TMC only if it needs to */
@@ -1413,6 +1413,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)
        spin_unlock_irqrestore(&drvdata->spinlock, flags);
 
        dev_dbg(drvdata->dev, "TMC-ETR disabled\n");
+       return 0;
 }
 
 static const struct coresight_ops_sink tmc_etr_sink_ops = {
index 93e2ef34e734f7c2618fbd54eb80fd0deed192e6..c1b77e3c3187da36782aab8592b05cd531818233 100644 (file)
@@ -94,13 +94,14 @@ static void tpiu_disable_hw(struct tpiu_drvdata *drvdata)
        CS_LOCK(drvdata->base);
 }
 
-static void tpiu_disable(struct coresight_device *csdev)
+static int tpiu_disable(struct coresight_device *csdev)
 {
        struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
 
        tpiu_disable_hw(drvdata);
 
        dev_dbg(drvdata->dev, "TPIU disabled\n");
+       return 0;
 }
 
 static const struct coresight_ops_sink tpiu_sink_ops = {
index 55204dd47479408cd20681b048ba3e07e84eb2a2..66c25b0a785ea1d250e928098f3b388e34ffced4 100644 (file)
@@ -239,9 +239,13 @@ static int coresight_enable_sink(struct coresight_device *csdev,
 
 static void coresight_disable_sink(struct coresight_device *csdev)
 {
+       int ret;
+
        if (atomic_dec_return(csdev->refcnt) == 0) {
                if (sink_ops(csdev)->disable) {
-                       sink_ops(csdev)->disable(csdev);
+                       ret = sink_ops(csdev)->disable(csdev);
+                       if (ret)
+                               return;
                        csdev->enable = false;
                }
        }
index 7b87965f7a65c90d8e98f11b14ab5b5b1f967abb..189cc6ddc92bd883842286422b241a97860fbdac 100644 (file)
@@ -192,7 +192,7 @@ struct coresight_device {
  */
 struct coresight_ops_sink {
        int (*enable)(struct coresight_device *csdev, u32 mode, void *data);
-       void (*disable)(struct coresight_device *csdev);
+       int (*disable)(struct coresight_device *csdev);
        void *(*alloc_buffer)(struct coresight_device *csdev, int cpu,
                              void **pages, int nr_pages, bool overwrite);
        void (*free_buffer)(void *config);