linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] drivers: coresight: Adds return stack option handling.
@ 2017-07-11 11:25 Mike Leach
  2017-07-11 11:25 ` [PATCH 1/3] coresight: pmu: Adds return stack option to perf coresight pmu Mike Leach
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Mike Leach @ 2017-07-11 11:25 UTC (permalink / raw)
  To: linux-arm-kernel

Trace return stack is a PTM and ETMv4 programmable option to reduce the
amount of trace genrated by omitting addresses from the trace stream
and inferring them from a local stack of return address values saved when
branch and link instructions are traced.

Adds 'retstack' as a command line option to cs_etm event in perf.
Adds support to program PTM / ETMv4 hardware to use feature.

Mike Leach (3):
  coresight: pmu:  Adds return stack option to perf coresight pmu
  coresight: ptm: Adds trace return stack option programming for PTM.
  coresight: etm4x: Adds trace return stack option programming for
    ETMv4.

 drivers/hwtracing/coresight/coresight-etm-perf.c |  2 ++
 drivers/hwtracing/coresight/coresight-etm.h      |  1 +
 drivers/hwtracing/coresight/coresight-etm3x.c    | 18 +++++++++++++++---
 drivers/hwtracing/coresight/coresight-etm4x.c    |  4 ++++
 include/linux/coresight-pmu.h                    |  1 +
 tools/include/linux/coresight-pmu.h              |  1 +
 6 files changed, 24 insertions(+), 3 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] coresight: pmu: Adds return stack option to perf coresight pmu
  2017-07-11 11:25 [PATCH 0/3] drivers: coresight: Adds return stack option handling Mike Leach
@ 2017-07-11 11:25 ` Mike Leach
  2017-07-11 11:25 ` [PATCH 2/3] coresight: ptm: Adds trace return stack option programming for PTM Mike Leach
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Mike Leach @ 2017-07-11 11:25 UTC (permalink / raw)
  To: linux-arm-kernel

Return stack is a programmable option on some ETM and PTM hardware.
Adds the option flags to enable this from the perf event command line.

Signed-off-by: Mike Leach <mike.leach@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm-perf.c | 2 ++
 include/linux/coresight-pmu.h                    | 1 +
 tools/include/linux/coresight-pmu.h              | 1 +
 3 files changed, 4 insertions(+)

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 8f546f5..5804551 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -53,10 +53,12 @@ static DEFINE_PER_CPU(struct coresight_device *, csdev_src);
 /* ETMv3.5/PTM's ETMCR is 'config' */
 PMU_FORMAT_ATTR(cycacc,		"config:" __stringify(ETM_OPT_CYCACC));
 PMU_FORMAT_ATTR(timestamp,	"config:" __stringify(ETM_OPT_TS));
+PMU_FORMAT_ATTR(retstack,	"config:" __stringify(ETM_OPT_RETSTK));
 
 static struct attribute *etm_config_formats_attr[] = {
 	&format_attr_cycacc.attr,
 	&format_attr_timestamp.attr,
+	&format_attr_retstack.attr,
 	NULL,
 };
 
diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h
index 7d41026..45852c2 100644
--- a/include/linux/coresight-pmu.h
+++ b/include/linux/coresight-pmu.h
@@ -24,6 +24,7 @@
 /* ETMv3.5/PTM's ETMCR config bit */
 #define ETM_OPT_CYCACC  12
 #define ETM_OPT_TS      28
+#define ETM_OPT_RETSTK	29
 
 static inline int coresight_get_trace_id(int cpu)
 {
diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h
index 7d41026..45852c2 100644
--- a/tools/include/linux/coresight-pmu.h
+++ b/tools/include/linux/coresight-pmu.h
@@ -24,6 +24,7 @@
 /* ETMv3.5/PTM's ETMCR config bit */
 #define ETM_OPT_CYCACC  12
 #define ETM_OPT_TS      28
+#define ETM_OPT_RETSTK	29
 
 static inline int coresight_get_trace_id(int cpu)
 {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] coresight: ptm: Adds trace return stack option programming for PTM.
  2017-07-11 11:25 [PATCH 0/3] drivers: coresight: Adds return stack option handling Mike Leach
  2017-07-11 11:25 ` [PATCH 1/3] coresight: pmu: Adds return stack option to perf coresight pmu Mike Leach
