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
317 coresight_disclaim_device(drvdata->base);317 coresight_disclaim_device(drvdata->base);
318}318}
319 319
320static void etb_disable(struct coresight_device *csdev)320static int etb_disable(struct coresight_device *csdev)
321{321{
322 struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);322 struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
323 unsigned long flags;323 unsigned long flags;
@@ -332,6 +332,7 @@ static void etb_disable(struct coresight_device *csdev) · 8 unmodified lines
332 spin_unlock_irqrestore(&drvdata->spinlock, flags);332 spin_unlock_irqrestore(&drvdata->spinlock, flags);
333 333
334 dev_dbg(drvdata->dev, "ETB disabled\n");334 dev_dbg(drvdata->dev, "ETB disabled\n");
335 return 0;
335}336}
336 337
337static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu,338static 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
273 return 0;273 return 0;
274}274}
275 275
276static void tmc_disable_etf_sink(struct coresight_device *csdev)276static int tmc_disable_etf_sink(struct coresight_device *csdev)
277{277{
278 unsigned long flags;278 unsigned long flags;
279 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);279 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
281 spin_lock_irqsave(&drvdata->spinlock, flags);281 spin_lock_irqsave(&drvdata->spinlock, flags);
282 if (drvdata->reading) {282 if (drvdata->reading) {
283 spin_unlock_irqrestore(&drvdata->spinlock, flags);283 spin_unlock_irqrestore(&drvdata->spinlock, flags);
284 return;284 return -EBUSY;
285 }285 }
286 286
287 /* Disable the TMC only if it needs to */287 /* 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
293 spin_unlock_irqrestore(&drvdata->spinlock, flags);293 spin_unlock_irqrestore(&drvdata->spinlock, flags);
294 294
295 dev_dbg(drvdata->dev, "TMC-ETB/ETF disabled\n");295 dev_dbg(drvdata->dev, "TMC-ETB/ETF disabled\n");
296 return 0;
296}297}
297 298
298static int tmc_enable_etf_link(struct coresight_device *csdev,299static 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
1393 return -EINVAL;1393 return -EINVAL;
1394}1394}
1395 1395
1396static void tmc_disable_etr_sink(struct coresight_device *csdev)1396static int tmc_disable_etr_sink(struct coresight_device *csdev)
1397{1397{
1398 unsigned long flags;1398 unsigned long flags;
1399 struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);1399 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
1401 spin_lock_irqsave(&drvdata->spinlock, flags);1401 spin_lock_irqsave(&drvdata->spinlock, flags);
1402 if (drvdata->reading) {1402 if (drvdata->reading) {
1403 spin_unlock_irqrestore(&drvdata->spinlock, flags);1403 spin_unlock_irqrestore(&drvdata->spinlock, flags);
1404 return;1404 return -EBUSY;
1405 }1405 }
1406 1406
1407 /* Disable the TMC only if it needs to */1407 /* 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
1413 spin_unlock_irqrestore(&drvdata->spinlock, flags);1413 spin_unlock_irqrestore(&drvdata->spinlock, flags);
1414 1414
1415 dev_dbg(drvdata->dev, "TMC-ETR disabled\n");1415 dev_dbg(drvdata->dev, "TMC-ETR disabled\n");
1416 return 0;
1416}1417}
1417 1418
1418static const struct coresight_ops_sink tmc_etr_sink_ops = {1419static 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
94 CS_LOCK(drvdata->base);94 CS_LOCK(drvdata->base);
95}95}
96 96
97static void tpiu_disable(struct coresight_device *csdev)97static int tpiu_disable(struct coresight_device *csdev)
98{98{
99 struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);99 struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
100 100
101 tpiu_disable_hw(drvdata);101 tpiu_disable_hw(drvdata);
102 102
103 dev_dbg(drvdata->dev, "TPIU disabled\n");103 dev_dbg(drvdata->dev, "TPIU disabled\n");
104 return 0;
104}105}
105 106
106static const struct coresight_ops_sink tpiu_sink_ops = {107static 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
239 239
240static void coresight_disable_sink(struct coresight_device *csdev)240static void coresight_disable_sink(struct coresight_device *csdev)
241{241{
242 int ret;
243
242 if (atomic_dec_return(csdev->refcnt) == 0) {244 if (atomic_dec_return(csdev->refcnt) == 0) {
243 if (sink_ops(csdev)->disable) {245 if (sink_ops(csdev)->disable) {
244 sink_ops(csdev)->disable(csdev);246 ret = sink_ops(csdev)->disable(csdev);
247 if (ret)
248 return;
245 csdev->enable = false;249 csdev->enable = false;
246 }250 }
247 }251 }
include/linux/coresight.h+1−1
@@ -192,7 +192,7 @@ struct coresight_device { · 191 unmodified lines
192 */192 */
193struct coresight_ops_sink {193struct coresight_ops_sink {
194 int (*enable)(struct coresight_device *csdev, u32 mode, void *data);194 int (*enable)(struct coresight_device *csdev, u32 mode, void *data);
195 void (*disable)(struct coresight_device *csdev);195 int (*disable)(struct coresight_device *csdev);
196 void *(*alloc_buffer)(struct coresight_device *csdev, int cpu,196 void *(*alloc_buffer)(struct coresight_device *csdev, int cpu,
197 void **pages, int nr_pages, bool overwrite);197 void **pages, int nr_pages, bool overwrite);
198 void (*free_buffer)(void *config);198 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