Skip to content

Commit 7fdc9bb

Browse files
mikel-armbbgregkh
authored andcommitted
coresight: config: Add preloaded configurations
Preload set of configurations. This patch creates a small set of preloaded configurations and features that are available immediately after coresight has been initialised. The current set provides a strobing feature for ETMv4, that creates a periodic sampling of trace by switching trace generation on and off using counters in the ETM. A configuration called "autofdo" is also provided that uses the 'strobing' feature and provides a couple of preset values, selectable on the perf command line. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mike Leach <[email protected]> Signed-off-by: Mathieu Poirier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 810ac40 commit 7fdc9bb

File tree

7 files changed

+224
-1
lines changed

7 files changed

+224
-1
lines changed

drivers/hwtracing/coresight/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#
55
obj-$(CONFIG_CORESIGHT) += coresight.o
66
coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \
7-
coresight-sysfs.o coresight-syscfg.o coresight-config.o
7+
coresight-sysfs.o coresight-syscfg.o coresight-config.o \
8+
coresight-cfg-preload.o coresight-cfg-afdo.o
89
obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o
910
coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \
1011
coresight-tmc-etr.o
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright(C) 2020 Linaro Limited. All rights reserved.
4+
* Author: Mike Leach <[email protected]>
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+
/* strobe feature */
18+
static struct cscfg_parameter_desc strobe_params[] = {
19+
{
20+
.name = "window",
21+
.value = 5000,
22+
},
23+
{
24+
.name = "period",
25+
.value = 10000,
26+
},
27+
};
28+
29+
static struct cscfg_regval_desc strobe_regs[] = {
30+
/* resource selectors */
31+
{
32+
.type = CS_CFG_REG_TYPE_RESOURCE,
33+
.offset = TRCRSCTLRn(2),
34+
.hw_info = ETM4_CFG_RES_SEL,
35+
.val32 = 0x20001,
36+
},
37+
{
38+
.type = CS_CFG_REG_TYPE_RESOURCE,
39+
.offset = TRCRSCTLRn(3),
40+
.hw_info = ETM4_CFG_RES_SEQ,
41+
.val32 = 0x20002,
42+
},
43+
/* strobe window counter 0 - reload from param 0 */
44+
{
45+
.type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_SAVE,
46+
.offset = TRCCNTVRn(0),
47+
.hw_info = ETM4_CFG_RES_CTR,
48+
},
49+
{
50+
.type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_PARAM,
51+
.offset = TRCCNTRLDVRn(0),
52+
.hw_info = ETM4_CFG_RES_CTR,
53+
.val32 = 0,
54+
},
55+
{
56+
.type = CS_CFG_REG_TYPE_RESOURCE,
57+
.offset = TRCCNTCTLRn(0),
58+
.hw_info = ETM4_CFG_RES_CTR,
59+
.val32 = 0x10001,
60+
},
61+
/* strobe period counter 1 - reload from param 1 */
62+
{
63+
.type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_SAVE,
64+
.offset = TRCCNTVRn(1),
65+
.hw_info = ETM4_CFG_RES_CTR,
66+
},
67+
{
68+
.type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_PARAM,
69+
.offset = TRCCNTRLDVRn(1),
70+
.hw_info = ETM4_CFG_RES_CTR,
71+
.val32 = 1,
72+
},
73+
{
74+
.type = CS_CFG_REG_TYPE_RESOURCE,
75+
.offset = TRCCNTCTLRn(1),
76+
.hw_info = ETM4_CFG_RES_CTR,
77+
.val32 = 0x8102,
78+
},
79+
/* sequencer */
80+
{
81+
.type = CS_CFG_REG_TYPE_RESOURCE,
82+
.offset = TRCSEQEVRn(0),
83+
.hw_info = ETM4_CFG_RES_SEQ,
84+
.val32 = 0x0081,
85+
},
86+
{
87+
.type = CS_CFG_REG_TYPE_RESOURCE,
88+
.offset = TRCSEQEVRn(1),
89+
.hw_info = ETM4_CFG_RES_SEQ,
90+
.val32 = 0x0000,
91+
},
92+
/* view-inst */
93+
{
94+
.type = CS_CFG_REG_TYPE_STD | CS_CFG_REG_TYPE_VAL_MASK,
95+
.offset = TRCVICTLR,
96+
.val32 = 0x0003,
97+
.mask32 = 0x0003,
98+
},
99+
/* end of regs */
100+
};
101+
102+
struct cscfg_feature_desc strobe_etm4x = {
103+
.name = "strobing",
104+
.description = "Generate periodic trace capture windows.\n"
105+
"parameter \'window\': a number of CPU cycles (W)\n"
106+
"parameter \'period\': trace enabled for W cycles every period x W cycles\n",
107+
.match_flags = CS_CFG_MATCH_CLASS_SRC_ETM4,
108+
.nr_params = ARRAY_SIZE(strobe_params),
109+
.params_desc = strobe_params,
110+
.nr_regs = ARRAY_SIZE(strobe_regs),
111+
.regs_desc = strobe_regs,
112+
};
113+
114+
/* create an autofdo configuration */
115+
116+
/* we will provide 9 sets of preset parameter values */
117+
#define AFDO_NR_PRESETS 9
118+
/* the total number of parameters in used features */
119+
#define AFDO_NR_PARAMS ARRAY_SIZE(strobe_params)
120+
121+
static const char *afdo_ref_names[] = {
122+
"strobing",
123+
};
124+
125+
/*
126+
* set of presets leaves strobing window constant while varying period to allow
127+
* experimentation with mark / space ratios for various workloads
128+
*/
129+
static u64 afdo_presets[AFDO_NR_PRESETS][AFDO_NR_PARAMS] = {
130+
{ 5000, 2 },
131+
{ 5000, 4 },
132+
{ 5000, 8 },
133+
{ 5000, 16 },
134+
{ 5000, 64 },
135+
{ 5000, 128 },
136+
{ 5000, 512 },
137+
{ 5000, 1024 },
138+
{ 5000, 4096 },
139+
};
140+
141+
struct cscfg_config_desc afdo_etm4x = {
142+
.name = "autofdo",
143+
.description = "Setup ETMs with strobing for autofdo\n"
144+
"Supplied presets allow experimentation with mark-space ratio for various loads\n",
145+
.nr_feat_refs = ARRAY_SIZE(afdo_ref_names),
146+
.feat_ref_names = afdo_ref_names,
147+
.nr_presets = AFDO_NR_PRESETS,
148+
.nr_total_params = AFDO_NR_PARAMS,
149+
.presets = &afdo_presets[0][0],
150+
};
151+
152+
/* end of ETM4x configurations */
153+
#endif /* IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright(C) 2020 Linaro Limited. All rights reserved.
4+
* Author: Mike Leach <[email protected]>
5+
*/
6+
7+
#include "coresight-cfg-preload.h"
8+
#include "coresight-config.h"
9+
#include "coresight-syscfg.h"
10+
11+
/* Basic features and configurations pre-loaded on initialisation */
12+
13+
static struct cscfg_feature_desc *preload_feats[] = {
14+
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
15+
&strobe_etm4x,
16+
#endif
17+
NULL
18+
};
19+
20+
static struct cscfg_config_desc *preload_cfgs[] = {
21+
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
22+
&afdo_etm4x,
23+
#endif
24+
NULL
25+
};
26+
27+
/* preload called on initialisation */
28+
int cscfg_preload(void)
29+
{
30+
return cscfg_load_config_sets(preload_cfgs, preload_feats);
31+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright(C) 2020 Linaro Limited. All rights reserved.
4+
* Author: Mike Leach <[email protected]>
5+
*/
6+
7+
/* declare preloaded configurations and features */
8+
9+
/* from coresight-cfg-afdo.c - etm 4x features */
10+
#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
11+
extern struct cscfg_feature_desc strobe_etm4x;
12+
extern struct cscfg_config_desc afdo_etm4x;
13+
#endif

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@
99
#include "coresight-config.h"
1010
#include "coresight-etm4x.h"
1111

12+
/* ETMv4 specific config defines */
13+
14+
/* resource IDs */
15+
16+
#define ETM4_CFG_RES_CTR 0x001
17+
#define ETM4_CFG_RES_CMP 0x002
18+
#define ETM4_CFG_RES_CMP_PAIR0 0x003
19+
#define ETM4_CFG_RES_CMP_PAIR1 0x004
20+
#define ETM4_CFG_RES_SEL 0x005
21+
#define ETM4_CFG_RES_SEL_PAIR0 0x006
22+
#define ETM4_CFG_RES_SEL_PAIR1 0x007
23+
#define ETM4_CFG_RES_SEQ 0x008
24+
#define ETM4_CFG_RES_TS 0x009
25+
#define ETM4_CFG_RES_MASK 0x00F
26+
1227
/* ETMv4 specific config functions */
1328
int etm4_cscfg_register(struct coresight_device *csdev);
1429

drivers/hwtracing/coresight/coresight-syscfg.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,17 @@ int __init cscfg_init(void)
752752
INIT_LIST_HEAD(&cscfg_mgr->config_desc_list);
753753
atomic_set(&cscfg_mgr->sys_active_cnt, 0);
754754

755+
/* preload built-in configurations */
756+
err = cscfg_preload();
757+
if (err)
758+
goto exit_err;
759+
755760
dev_info(cscfg_device(), "CoreSight Configuration manager initialised");
756761
return 0;
762+
763+
exit_err:
764+
cscfg_clear_device();
765+
return err;
757766
}
758767

759768
void cscfg_exit(void)

drivers/hwtracing/coresight/coresight-syscfg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct cscfg_registered_csdev {
5656
/* internal core operations for cscfg */
5757
int __init cscfg_init(void);
5858
void cscfg_exit(void);
59+
int cscfg_preload(void);
5960

6061
/* syscfg manager external API */
6162
int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs,

0 commit comments

Comments
 (0)