@ 2017-07-11 11:25 ` Mike Leach
  2017-07-11 11:25 ` [PATCH 3/3] coresight: etm4x: Adds trace return stack option programming for ETMv4 Mike Leach
  2017-07-12 15:15 ` [PATCH 0/3] drivers: coresight: Adds return stack option handling Mathieu Poirier
  3 siblings, 0 replies; 5+ messages in thread
From: Mike Leach @ 2017-07-11 11:25 UTC (permalink / raw)
  To: linux-arm-kernel

Adds handling to program the return stack option into PTM hardware if
specified in the perf command line.

If option is not supported by the hardware then it will be ignored.
This allows capture to move between core/ETM combinations that have the
hardware support to those that do not.

Signed-off-by: Mike Leach <mike.leach@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm.h   |  1 +
 drivers/hwtracing/coresight/coresight-etm3x.c | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm.h b/drivers/hwtracing/coresight/coresight-etm.h
index ad063d7..70b0a24 100644
--- a/drivers/hwtracing/coresight/coresight-etm.h
+++ b/drivers/hwtracing/coresight/coresight-etm.h
@@ -106,6 +106,7 @@
 #define ETMTECR1_START_STOP	BIT(25)
 /* ETMCCER - 0x1E8 */
 #define ETMCCER_TIMESTAMP	BIT(22)
+#define ETMCCER_RETSTACK	BIT(23)
 
 #define ETM_MODE_EXCLUDE	BIT(0)
 #define ETM_MODE_CYCACC		BIT(1)
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c
index a51b6b6..a0973f6 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x.c
@@ -308,7 +308,9 @@ void etm_config_trace_mode(struct etm_config *config)
 	config->addr_type[1] = ETM_ADDR_TYPE_RANGE;
 }
 
-#define ETM3X_SUPPORTED_OPTIONS (ETMCR_CYC_ACC | ETMCR_TIMESTAMP_EN)
+#define ETM3X_SUPPORTED_OPTIONS (ETMCR_CYC_ACC | \
+				 ETMCR_TIMESTAMP_EN | \
+				 ETMCR_RETURN_STACK)
 
 static int etm_parse_event_config(struct etm_drvdata *drvdata,
 				  struct perf_event *event)
@@ -339,14 +341,24 @@ static int etm_parse_event_config(struct etm_drvdata *drvdata,
 		etm_config_trace_mode(config);
 
 	/*
-	 * At this time only cycle accurate and timestamp options are
-	 * available.
+	 * At this time only cycle accurate, return stack  and timestamp
+	 * options are available.
 	 */
 	if (attr->config & ~ETM3X_SUPPORTED_OPTIONS)
 		return -EINVAL;
 
 	config->ctrl = attr->config;
 
+	/*
+	 * Possible to have cores with PTM (supports ret stack) and ETM
+	 * (never has ret stack) on the same SoC. So if we have a request
+	 * for return stack that can't be honoured on this core then
+	 * clear the bit - trace will still continue normally
+	 */
+	if ((config->ctrl & ETMCR_RETURN_STACK) &&
+	    !(drvdata->etmccer & ETMCCER_RETSTACK))
+		config->ctrl &= ~ETMCR_RETURN_STACK;
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] coresight: etm4x: Adds trace return stack option programming for ETMv4.
  2017-07-11 11:25 [PATCH 0/3] drivers: coresight: Adds return stack option handling Mike Leach
  2017-07-11 11:25 ` [PATCH 1/3] coresight: pmu: Adds return stack option to perf coresight pmu Mike Leach
  2017-07-11 11:25 ` [PATCH 2/3] coresight: ptm: Adds trace return stack option programming for PTM Mike Leach
@ 2017-07-11 11:25 ` Mike Leach
  2017-07-12 15:15 ` [PATCH 0/3] drivers: coresight: Adds return stack option handling Mathieu Poirier
  3 siblings, 0 replies; 5+ messages in thread
From: Mike Leach @ 2017-07-11 11:25 UTC (permalink / raw)
  To: linux-arm-kernel

Adds handling to program the return stack option into ETMv4 hardware if
specified in the perf command line.

If option is not supported by the hardware then it will be ignored.
This allows capture to move between core/ETM combinations that have the
hardware support to those that do not.

Signed-off-by: Mike Leach <mike.leach@linaro.org>
---
 drivers/hwtracing/coresight/coresight-etm4x.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
index d1340fb..fb3ce34 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x.c
@@ -224,6 +224,10 @@ static int etm4_parse_event_config(struct etmv4_drvdata *drvdata,
 	if (attr->config & BIT(ETM_OPT_TS))
 		/* bit[11], Global timestamp tracing bit */
 		config->cfg |= BIT(11);
+	/* return stack - enable if selected and supported */
+	if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack)
+		/* bit[12], Return stack enable bit */
+		config->cfg |= BIT(12);
 
 out:
 	return ret;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 0/3] drivers: coresight: Adds return stack option handling.
  2017-07-11 11:25 [PATCH 0/3] drivers: coresight: Adds return stack option handling Mike Leach
                   ` (2 preceding siblings ...)
  2017-07-11 11:25 ` [PATCH 3/3] coresight: etm4x: Adds trace return stack option programming for ETMv4 Mike Leach
@ 2017-07-12 15:15 ` Mathieu Poirier
  3 siblings, 0 replies; 5+ messages in thread
