From: Mike Leach <mike.leach@arm.com>
To: Yeoreum Yun <yeoreum.yun@arm.com>,
James Clark <james.clark@linaro.org>, Leo Yan <leo.yan@arm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH v11 8/9] coresight: etm4x: remove s_ex_level from config
Date: Fri, 18 Sep 2026 15:05:16 +0100 [thread overview]
Message-ID: <212419e5-a984-4f57-8a30-1d4558eb5c93@arm.com> (raw)
In-Reply-To: <20260915-separate_etm_cfg_v2-v11-8-d2b258d51747@arm.com>
Reviewed-by: Mike Leach <mike.leach@arm.com>
On 9/15/26 12:34, Yeoreum Yun wrote:
> s_ex_level is a hardware capability rather than a configurable parameter.
> As such, it should not be stored in the configuration structure.
>
> Remove s_ex_level from the config structure and pass etm4_caps to the
> functions that need to access this capability.
>
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
> ---
> drivers/hwtracing/coresight/coresight-etm4x-core.c | 58 +++++++++++++---------
> .../hwtracing/coresight/coresight-etm4x-sysfs.c | 2 +-
> drivers/hwtracing/coresight/coresight-etm4x.h | 5 +-
> 3 files changed, 38 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index 9de0c268ff954..e484e12572732 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -66,10 +66,12 @@ MODULE_PARM_DESC(pm_save_enable,
> "Save/restore state on power down: 1 = never, 2 = self-hosted. MMIO and DT only.");
>
> static struct etmv4_drvdata *etmdrvdata[NR_CPUS];
> -static void etm4_set_default_config(struct etmv4_config *config);
> +static void etm4_set_default_config(struct etmv4_config *config,
> + const struct etmv4_caps *caps);
> static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
> struct perf_event *event);
> -static u64 etm4_get_access_type(struct etmv4_config *config);
> +static u64 etm4_get_access_type(struct etmv4_config *config,
> + const struct etmv4_caps *caps);
>
> static enum cpuhp_state hp_online;
>
> @@ -803,7 +805,7 @@ static int etm4_parse_event_config(struct coresight_device *csdev,
> config->mode |= ETM_MODE_EXCL_GUEST;
>
> /* Always start from the default config */
> - etm4_set_default_config(config);
> + etm4_set_default_config(config, caps);
>
> /* Configure filters specified on the perf cmd line, if any. */
> ret = etm4_set_event_filters(drvdata, event);
> @@ -1471,7 +1473,6 @@ static void etm4_init_arch_data(void *info)
>
> /* EXLEVEL_S, bits[19:16] Secure state instruction tracing */
> caps->s_ex_level = FIELD_GET(TRCIDR3_EXLEVEL_S_MASK, etmidr3);
> - drvdata->config.s_ex_level = caps->s_ex_level;
> /* EXLEVEL_NS, bits[23:20] Non-secure state instruction tracing */
> caps->ns_ex_level = FIELD_GET(TRCIDR3_EXLEVEL_NS_MASK, etmidr3);
> /*
> @@ -1556,19 +1557,22 @@ static void etm4_init_arch_data(void *info)
> cpu_detect_trace_filtering(drvdata);
> }
>
> -static u32 etm4_get_victlr_access_type(struct etmv4_config *config)
> +static u32 etm4_get_victlr_access_type(struct etmv4_config *config,
> + const struct etmv4_caps *caps)
> {
> - return etm4_get_access_type(config) << __bf_shf(TRCVICTLR_EXLEVEL_MASK);
> + return etm4_get_access_type(config, caps) << __bf_shf(TRCVICTLR_EXLEVEL_MASK);
> }
>
> /* Set ELx trace filter access in the TRCVICTLR register */
> -static void etm4_set_victlr_access(struct etmv4_config *config)
> +static void etm4_set_victlr_access(struct etmv4_config *config,
> + const struct etmv4_caps *caps)
> {
> config->vinst_ctrl &= ~TRCVICTLR_EXLEVEL_MASK;
> - config->vinst_ctrl |= etm4_get_victlr_access_type(config);
> + config->vinst_ctrl |= etm4_get_victlr_access_type(config, caps);
> }
>
> -static void etm4_set_default_config(struct etmv4_config *config)
> +static void etm4_set_default_config(struct etmv4_config *config,
> + const struct etmv4_caps *caps)
> {
> /* disable all events tracing */
> config->eventctrl0 = 0x0;
> @@ -1587,7 +1591,7 @@ static void etm4_set_default_config(struct etmv4_config *config)
> config->vinst_ctrl = FIELD_PREP(TRCVICTLR_EVENT_MASK, 0x01);
>
> /* TRCVICTLR::EXLEVEL_NS:EXLEVELS: Set kernel / user filtering */
> - etm4_set_victlr_access(config);
> + etm4_set_victlr_access(config, caps);
> }
>
> static u64 etm4_get_ns_access_type(struct etmv4_config *config)
> @@ -1619,21 +1623,24 @@ static u64 etm4_get_ns_access_type(struct etmv4_config *config)
> * This must be shifted to the corresponding register field
> * for usage.
> */
> -static u64 etm4_get_access_type(struct etmv4_config *config)
> +static u64 etm4_get_access_type(struct etmv4_config *config,
> + const struct etmv4_caps *caps)
> {
> /* All Secure exception levels are excluded from the trace */
> - return etm4_get_ns_access_type(config) | (u64)config->s_ex_level;
> + return etm4_get_ns_access_type(config) | (u64)caps->s_ex_level;
> }
>
> -static u64 etm4_get_comparator_access_type(struct etmv4_config *config)
> +static u64 etm4_get_comparator_access_type(struct etmv4_config *config,
> + const struct etmv4_caps *caps)
> {
> - return etm4_get_access_type(config) << TRCACATR_EXLEVEL_SHIFT;
> + return etm4_get_access_type(config, caps) << TRCACATR_EXLEVEL_SHIFT;
> }
>
> static void etm4_set_comparator_filter(struct etmv4_config *config,
> + const struct etmv4_caps *caps,
> u64 start, u64 stop, int comparator)
> {
> - u64 access_type = etm4_get_comparator_access_type(config);
> + u64 access_type = etm4_get_comparator_access_type(config, caps);
>
> /* First half of default address comparator */
> config->addr_val[comparator] = start;
> @@ -1664,11 +1671,12 @@ static void etm4_set_comparator_filter(struct etmv4_config *config,
> }
>
> static void etm4_set_start_stop_filter(struct etmv4_config *config,
> + const struct etmv4_caps *caps,
> u64 address, int comparator,
> enum etm_addr_type type)
> {
> int shift;
> - u64 access_type = etm4_get_comparator_access_type(config);
> + u64 access_type = etm4_get_comparator_access_type(config, caps);
>
> /* Configure the comparator */
> config->addr_val[comparator] = address;
> @@ -1700,7 +1708,8 @@ static void etm4_set_default_filter(struct etmv4_config *config)
> config->vissctlr = 0x0;
> }
>
> -static void etm4_set_default(struct etmv4_config *config)
> +static void etm4_set_default(struct etmv4_config *config,
> + const struct etmv4_caps *caps)
> {
> if (WARN_ON_ONCE(!config))
> return;
> @@ -1712,7 +1721,7 @@ static void etm4_set_default(struct etmv4_config *config)
> * full instruction trace - with a default filter for trace all
> * achieved by having no filtering.
> */
> - etm4_set_default_config(config);
> + etm4_set_default_config(config, caps);
> etm4_set_default_filter(config);
> }
>
> @@ -1760,6 +1769,7 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
> {
> int i, comparator, ret = 0;
> u64 address;
> + const struct etmv4_caps *caps = &drvdata->caps;
> struct etmv4_config *config = &drvdata->active_config;
> struct etm_filters *filters = event->hw.addr_filters;
>
> @@ -1789,7 +1799,7 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
>
> switch (type) {
> case ETM_ADDR_TYPE_RANGE:
> - etm4_set_comparator_filter(config,
> + etm4_set_comparator_filter(config, caps,
> filter->start_addr,
> filter->stop_addr,
> comparator);
> @@ -1810,7 +1820,7 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
> filter->stop_addr);
>
> /* Configure comparator */
> - etm4_set_start_stop_filter(config, address,
> + etm4_set_start_stop_filter(config, caps, address,
> comparator, type);
>
> /*
> @@ -1846,7 +1856,8 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
> return ret;
> }
>
> -void etm4_config_trace_mode(struct etmv4_config *config)
> +void etm4_config_trace_mode(struct etmv4_config *config,
> + const struct etmv4_caps *caps)
> {
> u32 mode;
>
> @@ -1860,7 +1871,7 @@ void etm4_config_trace_mode(struct etmv4_config *config)
> if (!(mode & ETM_MODE_EXCL_KERN) && !(mode & ETM_MODE_EXCL_USER))
> return;
>
> - etm4_set_victlr_access(config);
> + etm4_set_victlr_access(config, caps);
> }
>
> static int etm4_online_cpu(unsigned int cpu)
> @@ -2172,6 +2183,7 @@ static int etm4_add_coresight_dev(struct etm4_init_arg *init_arg)
> struct coresight_platform_data *pdata = NULL;
> struct device *dev = init_arg->dev;
> struct etmv4_drvdata *drvdata = dev_get_drvdata(dev);
> + const struct etmv4_caps *caps = &drvdata->caps;
> struct coresight_desc desc = { 0 };
> u8 major, minor;
> char *type_name;
> @@ -2201,7 +2213,7 @@ static int etm4_add_coresight_dev(struct etm4_init_arg *init_arg)
> if (!desc.name)
> return -ENOMEM;
>
> - etm4_set_default(&drvdata->config);
> + etm4_set_default(&drvdata->config, caps);
>
> if (etm4x_always_pm_save(dev, init_arg->csa))
> pm_save = true;
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> index 50ef2e957300f..d826033d52e24 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> @@ -443,7 +443,7 @@ static ssize_t mode_store(struct device *dev,
> config->vinst_ctrl &= ~TRCVICTLR_TRCERR;
>
> if (config->mode & (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER))
> - etm4_config_trace_mode(config);
> + etm4_config_trace_mode(config, caps);
>
> raw_spin_unlock(&drvdata->spinlock);
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h
> index 8c1c1364b1c44..f252da868b6de 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x.h
> +++ b/drivers/hwtracing/coresight/coresight-etm4x.h
> @@ -955,7 +955,6 @@ struct etmv4_caps {
> * @vmid_mask0: VM ID comparator mask for comparator 0-3.
> * @vmid_mask1: VM ID comparator mask for comparator 4-7.
> * @ext_inp: External input selection.
> - * @s_ex_level: Secure ELs where tracing is supported.
> */
> struct etmv4_config {
> u64 mode;
> @@ -998,7 +997,6 @@ struct etmv4_config {
> u32 vmid_mask0;
> u32 vmid_mask1;
> u32 ext_inp;
> - u8 s_ex_level;
> };
>
> /**
> @@ -1116,7 +1114,8 @@ enum etm_addr_ctxtype {
> };
>
> extern const struct attribute_group *coresight_etmv4_groups[];
> -void etm4_config_trace_mode(struct etmv4_config *config);
> +void etm4_config_trace_mode(struct etmv4_config *config,
> + const struct etmv4_caps *caps);
>
> u64 etm4x_sysreg_read(u32 offset, bool _relaxed, bool _64bit);
> void etm4x_sysreg_write(u64 val, u32 offset, bool _relaxed, bool _64bit);
>
next prev parent reply other threads:[~2026-09-18 14:06 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 11:34 [PATCH v11 0/9] fix several inconsistencies with sysfs configuration in etmX Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 1/9] coresight: etm4x: prohibit modifying ss_status and cntr_val while session is enabled Yeoreum Yun
2026-09-15 11:51 ` sashiko-bot
2026-09-15 13:26 ` Yeoreum Yun
2026-09-18 11:14 ` Mike Leach
2026-09-18 17:08 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 2/9] coresight: etm3x: prohibit modifying cntr_val and reset " Yeoreum Yun
2026-09-15 11:48 ` sashiko-bot
2026-09-15 13:30 ` Yeoreum Yun
2026-09-15 13:55 ` Yeoreum Yun
2026-09-18 11:15 ` Mike Leach
2026-09-15 11:34 ` [PATCH v11 3/9] coresight: etm4x: fix inconsistencies with sysfs configuration Yeoreum Yun
2026-09-15 11:53 ` sashiko-bot
2026-09-15 12:36 ` Yeoreum Yun
2026-09-18 13:49 ` Mike Leach
2026-09-18 17:00 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 4/9] coresight: etm3x: " Yeoreum Yun
2026-09-15 11:47 ` sashiko-bot
2026-09-15 13:42 ` Yeoreum Yun
2026-09-18 13:57 ` Mike Leach
2026-09-18 17:09 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 5/9] coresight: etm3x: remove redundant cpu online check on etm_enable_sysfs() Yeoreum Yun
2026-09-18 13:58 ` Mike Leach
2026-09-15 11:34 ` [PATCH v11 6/9] coresight: etm4x: introduce struct etm4_caps Yeoreum Yun
2026-09-18 14:01 ` Mike Leach
2026-09-15 11:34 ` [PATCH v11 7/9] coresight: etm4x: exclude ss_status from drvdata->config Yeoreum Yun
2026-09-15 11:49 ` sashiko-bot
2026-09-15 13:35 ` Yeoreum Yun
2026-09-18 14:04 ` Mike Leach
2026-09-18 17:13 ` Yeoreum Yun
2026-09-15 11:34 ` [PATCH v11 8/9] coresight: etm4x: remove s_ex_level from config Yeoreum Yun
2026-09-18 14:05 ` Mike Leach [this message]
2026-09-15 11:34 ` [PATCH v11 9/9] coresight: etm3x: introduce struct etm_caps Yeoreum Yun
2026-09-18 14:57 ` Mike Leach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=212419e5-a984-4f57-8a30-1d4558eb5c93@arm.com \
--to=mike.leach@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=coresight@lists.linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=james.clark@linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mathieu.poirier@linaro.org \
--cc=rostedt@goodmis.org \
--cc=suzuki.poulose@arm.com \
--cc=yeoreum.yun@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®