Skip to content

Commit 4b7e626

Browse files
Linu CherianSuzuki K Poulose
authored andcommitted
coresight: config: Add preloaded configuration
Add a preloaded configuration for generating external trigger on address match. This can be used by CTI and ETR blocks to stop trace capture on kernel panic. Kernel address for "panic" function is used as the default trigger address. This new configuration is available as, /sys/kernel/config/cs-syscfg/configurations/panicstop Signed-off-by: Linu Cherian <[email protected]> Reviewed-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 942bbee commit 4b7e626

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

drivers/hwtracing/coresight/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ subdir-ccflags-y += $(condflags)
2525
obj-$(CONFIG_CORESIGHT) += coresight.o
2626
coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \
2727
coresight-sysfs.o coresight-syscfg.o coresight-config.o \
28-
coresight-cfg-preload.o coresight-cfg-afdo.o \
28+
coresight-cfg-preload.o coresight-cfg-afdo.o coresight-cfg-pstop.o \
2929
coresight-syscfg-configfs.o coresight-trace-id.o
3030
obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o
3131
coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \

drivers/hwtracing/coresight/coresight-cfg-preload.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
static struct cscfg_feature_desc *preload_feats[] = {
1414
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
1515
&strobe_etm4x,
16+
&gen_etrig_etm4x,
1617
#endif
1718
NULL
1819
};
1920

2021
static struct cscfg_config_desc *preload_cfgs[] = {
2122
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
2223
&afdo_etm4x,
24+
&pstop_etm4x,
2325
#endif
2426
NULL
2527
};

drivers/hwtracing/coresight/coresight-cfg-preload.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
1111
extern struct cscfg_feature_desc strobe_etm4x;
1212
extern struct cscfg_config_desc afdo_etm4x;
13+
extern struct cscfg_feature_desc gen_etrig_etm4x;
14+
extern struct cscfg_config_desc pstop_etm4x;
1315
#endif
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright(C) 2023 Marvell.
4+
* Based on coresight-cfg-afdo.c
5+
*/
6+
7+
#include "coresight-config.h"
8+
9+
/* ETMv4 includes and features */
10+
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
11+
#include "coresight-etm4x-cfg.h"
12+
13+
/* preload configurations and features */
14+
15+
/* preload in features for ETMv4 */
16+
17+
/* panic_stop feature */
18+
static struct cscfg_parameter_desc gen_etrig_params[] = {
19+
{
20+
.name = "address",
21+
.value = (u64)panic,
22+
},
23+
};
24+
25+
static struct cscfg_regval_desc gen_etrig_regs[] = {
26+
/* resource selector */
27+
{
28+
.type = CS_CFG_REG_TYPE_RESOURCE,
29+
.offset = TRCRSCTLRn(2),
30+
.hw_info = ETM4_CFG_RES_SEL,
31+
.val32 = 0x40001,
32+
},
33+
/* single address comparator */
34+
{
35+
.type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_64BIT |
36+
CS_CFG_REG_TYPE_VAL_PARAM,
37+
.offset = TRCACVRn(0),
38+
.val32 = 0x0,
39+
},
40+
{
41+
.type = CS_CFG_REG_TYPE_RESOURCE,
42+
.offset = TRCACATRn(0),
43+
.val64 = 0xf00,
44+
},
45+
/* Driver external output[0] with comparator out */
46+
{
47+
.type = CS_CFG_REG_TYPE_RESOURCE,
48+
.offset = TRCEVENTCTL0R,
49+
.val32 = 0x2,
50+
},
51+
/* end of regs */
52+
};
53+
54+
struct cscfg_feature_desc gen_etrig_etm4x = {
55+
.name = "gen_etrig",
56+
.description = "Generate external trigger on address match\n"
57+
"parameter \'address\': address of kernel address\n",
58+
.match_flags = CS_CFG_MATCH_CLASS_SRC_ETM4,
59+
.nr_params = ARRAY_SIZE(gen_etrig_params),
60+
.params_desc = gen_etrig_params,
61+
.nr_regs = ARRAY_SIZE(gen_etrig_regs),
62+
.regs_desc = gen_etrig_regs,
63+
};
64+
65+
/* create a panic stop configuration */
66+
67+
/* the total number of parameters in used features */
68+
#define PSTOP_NR_PARAMS ARRAY_SIZE(gen_etrig_params)
69+
70+
static const char *pstop_ref_names[] = {
71+
"gen_etrig",
72+
};
73+
74+
struct cscfg_config_desc pstop_etm4x = {
75+
.name = "panicstop",
76+
.description = "Stop ETM on kernel panic\n",
77+
.nr_feat_refs = ARRAY_SIZE(pstop_ref_names),
78+
.feat_ref_names = pstop_ref_names,
79+
.nr_total_params = PSTOP_NR_PARAMS,
80+
};
81+
82+
/* end of ETM4x configurations */
83+
#endif /* IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) */

0 commit comments

Comments
 (0)