Signed-off-by: Jie Gan <quic_jiegan@xxxxxxxxxxx>
---
drivers/hwtracing/coresight/coresight-core.c | 59 +++++++++++++++----
drivers/hwtracing/coresight/coresight-etb10.c | 3 +-
.../hwtracing/coresight/coresight-etm-perf.c | 37 ++++++++++--
.../coresight/coresight-etm3x-core.c | 30 ++++++++++
.../coresight/coresight-etm4x-core.c | 29 +++++++++
drivers/hwtracing/coresight/coresight-priv.h | 13 +++-
drivers/hwtracing/coresight/coresight-stm.c | 22 +++++++
drivers/hwtracing/coresight/coresight-sysfs.c | 24 +++++++-
.../hwtracing/coresight/coresight-tmc-etf.c | 3 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 6 +-
drivers/hwtracing/coresight/coresight-tpda.c | 20 +++++++
drivers/hwtracing/coresight/coresight-trbe.c | 4 +-
drivers/hwtracing/coresight/ultrasoc-smb.c | 3 +-
include/linux/coresight.h | 6 ++
14 files changed, 234 insertions(+), 25 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/
hwtracing/coresight/coresight-core.c
index 0a9380350fb5..2e560b425fd4 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -23,6 +23,7 @@
#include "coresight-etm-perf.h"
#include "coresight-priv.h"
#include "coresight-syscfg.h"
+#include "coresight-trace-id.h"
/*
* Mutex used to lock all sysfs enable and disable actions and
loading and
@@ -331,12 +332,12 @@ static int coresight_enable_helper(struct
coresight_device *csdev,
return helper_ops(csdev)->enable(csdev, mode, data);
}
-static void coresight_disable_helper(struct coresight_device *csdev)
+static void coresight_disable_helper(struct coresight_device *csdev,
void *data)
{
- helper_ops(csdev)->disable(csdev, NULL);
+ helper_ops(csdev)->disable(csdev, data);
}
-static void coresight_disable_helpers(struct coresight_device *csdev)
+static void coresight_disable_helpers(struct coresight_device
*csdev, void *data)
{
int i;
struct coresight_device *helper;
@@ -344,7 +345,7 @@ static void coresight_disable_helpers(struct
coresight_device *csdev)
for (i = 0; i < csdev->pdata->nr_outconns; ++i) {
helper = csdev->pdata->out_conns[i]->dest_dev;
if (helper && coresight_is_helper(helper))
- coresight_disable_helper(helper);
+ coresight_disable_helper(helper, data);
}
}
@@ -361,7 +362,7 @@ static void coresight_disable_helpers(struct
coresight_device *csdev)
void coresight_disable_source(struct coresight_device *csdev, void
*data)
{
source_ops(csdev)->disable(csdev, data);
- coresight_disable_helpers(csdev);
+ coresight_disable_helpers(csdev, NULL);
}
EXPORT_SYMBOL_GPL(coresight_disable_source);
@@ -371,7 +372,8 @@ EXPORT_SYMBOL_GPL(coresight_disable_source);
* disabled.
*/
static void coresight_disable_path_from(struct list_head *path,
- struct coresight_node *nd)
+ struct coresight_node *nd,
+ void *sink_data)
{
u32 type;
struct coresight_device *csdev, *parent, *child;
@@ -417,13 +419,13 @@ static void coresight_disable_path_from(struct
list_head *path,
}
/* Disable all helpers adjacent along the path last */
- coresight_disable_helpers(csdev);
+ coresight_disable_helpers(csdev, sink_data);
}
}
-void coresight_disable_path(struct list_head *path)
+void coresight_disable_path(struct list_head *path, void *sink_data)
{
- coresight_disable_path_from(path, NULL);
+ coresight_disable_path_from(path, NULL, sink_data);
}
EXPORT_SYMBOL_GPL(coresight_disable_path);
@@ -505,10 +507,47 @@ int coresight_enable_path(struct list_head
*path, enum cs_mode mode,
out:
return ret;
err:
- coresight_disable_path_from(path, nd);
+ coresight_disable_path_from(path, nd, sink_data);
goto out;
}
+int coresight_read_traceid(struct list_head *path, enum cs_mode mode,
+ struct coresight_trace_id_map *id_map)
+{
+ int trace_id, type;
+ struct coresight_device *csdev;
+ struct coresight_node *nd;
+
+ list_for_each_entry(nd, path, link) {
+ csdev = nd->csdev;
+ type = csdev->type;
+
+ switch (type) {
+ case CORESIGHT_DEV_TYPE_SOURCE:
+ if (source_ops(csdev)->trace_id != NULL) {
+ trace_id = source_ops(csdev)->trace_id(csdev,
+ mode,
+ id_map);
+ if (IS_VALID_CS_TRACE_ID(trace_id))
+ goto out;
+ }
+ break;
+ case CORESIGHT_DEV_TYPE_LINK:
+ if (link_ops(csdev)->trace_id != NULL) {
+ trace_id = link_ops(csdev)->trace_id(csdev);
+ if (IS_VALID_CS_TRACE_ID(trace_id))
+ goto out;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return -EINVAL;
+out:
+ return trace_id;
+}
+
struct coresight_device *coresight_get_sink(struct list_head *path)
{
struct coresight_device *csdev;
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/
hwtracing/coresight/coresight-etb10.c
index aea9ac9c4bd0..904b5531c256 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -173,7 +173,8 @@ static int etb_enable_perf(struct
coresight_device *csdev, void *data)
pid_t pid;
unsigned long flags;
struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
- struct perf_output_handle *handle = data;
+ struct cs_sink_data *sink_data = (struct cs_sink_data *)data;
+ struct perf_output_handle *handle = sink_data->handle;
struct cs_buffers *buf = etm_perf_sink_config(handle);
spin_lock_irqsave(&drvdata->spinlock, flags);
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/
drivers/hwtracing/coresight/coresight-etm-perf.c
index ad6a8f4b70b6..e676edd42ddc 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -459,6 +459,7 @@ static void etm_event_start(struct perf_event
*event, int flags)
struct perf_output_handle *handle = &ctxt->handle;
struct coresight_device *sink, *csdev = per_cpu(csdev_src, cpu);
struct list_head *path;
+ struct cs_sink_data *sink_data = NULL;
u64 hw_id;
u8 trace_id;
@@ -498,9 +499,20 @@ static void etm_event_start(struct perf_event
*event, int flags)
if (WARN_ON_ONCE(!sink))
goto fail_end_stop;
+ sink_data = kzalloc(sizeof(*sink_data), GFP_KERNEL);