From: Leo Yan <leo.yan@arm.com>
To: Amir Ayupov <aaupov@fb.com>
Cc: James Clark <james.clark@linaro.org>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jonathan Corbet <corbet@lwn.net>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Randy Dunlap <rdunlap@infradead.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Daniel Pereira <danielmaraboo@gmail.com>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/4] coresight: etm4x: Skip features requiring unavailable events
Date: Mon, 30 Nov 2026 15:51:51 +0000 [thread overview]
Message-ID: <20261130155151.GM861809@e132581.arm.com> (raw)
In-Reply-To: <af7838ccf521e6317dbc3ef706dd4b8c979740fa.1795196854.git.aaupov@fb.com>
On Fri, Nov 20, 2026 at 10:54:32AM -0800, Amir Ayupov wrote:
[...]
> +static int etm4_cfg_check_eventctl0_support(const struct cscfg_regval_desc *reg_desc,
> + unsigned int nr_event)
> +{
> + u32 requested;
> +
> + if (reg_desc->offset != TRCEVENTCTL0R)
> + return 0;
> +
> + /* Parameters can change after loading, so check all writable fields. */
> + if (reg_desc->type & CS_CFG_REG_TYPE_VAL_PARAM)
> + requested = reg_desc->type & CS_CFG_REG_TYPE_VAL_MASK ?
> + reg_desc->mask32 : U32_MAX;
> + else
> + requested = reg_desc->type & CS_CFG_REG_TYPE_VAL_MASK ?
> + reg_desc->val32 & reg_desc->mask32 : reg_desc->val32;
> +
> + /* Four events use the full register: do not shift a u32 by 32. */
> + if (nr_event < 4 && (requested >> (8 * nr_event)))
> + return -EOPNOTSUPP;
> + return 0;
> +}
> +
> /**
> * etm4_cfg_load_feature - load a feature into a device instance.
> *
> @@ -149,6 +171,7 @@ static int etm4_cfg_load_feature(struct coresight_device *csdev,
> struct device *dev = csdev->dev.parent;
> struct etmv4_drvdata *drvdata = dev_get_drvdata(dev);
> const struct cscfg_feature_desc *feat_desc = feat_csdev->feat_desc;
> + const struct cscfg_regval_desc *reg_desc;
> u32 offset;
> int i = 0, err = 0;
>
> @@ -162,12 +185,28 @@ static int etm4_cfg_load_feature(struct coresight_device *csdev,
> */
> feat_csdev->drv_spinlock = NULL;
>
> - /* process the register descriptions */
> - for (i = 0; i < feat_csdev->nr_regs && !err; i++) {
> - offset = feat_desc->regs_desc[i].offset;
> + /* Validate every description before deciding whether to skip a device. */
> + for (i = 0; i < feat_csdev->nr_regs; i++) {
> + reg_desc = &feat_desc->regs_desc[i];
> + offset = reg_desc->offset;
> + if ((reg_desc->type & CS_CFG_REG_TYPE_VAL_PARAM) &&
> + reg_desc->param_idx >= (u32)feat_csdev->nr_params)
> + return -EINVAL;
> + if (offset == TRCEVENTCTL0R &&
> + (reg_desc->type & CS_CFG_REG_TYPE_VAL_64BIT))
> + return -EINVAL;
> err = etm4_cfg_map_reg_offset(drvdata, &feat_csdev->regs_csdev[i], offset);
> + if (err)
> + return err;
> }
> - return err;
> +
> + for (i = 0; i < feat_csdev->nr_regs; i++) {
> + err = etm4_cfg_check_eventctl0_support(&feat_desc->regs_desc[i],
> + drvdata->caps.nr_event);
> + if (err)
> + return err;
> + }
> + return 0;
> }
Validating EVENTCTL0 here seems redundant, as built-in configs use
fixed values.
For dynamically loaded configs, I still think the ETMv4 driver should
handle resource allocation, validation and register programming in
dedicated functions, such as etm4_pulse_config(). This would avoid the
need for the validation above, which checks EVENTCTL0 alone and is
insufficient for other configs.
Since this patch should not depend on refactoring, I'm happy for it to
be merged:
Reviewed-by: Leo Yan <leo.yan@arm.com>
next prev parent reply other threads:[~2026-11-30 15:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 18:54 [PATCH v6 0/4] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 1/4] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-11-20 18:54 ` [PATCH v6 2/4] coresight: etm4x: Skip features requiring unavailable events Amir Ayupov
2026-11-30 15:51 ` Leo Yan [this message]
2026-11-20 18:54 ` [PATCH v6 3/4] coresight: perf: Filter sources lacking the selected configuration Amir Ayupov
2026-11-30 17:47 ` Leo Yan
2026-11-20 18:54 ` [PATCH v6 4/4] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
2026-11-30 17:55 ` Leo Yan
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=20261130155151.GM861809@e132581.arm.com \
--to=leo.yan@arm.com \
--cc=aaupov@fb.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=corbet@lwn.net \
--cc=coresight@lists.linaro.org \
--cc=danielmaraboo@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.clark@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.poirier@linaro.org \
--cc=mike.leach@arm.com \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/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®