Preload set of configurations.
Signed-off-by: Mike Leach mike.leach@linaro.org --- drivers/hwtracing/coresight/Makefile | 3 +- .../coresight/coresight-cfg-preload.c | 165 ++++++++++++++++++ drivers/hwtracing/coresight/coresight-core.c | 7 + .../hwtracing/coresight/coresight-syscfg.h | 1 + 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 drivers/hwtracing/coresight/coresight-cfg-preload.c
diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index 5723094b2b69..8914be6b254c 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -4,7 +4,8 @@ # obj-$(CONFIG_CORESIGHT) += coresight.o coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \ - coresight-sysfs.o coresight-syscfg.o coresight-config.o + coresight-sysfs.o coresight-syscfg.o coresight-config.o \ + coresight-cfg-preload.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \ coresight-tmc-etr.o diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.c b/drivers/hwtracing/coresight/coresight-cfg-preload.c new file mode 100644 index 000000000000..77b477b868d0 --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-cfg-preload.c @@ -0,0 +1,165 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright(C) 2020 Linaro Limited. All rights reserved. + * Author: Mike Leach mike.leach@linaro.org + */ + +#include "coresight-config.h" +#include "coresight-syscfg.h" +#include "coresight-etm4x-cfg.h" + +/* preload configurations and features */ + +/* preload in features for ETMv4 */ + +/* strobe feature */ + +/* register defines */ +#define STRB_REG_CTR (CS_CFG_REG_RESOURCE | ETM4_CFG_RES_CTR) +#define STRB_REG_CTR_RB (STRB_REG_CTR | CS_CFG_REG_VAL_SAVE) +#define STRB_REG_CTR_PRM (STRB_REG_CTR | CS_CFG_REG_VAL_PARAM) +#define STRB_REG_SEQ (CS_CFG_REG_RESOURCE | ETM4_CFG_RES_SEQ) +#define STRB_REG_SEL (CS_CFG_REG_RESOURCE | ETM4_CFG_RES_SEL) +#define STRB_REG_VI (CS_CFG_REG_STD | CS_CFG_REG_VAL_MASK) + +static struct cs_cfg_parameter_desc strobe_params[] = { + { + .name = "window", + .value = 5000, + }, + { + .name = "period", + .value = 10000, + }, + { 0 }, +}; + +static struct cs_cfg_reg_desc strobe_regs[] = { + /* resource selectors */ + { + .flags = STRB_REG_SEL | TRCRSCTLRn(2), + .value = { + .val32 = 0x20001, + }, + }, + { + .flags = STRB_REG_SEQ | TRCRSCTLRn(3), + .value = { + .val32 = 0x20002, + } + }, + /* strobe window counter 0 - reload from param 0 */ + { + .flags = STRB_REG_CTR_RB | TRCCNTVRn(0), + }, + { + .flags = STRB_REG_CTR_PRM | TRCCNTRLDVRn(0), + .value = { + .val32 = 0, + }, + }, + { + .flags = STRB_REG_CTR | TRCCNTCTLRn(0), + .value = { + .val32 = 0x10001, + }, + }, + /* strobe period counter 1 - reload from param 1 */ + { + .flags = STRB_REG_CTR_RB | TRCCNTVRn(1), + }, + { + .flags = STRB_REG_CTR_PRM | TRCCNTRLDVRn(1), + .value = { + .val32 = 1, + }, + }, + { + .flags = STRB_REG_CTR | TRCCNTCTLRn(1), + .value = { + .val32 = 0x8102, + }, + }, + /* sequencer */ + { + .flags = STRB_REG_SEQ | TRCSEQEVRn(0), + .value = { + .val32 = 0x0081, + }, + }, + { + .flags = STRB_REG_SEQ | TRCSEQEVRn(1), + .value = { + .val32 = 0x0000, + }, + }, + /* view-inst */ + { + .flags = STRB_REG_VI | TRCVICTLR, + .value = { + .val32 = 0x0003, + .mask32 = 0x0003, + }, + }, + /* end of regs */ + { 0 }, +}; + +static struct cs_cfg_feature_desc strobe = { + .name = "strobing", + .brief = "Generate periodic trace capture windows.", + .match_flags = CS_CFG_MATCH_CLASS_SRC_ETM4, + .params = strobe_params, + .regs = strobe_regs, +}; + +static struct cs_cfg_feature_desc *preload_feats[] = { + &strobe, + 0 +}; + +/* create an autofdo configuration */ + +/* we will provide 2 sets of preset parameter values */ +#define AFDO_NR_PRESETS 2 +/* the total number of parameters in used features */ +#define AFDO_NR_PARAM_SUM 2 + +#define AFDO_MATCH_STROBING (CS_CFG_MATCH_INST_ANY | CS_CFG_MATCH_CLASS_SRC_ETM4) + +static struct cs_cfg_uses_feat_desc afdo_uses[] = { + { + .name = "strobing", + .nr_params = 2, + .match = { + .flags = AFDO_MATCH_STROBING, + }, + }, +}; + +static u64 afdo_presets[AFDO_NR_PRESETS][AFDO_NR_PARAM_SUM] = { + { 10000, 5000 }, + { 5000, 5000 }, +}; + + +static struct cs_cfg_config_desc afdo = { + .name = "autofdo", + .brief = "Setup ETMs with strobing for autofdo", + .nr_uses = sizeof(afdo_uses) / sizeof(struct cs_cfg_uses_feat_desc), + .uses = afdo_uses, + .nr_presets = AFDO_NR_PRESETS, + .nr_total_params = AFDO_NR_PARAM_SUM, + .presets = &afdo_presets[0][0], +}; + +static struct cs_cfg_config_desc *preload_cfgs[] = { + &afdo, + 0 +}; + +/* preload called with mutex locked */ +int cscfg_preload(void) +{ + return cscfg_load_config_sets(preload_cfgs, preload_feats); +} diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 91f1fbd7d51d..7158d5a46b93 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1701,9 +1701,16 @@ static int __init coresight_init(void) goto exit_perf_clear;
ret = cscfg_create_device(); + if (ret) + goto exit_cscfg_driver; + + /* preload builtin configurations */ + ret = cscfg_preload(); if (!ret) return 0;
+ cscfg_clear_device(); +exit_cscfg_driver: cscfg_driver_exit(); exit_perf_clear: etm_perf_exit(); diff --git a/drivers/hwtracing/coresight/coresight-syscfg.h b/drivers/hwtracing/coresight/coresight-syscfg.h index 30dc12a7ecaa..b3a1c246dd33 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.h +++ b/drivers/hwtracing/coresight/coresight-syscfg.h @@ -77,6 +77,7 @@ int cscfg_create_device(void); void cscfg_clear_device(void); int __init cscfg_driver_init(void); void cscfg_driver_exit(void); +int cscfg_preload(void);
/* syscfg external API */ int cscfg_load_config_sets(struct cs_cfg_config_desc **cfg_descs,