... | ... | ||
---|---|---|---|
5 | 5 | ||
6 | Patches 02 and 03 change the ETMv4 driver to prepare callback functions | 6 | Patches 02 and 03 change the ETMv4 driver to prepare callback functions |
7 | for AUX pause and resume. | 7 | for AUX pause and resume. |
8 | 8 | ||
9 | Patch 04 changes the ETM perf layer to support AUX pause and resume in a | 9 | Patch 04 changes the ETM perf layer to support AUX pause and resume in a |
10 | perf session. The patches 05 updates buffer on AUX pause occasion, | 10 | perf session. The patch 05 re-enables sinks after buffer update, based |
11 | which can mitigate the trace data lose issue. | 11 | on it, the patch 06 updates buffer on AUX pause occasion, which can |
12 | mitigate the trace data lose issue. | ||
12 | 13 | ||
13 | Patch 07 documents the AUX pause usages with Arm CoreSight. | 14 | Patch 07 documents the AUX pause usages with Arm CoreSight. |
14 | 15 | ||
15 | This patch set has been verified on the Hikey960 board and TC platform. | 16 | This patch set has been verified on the Hikey960 board. |
16 | The previous one uses ETR and the later uses TRBE as sink. | ||
17 | 17 | ||
18 | It is suggested to disable CPUIdle (add `nohlt` option in Linux command | 18 | It is suggested to disable CPUIdle (add `nohlt` option in Linux command |
19 | line) when verifying this series. ETM and funnel drivers are found | 19 | line) when verifying this series. ETM and funnel drivers are found |
20 | issues during CPU suspend and resume which will be addressed separately. | 20 | issues during CPU suspend and resume which will be addressed separately. |
21 | |||
22 | Changes from v3: | ||
23 | - Re-enabled sink in buffer update callbacks (Suzuki). | ||
21 | 24 | ||
22 | Changes from v2: | 25 | Changes from v2: |
23 | - Rebased on CoreSight next branch. | 26 | - Rebased on CoreSight next branch. |
24 | - Dropped the uAPI 'update_buf_on_pause' and updated document | 27 | - Dropped the uAPI 'update_buf_on_pause' and updated document |
25 | respectively (Suzuki). | 28 | respectively (Suzuki). |
... | ... | ||
28 | 31 | ||
29 | Changes from v1: | 32 | Changes from v1: |
30 | - Added validation function pointers in pause and resume APIs (Mike). | 33 | - Added validation function pointers in pause and resume APIs (Mike). |
31 | 34 | ||
32 | 35 | ||
33 | Leo Yan (6): | 36 | Leo Yan (7): |
34 | coresight: etm4x: Extract the trace unit controlling | 37 | coresight: etm4x: Extract the trace unit controlling |
35 | coresight: Introduce pause and resume APIs for source | 38 | coresight: Introduce pause and resume APIs for source |
36 | coresight: etm4x: Hook pause and resume callbacks | 39 | coresight: etm4x: Hook pause and resume callbacks |
37 | coresight: perf: Support AUX trace pause and resume | 40 | coresight: perf: Support AUX trace pause and resume |
41 | coresight: tmc: Re-enable sink after buffer update | ||
38 | coresight: perf: Update buffer on AUX pause | 42 | coresight: perf: Update buffer on AUX pause |
39 | Documentation: coresight: Document AUX pause and resume | 43 | Documentation: coresight: Document AUX pause and resume |
40 | 44 | ||
41 | .../trace/coresight/coresight-perf.rst | 31 ++++ | 45 | Documentation/trace/coresight/coresight-perf.rst | 31 +++++++++ |
42 | drivers/hwtracing/coresight/coresight-core.c | 22 +++ | 46 | drivers/hwtracing/coresight/coresight-core.c | 22 +++++++ |
43 | .../hwtracing/coresight/coresight-etm-perf.c | 84 +++++++++- | 47 | drivers/hwtracing/coresight/coresight-etm-perf.c | 84 +++++++++++++++++++++++- |
44 | .../coresight/coresight-etm4x-core.c | 143 +++++++++++++----- | 48 | drivers/hwtracing/coresight/coresight-etm4x-core.c | 143 +++++++++++++++++++++++++++++------------ |
45 | drivers/hwtracing/coresight/coresight-etm4x.h | 2 + | 49 | drivers/hwtracing/coresight/coresight-etm4x.h | 2 + |
46 | drivers/hwtracing/coresight/coresight-priv.h | 2 + | 50 | drivers/hwtracing/coresight/coresight-priv.h | 2 + |
47 | include/linux/coresight.h | 4 + | 51 | drivers/hwtracing/coresight/coresight-tmc-etf.c | 9 +++ |
48 | 7 files changed, 246 insertions(+), 42 deletions(-) | 52 | drivers/hwtracing/coresight/coresight-tmc-etr.c | 10 +++ |
53 | include/linux/coresight.h | 4 ++ | ||
54 | 9 files changed, 265 insertions(+), 42 deletions(-) | ||
49 | 55 | ||
50 | -- | 56 | -- |
51 | 2.34.1 | 57 | 2.34.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
5 | Extract the operations in the etm4_{enable|disable}_trace_unit() | 5 | Extract the operations in the etm4_{enable|disable}_trace_unit() |
6 | functions. A minor improvement in etm4_enable_trace_unit() is for | 6 | functions. A minor improvement in etm4_enable_trace_unit() is for |
7 | returning the timeout error to callers. | 7 | returning the timeout error to callers. |
8 | 8 | ||
9 | Signed-off-by: Leo Yan <leo.yan@arm.com> | 9 | Signed-off-by: Leo Yan <leo.yan@arm.com> |
10 | Reviewed-by: Mike Leach <mike.leach@linaro.org> | ||
10 | --- | 11 | --- |
11 | .../coresight/coresight-etm4x-core.c | 103 +++++++++++------- | 12 | drivers/hwtracing/coresight/coresight-etm4x-core.c | 103 +++++++++++++++++++++++++---------------- |
12 | 1 file changed, 62 insertions(+), 41 deletions(-) | 13 | 1 file changed, 62 insertions(+), 41 deletions(-) |
13 | 14 | ||
14 | diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c | 15 | diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c | 17 | --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c |
... | ... | diff view generated by jsdifflib |
1 | Introduce APIs for pausing and resuming trace source and export as GPL | 1 | Introduce APIs for pausing and resuming trace source and export as GPL |
---|---|---|---|
2 | symbols. | 2 | symbols. |
3 | 3 | ||
4 | Signed-off-by: Leo Yan <leo.yan@arm.com> | 4 | Signed-off-by: Leo Yan <leo.yan@arm.com> |
5 | Reviewed-by: Mike Leach <mike.leach@linaro.org> | ||
5 | --- | 6 | --- |
6 | drivers/hwtracing/coresight/coresight-core.c | 22 ++++++++++++++++++++ | 7 | drivers/hwtracing/coresight/coresight-core.c | 22 ++++++++++++++++++++++ |
7 | drivers/hwtracing/coresight/coresight-priv.h | 2 ++ | 8 | drivers/hwtracing/coresight/coresight-priv.h | 2 ++ |
8 | include/linux/coresight.h | 4 ++++ | 9 | include/linux/coresight.h | 4 ++++ |
9 | 3 files changed, 28 insertions(+) | 10 | 3 files changed, 28 insertions(+) |
10 | 11 | ||
11 | diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c | 12 | diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c |
... | ... | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
4 | paused. If the flag is set, the driver will skip starting the hardware | 4 | paused. If the flag is set, the driver will skip starting the hardware |
5 | trace. The flag is always set to false for the sysfs mode, meaning the | 5 | trace. The flag is always set to false for the sysfs mode, meaning the |
6 | tracer will never be paused in the case. | 6 | tracer will never be paused in the case. |
7 | 7 | ||
8 | Signed-off-by: Leo Yan <leo.yan@arm.com> | 8 | Signed-off-by: Leo Yan <leo.yan@arm.com> |
9 | Reviewed-by: Mike Leach <mike.leach@linaro.org> | ||
9 | --- | 10 | --- |
10 | .../coresight/coresight-etm4x-core.c | 42 ++++++++++++++++++- | 11 | drivers/hwtracing/coresight/coresight-etm4x-core.c | 42 +++++++++++++++++++++++++++++++++++++++++- |
11 | drivers/hwtracing/coresight/coresight-etm4x.h | 2 + | 12 | drivers/hwtracing/coresight/coresight-etm4x.h | 2 ++ |
12 | 2 files changed, 43 insertions(+), 1 deletion(-) | 13 | 2 files changed, 43 insertions(+), 1 deletion(-) |
13 | 14 | ||
14 | diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c | 15 | diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c | 17 | --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c |
... | ... | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
14 | To achieve fine-grained control of the pause and resume, only the tracer | 14 | To achieve fine-grained control of the pause and resume, only the tracer |
15 | is disabled and enabled. This avoids the unnecessary complexity and | 15 | is disabled and enabled. This avoids the unnecessary complexity and |
16 | latency caused by manipulating the entire link path. | 16 | latency caused by manipulating the entire link path. |
17 | 17 | ||
18 | Signed-off-by: Leo Yan <leo.yan@arm.com> | 18 | Signed-off-by: Leo Yan <leo.yan@arm.com> |
19 | Reviewed-by: Mike Leach <mike.leach@linaro.org> | ||
19 | --- | 20 | --- |
20 | .../hwtracing/coresight/coresight-etm-perf.c | 45 ++++++++++++++++++- | 21 | drivers/hwtracing/coresight/coresight-etm-perf.c | 45 +++++++++++++++++++++++++++++++++++++++++++- |
21 | 1 file changed, 44 insertions(+), 1 deletion(-) | 22 | 1 file changed, 44 insertions(+), 1 deletion(-) |
22 | 23 | ||
23 | diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c | 24 | diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c |
24 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/drivers/hwtracing/coresight/coresight-etm-perf.c | 26 | --- a/drivers/hwtracing/coresight/coresight-etm-perf.c |
... | ... | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The buffer update callbacks disable the sink before syncing data but | ||
2 | misses to re-enable it afterward. This is fine in the general flow, | ||
3 | because the sink will be re-enabled the next time the PMU event is | ||
4 | activated. | ||
1 | 5 | ||
6 | However, during AUX pause and resume, if the sink is disabled in the | ||
7 | buffer update callback, there is no chance to re-enable it when AUX | ||
8 | resumes. | ||
9 | |||
10 | To address this, the callbacks now check the event state | ||
11 | 'event->hw.state'. If the event is an active state (0), the sink is | ||
12 | re-enabled. | ||
13 | |||
14 | For the TMC ETR driver, buffer updates are not fully protected by | ||
15 | the driver's spinlock. In this case, the sink is not re-enabled if its | ||
16 | reference counter is 0, in order to avoid race conditions where the sink | ||
17 | may have been completely disabled. | ||
18 | |||
19 | Signed-off-by: Leo Yan <leo.yan@arm.com> | ||
20 | --- | ||
21 | drivers/hwtracing/coresight/coresight-tmc-etf.c | 9 +++++++++ | ||
22 | drivers/hwtracing/coresight/coresight-tmc-etr.c | 10 ++++++++++ | ||
23 | 2 files changed, 19 insertions(+) | ||
24 | |||
25 | diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c | ||
28 | +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, | ||
30 | unsigned long offset, to_read = 0, flags; | ||
31 | struct cs_buffers *buf = sink_config; | ||
32 | struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); | ||
33 | + struct perf_event *event = handle->event; | ||
34 | |||
35 | if (!buf) | ||
36 | return 0; | ||
37 | @@ -XXX,XX +XXX,XX @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, | ||
38 | * is expected by the perf ring buffer. | ||
39 | */ | ||
40 | CS_LOCK(drvdata->base); | ||
41 | + | ||
42 | + /* | ||
43 | + * If the event is active, it is triggered during an AUX pause. | ||
44 | + * Re-enable the sink so that it is ready when AUX resume is invoked. | ||
45 | + */ | ||
46 | + if (!event->hw.state) | ||
47 | + __tmc_etb_enable_hw(drvdata); | ||
48 | + | ||
49 | out: | ||
50 | raw_spin_unlock_irqrestore(&drvdata->spinlock, flags); | ||
51 | |||
52 | diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c | ||
55 | +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c | ||
56 | @@ -XXX,XX +XXX,XX @@ tmc_update_etr_buffer(struct coresight_device *csdev, | ||
57 | struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); | ||
58 | struct etr_perf_buffer *etr_perf = config; | ||
59 | struct etr_buf *etr_buf = etr_perf->etr_buf; | ||
60 | + struct perf_event *event = handle->event; | ||
61 | |||
62 | raw_spin_lock_irqsave(&drvdata->spinlock, flags); | ||
63 | |||
64 | @@ -XXX,XX +XXX,XX @@ tmc_update_etr_buffer(struct coresight_device *csdev, | ||
65 | */ | ||
66 | smp_wmb(); | ||
67 | |||
68 | + /* | ||
69 | + * If the event is active, it is triggered during an AUX pause. | ||
70 | + * Re-enable the sink so that it is ready when AUX resume is invoked. | ||
71 | + */ | ||
72 | + raw_spin_lock_irqsave(&drvdata->spinlock, flags); | ||
73 | + if (csdev->refcnt && !event->hw.state) | ||
74 | + __tmc_etr_enable_hw(drvdata); | ||
75 | + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags); | ||
76 | + | ||
77 | out: | ||
78 | /* | ||
79 | * Don't set the TRUNCATED flag in snapshot mode because 1) the | ||
80 | -- | ||
81 | 2.34.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
10 | buffer on AUX pause for the per CPU sink. Currently, this is only | 10 | buffer on AUX pause for the per CPU sink. Currently, this is only |
11 | applied for TRBE. | 11 | applied for TRBE. |
12 | 12 | ||
13 | Signed-off-by: Leo Yan <leo.yan@arm.com> | 13 | Signed-off-by: Leo Yan <leo.yan@arm.com> |
14 | --- | 14 | --- |
15 | .../hwtracing/coresight/coresight-etm-perf.c | 43 ++++++++++++++++++- | 15 | drivers/hwtracing/coresight/coresight-etm-perf.c | 43 +++++++++++++++++++++++++++++++++++++++++-- |
16 | 1 file changed, 41 insertions(+), 2 deletions(-) | 16 | 1 file changed, 41 insertions(+), 2 deletions(-) |
17 | 17 | ||
18 | diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c | 18 | diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c |
19 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/drivers/hwtracing/coresight/coresight-etm-perf.c | 20 | --- a/drivers/hwtracing/coresight/coresight-etm-perf.c |
... | ... | diff view generated by jsdifflib |
1 | This adds description for AUX pause and resume. It gives introduction | 1 | This adds description for AUX pause and resume. It gives introduction |
---|---|---|---|
2 | for what's AUX pause and resume and records usage examples. | 2 | for what's AUX pause and resume and records usage examples. |
3 | 3 | ||
4 | Signed-off-by: Leo Yan <leo.yan@arm.com> | 4 | Signed-off-by: Leo Yan <leo.yan@arm.com> |
5 | --- | 5 | --- |
6 | .../trace/coresight/coresight-perf.rst | 31 +++++++++++++++++++ | 6 | Documentation/trace/coresight/coresight-perf.rst | 31 +++++++++++++++++++++++++++++++ |
7 | 1 file changed, 31 insertions(+) | 7 | 1 file changed, 31 insertions(+) |
8 | 8 | ||
9 | diff --git a/Documentation/trace/coresight/coresight-perf.rst b/Documentation/trace/coresight/coresight-perf.rst | 9 | diff --git a/Documentation/trace/coresight/coresight-perf.rst b/Documentation/trace/coresight/coresight-perf.rst |
10 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
11 | --- a/Documentation/trace/coresight/coresight-perf.rst | 11 | --- a/Documentation/trace/coresight/coresight-perf.rst |
... | ... | diff view generated by jsdifflib |