From: Mathieu Poirier @ 2017-07-12 15:15 UTC (permalink / raw)
  To: linux-arm-kernel

On 11 July 2017 at 05:25, Mike Leach <mike.leach@linaro.org> wrote:
> Trace return stack is a PTM and ETMv4 programmable option to reduce the
> amount of trace genrated by omitting addresses from the trace stream
> and inferring them from a local stack of return address values saved when
> branch and link instructions are traced.
>
> Adds 'retstack' as a command line option to cs_etm event in perf.
> Adds support to program PTM / ETMv4 hardware to use feature.
>
> Mike Leach (3):
>   coresight: pmu:  Adds return stack option to perf coresight pmu
>   coresight: ptm: Adds trace return stack option programming for PTM.
>   coresight: etm4x: Adds trace return stack option programming for
>     ETMv4.
>
>  drivers/hwtracing/coresight/coresight-etm-perf.c |  2 ++
>  drivers/hwtracing/coresight/coresight-etm.h      |  1 +
>  drivers/hwtracing/coresight/coresight-etm3x.c    | 18 +++++++++++++++---
>  drivers/hwtracing/coresight/coresight-etm4x.c    |  4 ++++
>  include/linux/coresight-pmu.h                    |  1 +
>  tools/include/linux/coresight-pmu.h              |  1 +
>  6 files changed, 24 insertions(+), 3 deletions(-)

I have applied this set.

Thanks,
Mathieu

>
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-12 15:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-11 11:25 [PATCH 0/3] drivers: coresight: Adds return stack option handling Mike Leach
2017-07-11 11:25 ` [PATCH 1/3] coresight: pmu: Adds return stack option to perf coresight pmu Mike Leach
2017-07-11 11:25 ` [PATCH 2/3] coresight: ptm: Adds trace return stack option programming for PTM Mike Leach
2017-07-11 11:25 ` [PATCH 3/3] coresight: etm4x: Adds trace return stack option programming for ETMv4 Mike Leach
2017-07-12 15:15 ` [PATCH 0/3] drivers: coresight: Adds return stack option handling Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).