Skip to content

Commit 687e025

Browse files
coresight: etm4x: splitting etmv4 default configuration
Splitting and updating the default initialisation for each etmv4 configuration so that it can be called at the beginning of each session rather than initialisation time only. Since the trace ID isn't expected to change with every session, moving it with the default tracer initialisation. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit fc208abef39279903887bea955139f64bf0bbb12)
1 parent 640cc6a commit 687e025

2 files changed

Lines changed: 73 additions & 67 deletions

File tree

drivers/hwtracing/coresight/coresight-etm4x.c

Lines changed: 61 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/clk.h>
2727
#include <linux/cpu.h>
2828
#include <linux/coresight.h>
29+
#include <linux/coresight-pmu.h>
2930
#include <linux/pm_wakeup.h>
3031
#include <linux/amba/bus.h>
3132
#include <linux/seq_file.h>
@@ -436,14 +437,20 @@ static void etm4_init_arch_data(void *info)
436437
CS_LOCK(drvdata->base);
437438
}
438439

439-
static void etm4_init_default_data(struct etmv4_drvdata *drvdata)
440+
static void etm4_set_default(struct etmv4_config *config)
440441
{
441-
int i;
442-
struct etmv4_config *config = &drvdata->config;
442+
if (WARN_ON_ONCE(!config))
443+
return;
443444

444-
config->pe_sel = 0x0;
445-
config->cfg = (ETMv4_MODE_CTXID | ETM_MODE_VMID |
446-
ETMv4_MODE_TIMESTAMP | ETM_MODE_RETURNSTACK);
445+
/*
446+
* Make default initialisation trace everything
447+
*
448+
* Select the "always true" resource selector on the
449+
* "Enablign Event" line and configure address range comparator
450+
* '0' to trace all the possible address range. From there
451+
* configure the "include/exclude" engine to include address
452+
* range comparator '0'.
453+
*/
447454

448455
/* disable all events tracing */
449456
config->eventctrl0 = 0x0;
@@ -452,78 +459,58 @@ static void etm4_init_default_data(struct etmv4_drvdata *drvdata)
452459
/* disable stalling */
453460
config->stall_ctrl = 0x0;
454461

462+
/* enable trace synchronization every 4096 bytes, if available */
463+
config->syncfreq = 0xC;
464+
455465
/* disable timestamp event */
456466
config->ts_ctrl = 0x0;
457467

458-
/* enable trace synchronization every 4096 bytes for trace */
459-
if (drvdata->syncpr == false)
460-
config->syncfreq = 0xC;
468+
/* TRCVICTLR::EVENT = 0x01, select the always on logic */
469+
config->vinst_ctrl |= BIT(0);
461470

462471
/*
463-
* enable viewInst to trace everything with start-stop logic in
464-
* started state
472+
* TRCVICTLR::SSSTATUS == 1, the start-stop logic is
473+
* in the started state
465474
*/
466-
config->vinst_ctrl |= BIT(0);
467-
/* set initial state of start-stop logic */
468-
if (drvdata->nr_addr_cmp)
469-
config->vinst_ctrl |= BIT(9);
470-
471-
/* no address range filtering for ViewInst */
472-
config->viiectlr = 0x0;
473-
/* no start-stop filtering for ViewInst */
474-
config->vissctlr = 0x0;
475-
476-
/* disable seq events */
477-
for (i = 0; i < drvdata->nrseqstate-1; i++)
478-
config->seq_ctrl[i] = 0x0;
479-
config->seq_rst = 0x0;
480-
config->seq_state = 0x0;
481-
482-
/* disable external input events */
483-
config->ext_inp = 0x0;
484-
485-
for (i = 0; i < drvdata->nr_cntr; i++) {
486-
config->cntrldvr[i] = 0x0;
487-
config->cntr_ctrl[i] = 0x0;
488-
config->cntr_val[i] = 0x0;
489-
}
490-
491-
/* Resource selector pair 0 is always implemented and reserved */
492-
config->res_idx = 0x2;
493-
for (i = 2; i < drvdata->nr_resource * 2; i++)
494-
config->res_ctrl[i] = 0x0;
475+
config->vinst_ctrl |= BIT(9);
495476

496-
for (i = 0; i < drvdata->nr_ss_cmp; i++) {
497-
config->ss_ctrl[i] = 0x0;
498-
config->ss_pe_cmp[i] = 0x0;
499-
}
500-
501-
if (drvdata->nr_addr_cmp >= 1) {
502-
config->addr_val[0] = (unsigned long)_stext;
503-
config->addr_val[1] = (unsigned long)_etext;
504-
config->addr_type[0] = ETM_ADDR_TYPE_RANGE;
505-
config->addr_type[1] = ETM_ADDR_TYPE_RANGE;
506-
}
507-
508-
for (i = 0; i < drvdata->numcidc; i++) {
509-
config->ctxid_pid[i] = 0x0;
510-
config->ctxid_vpid[i] = 0x0;
511-
}
477+
/*
478+
* Configure address range comparator '0' to encompass all
479+
* possible addresses.
480+
*/
512481

513-
config->ctxid_mask0 = 0x0;
514-
config->ctxid_mask1 = 0x0;
482+
/* First half of default address comparator: start at address 0 */
483+
config->addr_val[ETM_DEFAULT_ADDR_COMP] = 0x0;
484+
/* trace instruction addresses */
485+
config->addr_acc[ETM_DEFAULT_ADDR_COMP] &= ~(BIT(0) | BIT(1));
486+
/* EXLEVEL_NS, bits[12:15], only trace application and kernel space */
487+
config->addr_acc[ETM_DEFAULT_ADDR_COMP] |= ETM_EXLEVEL_NS_HYP;
488+
/* EXLEVEL_S, bits[11:8], don't trace anything in secure state */
489+
config->addr_acc[ETM_DEFAULT_ADDR_COMP] |= (ETM_EXLEVEL_S_APP |
490+
ETM_EXLEVEL_S_OS |
491+
ETM_EXLEVEL_S_HYP);
492+
config->addr_type[ETM_DEFAULT_ADDR_COMP] = ETM_ADDR_TYPE_RANGE;
515493

516-
for (i = 0; i < drvdata->numvmidc; i++)
517-
config->vmid_val[i] = 0x0;
518-
config->vmid_mask0 = 0x0;
519-
config->vmid_mask1 = 0x0;
494+
/*
495+
* Second half of default address comparator: go all
496+
* the way to the top.
497+
*/
498+
config->addr_val[ETM_DEFAULT_ADDR_COMP + 1] = ~0x0;
499+
/* trace instruction addresses */
500+
config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] &= ~(BIT(0) | BIT(1));
501+
/* Address comparator type must be equal for both halves */
502+
config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] =
503+
config->addr_acc[ETM_DEFAULT_ADDR_COMP];
504+
config->addr_type[ETM_DEFAULT_ADDR_COMP + 1] = ETM_ADDR_TYPE_RANGE;
520505

