aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Poirier <mathieu.poirier@linaro.org>2016-02-17 19:52:02 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-20 17:11:01 -0500
commit17534ceb835a1a96eb921a2a80df168723d6570a (patch)
tree6cbfd344150ab19190bf415ef4c328ccbf9dcf3d
parent0bcbf2e30ff2271b54f54c8697a185f7d86ec6e4 (diff)
coresight: introducing a global trace ID function
TraceID values have to be unique for all tracers and consistent between drivers and user space. As such introducing a central function to be used whenever a traceID value is required. The patch also account for data traceIDs, which are usually I(N) + 1. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/hwtracing/coresight/coresight-etm3x.c7
-rw-r--r--include/linux/coresight-pmu.h12
2 files changed, 14 insertions, 5 deletions
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c
index 77b37413803f..0ba1a3981373 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x.c
@@ -27,6 +27,7 @@
27#include <linux/cpu.h> 27#include <linux/cpu.h>
28#include <linux/of.h> 28#include <linux/of.h>
29#include <linux/coresight.h> 29#include <linux/coresight.h>
30#include <linux/coresight-pmu.h>
30#include <linux/amba/bus.h> 31#include <linux/amba/bus.h>
31#include <linux/seq_file.h> 32#include <linux/seq_file.h>
32#include <linux/uaccess.h> 33#include <linux/uaccess.h>
@@ -740,11 +741,7 @@ static void etm_init_arch_data(void *info)
740 741
741static void etm_init_trace_id(struct etm_drvdata *drvdata) 742static void etm_init_trace_id(struct etm_drvdata *drvdata)
742{ 743{
743 /* 744 drvdata->traceid = coresight_get_trace_id(drvdata->cpu);
744 * A trace ID of value 0 is invalid, so let's start at some
745 * random value that fits in 7 bits and go from there.
746 */
747 drvdata->traceid = 0x10 + drvdata->cpu;
748} 745}
749 746
750static int etm_probe(struct amba_device *adev, const struct amba_id *id) 747static int etm_probe(struct amba_device *adev, const struct amba_id *id)
diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h
index 6c5386b23b10..7d410260661b 100644
--- a/include/linux/coresight-pmu.h
+++ b/include/linux/coresight-pmu.h
@@ -19,9 +19,21 @@
19#define _LINUX_CORESIGHT_PMU_H 19#define _LINUX_CORESIGHT_PMU_H
20 20
21#define CORESIGHT_ETM_PMU_NAME "cs_etm" 21#define CORESIGHT_ETM_PMU_NAME "cs_etm"
22#define CORESIGHT_ETM_PMU_SEED 0x10
22 23
23/* ETMv3.5/PTM's ETMCR config bit */ 24/* ETMv3.5/PTM's ETMCR config bit */
24#define ETM_OPT_CYCACC 12 25#define ETM_OPT_CYCACC 12
25#define ETM_OPT_TS 28 26#define ETM_OPT_TS 28
26 27
28static inline int coresight_get_trace_id(int cpu)
29{
30 /*
31 * A trace ID of value 0 is invalid, so let's start at some
32 * random value that fits in 7 bits and go from there. Since
33 * the common convention is to have data trace IDs be I(N) + 1,
34 * set instruction trace IDs as a function of the CPU number.
35 */
36 return (CORESIGHT_ETM_PMU_SEED + (cpu * 2));
37}
38
27#endif 39#endif