Skip to content

Commit d5f7e4b

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: tmc: Re-enable sink after buffer update
The buffer update callbacks disable the sink before syncing data but misses to re-enable it afterward. This is fine in the general flow, because the sink will be re-enabled the next time the PMU event is activated. However, during AUX pause and resume, if the sink is disabled in the buffer update callback, there is no chance to re-enable it when AUX resumes. To address this, the callbacks now check the event state 'event->hw.state'. If the event is an active state (0), the sink is re-enabled. For the TMC ETR driver, buffer updates are not fully protected by the driver's spinlock. In this case, the sink is not re-enabled if its reference counter is 0, in order to avoid race conditions where the sink may have been completely disabled. Signed-off-by: Leo Yan <[email protected]> Reviewed-by: Mike Leach <[email protected]> Reviewed-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent abffe22 commit d5f7e4b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/hwtracing/coresight/coresight-tmc-etf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,
482482
unsigned long offset, to_read = 0, flags;
483483
struct cs_buffers *buf = sink_config;
484484
struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
485+
struct perf_event *event = handle->event;
485486

486487
if (!buf)
487488
return 0;
@@ -586,6 +587,14 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,
586587
* is expected by the perf ring buffer.
587588
*/
588589
CS_LOCK(drvdata->base);
590+
591+
/*
592+
* If the event is active, it is triggered during an AUX pause.
593+
* Re-enable the sink so that it is ready when AUX resume is invoked.
594+
*/
595+
if (!event->hw.state)
596+
__tmc_etb_enable_hw(drvdata);
597+
589598
out:
590599
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
591600

drivers/hwtracing/coresight/coresight-tmc-etr.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,7 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
16341634
struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
16351635
struct etr_perf_buffer *etr_perf = config;
16361636
struct etr_buf *etr_buf = etr_perf->etr_buf;
1637+
struct perf_event *event = handle->event;
16371638

16381639
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
16391640

@@ -1703,6 +1704,15 @@ tmc_update_etr_buffer(struct coresight_device *csdev,
17031704
*/
17041705
smp_wmb();
17051706

1707+
/*
1708+
* If the event is active, it is triggered during an AUX pause.
1709+
* Re-enable the sink so that it is ready when AUX resume is invoked.
1710+
*/
1711+
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
1712+
if (csdev->refcnt && !event->hw.state)
1713+
__tmc_etr_enable_hw(drvdata);
1714+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
1715+
17061716
out:
17071717
/*
17081718
* Don't set the TRUNCATED flag in snapshot mode because 1) the

0 commit comments

Comments
 (0)