521506
/*
522-
* A trace ID value of 0 is invalid, so let's start at some
523-
* random value that fits in 7 bits. ETMv3.x has 0x10 so let's
524-
* start at 0x20.
507+
* Configure the ViewInst function to filter on address range
508+
* comparator '0'.
525509
*/
526-
drvdata->trcid = 0x20 + drvdata->cpu;
510+
config->viiectlr = BIT(0);
511+
512+
/* no start-stop filtering for ViewInst */
513+
config->vissctlr = 0x0;
527514
}
528515

529516
static int etm4_cpu_callback(struct notifier_block *nfb, unsigned long action,
@@ -568,6 +555,11 @@ static struct notifier_block etm4_cpu_notifier = {
568555
.notifier_call = etm4_cpu_callback,
569556
};
570557

558+
static void etm4_init_trace_id(struct etmv4_drvdata *drvdata)
559+
{
560+
drvdata->trcid = coresight_get_trace_id(drvdata->cpu);
561+
}
562+
571563
static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
572564
{
573565
int ret;
@@ -627,7 +619,9 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
627619
ret = -EINVAL;
628620
goto err_arch_supported;
629621
}
630-
etm4_init_default_data(drvdata);
622+
623+
etm4_init_trace_id(drvdata);
624+
etm4_set_default(&drvdata->config);
631625

632626
pm_runtime_put(&adev->dev);
633627

drivers/hwtracing/coresight/coresight-etm4x.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,18 @@
178178
#define ETMv4_MODE_ALL 0xFFFFFFF
179179

180180
#define TRCSTATR_IDLE_BIT 0
181+
#define ETM_DEFAULT_ADDR_COMP 0
182+
183+
/* secure state access levels */
184+
#define ETM_EXLEVEL_S_APP BIT(8)
185+
#define ETM_EXLEVEL_S_OS BIT(9)
186+
#define ETM_EXLEVEL_S_NA BIT(10)
187+
#define ETM_EXLEVEL_S_HYP BIT(11)
188+
/* non-secure state access levels */
189+
#define ETM_EXLEVEL_NS_APP BIT(12)
190+
#define ETM_EXLEVEL_NS_OS BIT(13)
191+
#define ETM_EXLEVEL_NS_HYP BIT(14)
192+
#define ETM_EXLEVEL_NS_NA BIT(15)
181193

182194
/**
183195
* struct etmv4_config - configuration information related to an ETMv4

0 commit comments

Comments
 (0)