Hi Mike
On 16/01/2023 12:49, Mike Leach wrote:
The existing mechanism to assign Trace ID values to sources is limited and does not scale for larger multicore / multi trace source systems.
The API introduces functions that reserve IDs based on availabilty represented by a coresight_trace_id_map structure. This records the used and free IDs in a bitmap.
CPU bound sources such as ETMs use the coresight_trace_id_get_cpu_id coresight_trace_id_put_cpu_id pair of functions. The API will record the ID associated with the CPU. This ensures that the same ID will be re-used while perf events are active on the CPU. The put_cpu_id function will pend release of the ID until all perf cs_etm sessions are complete.
For backward compatibility the functions will attempt to use the same CPU IDs as the legacy system would have used if these are still available.
Non-cpu sources, such as the STM can use coresight_trace_id_get_system_id / coresight_trace_id_put_system_id.
Signed-off-by: Mike Leach mike.leach@linaro.org
drivers/hwtracing/coresight/Makefile | 2 +- .../hwtracing/coresight/coresight-trace-id.c | 265 ++++++++++++++++++ .../hwtracing/coresight/coresight-trace-id.h | 156 +++++++++++ include/linux/coresight-pmu.h | 10 + 4 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 drivers/hwtracing/coresight/coresight-trace-id.c create mode 100644 drivers/hwtracing/coresight/coresight-trace-id.h
diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index b6c4a48140ec..329a0c704b87 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -6,7 +6,7 @@ obj-$(CONFIG_CORESIGHT) += coresight.o coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \ coresight-sysfs.o coresight-syscfg.o coresight-config.o \ coresight-cfg-preload.o coresight-cfg-afdo.o \
coresight-syscfg-configfs.o
obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \ coresight-tmc-etr.ocoresight-syscfg-configfs.o coresight-trace-id.o
diff --git a/drivers/hwtracing/coresight/coresight-trace-id.c b/drivers/hwtracing/coresight/coresight-trace-id.c new file mode 100644 index 000000000000..9b85c376cb12 --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-trace-id.c @@ -0,0 +1,265 @@ +// SPDX-License-Identifier: GPL-2.0
...
+int coresight_trace_id_read_cpu_id(int cpu) +{
- return _coresight_trace_id_read_cpu_id(cpu);
+} +EXPORT_SYMBOL_GPL(coresight_trace_id_read_cpu_id);
+int coresight_trace_id_get_system_id(void) +{
- return coresight_trace_id_map_get_system_id(&id_map_default);
+} +EXPORT_SYMBOL_GPL(coresight_trace_id_get_system_id);
+void coresight_trace_id_put_system_id(int id) +{
- coresight_trace_id_map_put_system_id(&id_map_default, id);
+} +EXPORT_SYMBOL_GPL(coresight_trace_id_put_system_id);
+void coresight_trace_id_perf_start(void) +{
- atomic_inc(&perf_cs_etm_session_active);
+} +EXPORT_SYMBOL_GPL(coresight_trace_id_perf_start);
+void coresight_trace_id_perf_stop(void) +{
- if (!atomic_dec_return(&perf_cs_etm_session_active))
coresight_trace_id_release_all_pending();
+} +EXPORT_SYMBOL_GPL(coresight_trace_id_perf_stop);
This blank new line at the end of the file generates a checkpatch warning for me. I have fixed it locally and applied it.
diff --git a/drivers/hwtracing/coresight/coresight-trace-id.h b/drivers/hwtracing/coresight/coresight-trace-id.h