History

coresight: Adding return code to sink::disable() operation

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.

Mathieu Poirier committed 7 years ago

Commit 6c817a91 parent a54e14f6 files · +16 −8Browse files

Unified · Split

6 files
  1. drivers/hwtracing/coresight/coresight-etb10.c +2 −1
  2. drivers/hwtracing/coresight/coresight-tmc-etf.c +3 −2
  3. drivers/hwtracing/coresight/coresight-tmc-etr.c +3 −2
  4. drivers/hwtracing/coresight/coresight-tpiu.c +2 −1
  5. drivers/hwtracing/coresight/coresight.c +5 −1
  6. include/linux/coresight.h +1 −1
drivers/hwtracing/coresight/coresight-etb10.c+2−1
@@ -317,7 +317,7 @@ static void etb_disable_hw(struct etb_drvdata *drvdata) · 316 unmodified lines
317317 coresight_disclaim_device(drvdata->base);
318318 }
319319
320−static void etb_disable(struct coresight_device *csdev)
320+static int etb_disable(struct coresight_device *csdev)
321321 {
322322 struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
323323 unsigned long flags;
@@ -332,6 +332,7 @@ static void etb_disable(struct coresight_device *csdev) · 8 unmodified lines
332332 spin_unlock_irqrestore(&drvdata->spinlock, flags);
333333
334334 dev_dbg(drvdata->dev, "ETB disabled\n");
335+ return 0;
335336 }
336337
337338 static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu,
drivers/hwtracing/coresight/coresight-tmc-etf.c+3−2
@@ -273,7 +273,7 @@ static int tmc_enable_etf_sink(struct coresight_device *csdev, · 272 unmodified lines
273273 return 0;
274274 }
275275
276−static void tmc_disable_etf_sink(struct coresight_device *csdev)
276+static int tmc_disable_etf_sink(struct coresight_device *csdev)
277277 {
278278 unsigned long flags;
279279 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
@@ -281,7 +281,7 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev) · 1 unmodified line
281281 spin_lock_irqsave(&drvdata->spinlock, flags);
282282 if (drvdata->reading) {
283283 spin_unlock_irqrestore(&drvdata->spinlock, flags);
284− return;
284+ return -EBUSY;
285285 }
286286
287287 /* Disable the TMC only if it needs to */
@@ -293,6 +293,7 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev) · 5 unmodified lines
293293 spin_unlock_irqrestore(&drvdata->spinlock, flags);
294294
295295 dev_dbg(drvdata->dev, "TMC-ETB/ETF disabled\n");
296+ return 0;
296297 }
297298
298299 static int tmc_enable_etf_link(struct coresight_device *csdev,
drivers/hwtracing/coresight/coresight-tmc-etr.c+3−2
@@ -1393,7 +1393,7 @@ static int tmc_enable_etr_sink(struct coresight_device *csdev, · 1392 unmodified lines
13931393 return -EINVAL;
13941394 }
13951395
1396−static void tmc_disable_etr_sink(struct coresight_device *csdev)
1396+static int tmc_disable_etr_sink(struct coresight_device *csdev)
13971397 {
13981398 unsigned long flags;
13991399 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
@@ -1401,7 +1401,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev) · 1 unmodified line
14011401 spin_lock_irqsave(&drvdata->spinlock, flags);
14021402 if (drvdata->reading) {
14031403 spin_unlock_irqrestore(&drvdata->spinlock, flags);
1404− return;
1404+ return -EBUSY;
14051405 }
14061406
14071407 /* Disable the TMC only if it needs to */
@@ -1413,6 +1413,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev) · 5 unmodified lines
14131413 spin_unlock_irqrestore(&drvdata->spinlock, flags);
14141414
14151415 dev_dbg(drvdata->dev, "TMC-ETR disabled\n");
1416+ return 0;
14161417 }
14171418
14181419 static const struct coresight_ops_sink tmc_etr_sink_ops = {
drivers/hwtracing/coresight/coresight-tpiu.c+2−1
@@ -94,13 +94,14 @@ static void tpiu_disable_hw(struct tpiu_drvdata *drvdata) · 93 unmodified lines
9494 CS_LOCK(drvdata->base);
9595 }
9696
97−static void tpiu_disable(struct coresight_device *csdev)
97+static int tpiu_disable(struct coresight_device *csdev)
9898 {
9999 struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
100100
101101 tpiu_disable_hw(drvdata);
102102
103103 dev_dbg(drvdata->dev, "TPIU disabled\n");
104+ return 0;
104105 }
105106
106107 static const struct coresight_ops_sink tpiu_sink_ops = {
drivers/hwtracing/coresight/coresight.c+5−1
@@ -239,9 +239,13 @@ static int coresight_enable_sink(struct coresight_device *csdev, · 238 unmodified lines
239239
240240 static void coresight_disable_sink(struct coresight_device *csdev)
241241 {
242+ int ret;
243+
242244 if (atomic_dec_return(csdev->refcnt) == 0) {
243245 if (sink_ops(csdev)->disable) {
244− sink_ops(csdev)->disable(csdev);
246+ ret = sink_ops(csdev)->disable(csdev);
247+ if (ret)
248+ return;
245249 csdev->enable = false;
246250 }
247251 }
include/linux/coresight.h+1−1
@@ -192,7 +192,7 @@ struct coresight_device { · 191 unmodified lines
192192 */
193193 struct coresight_ops_sink {
194194 int (*enable)(struct coresight_device *csdev, u32 mode, void *data);
195− void (*disable)(struct coresight_device *csdev);
195+ int (*disable)(struct coresight_device *csdev);
196196 void *(*alloc_buffer)(struct coresight_device *csdev, int cpu,
197197 void **pages, int nr_pages, bool overwrite);
198198 void (*free_buffer)(void *config);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t