From: Ping Li <leeonion.muyu@gmail.com>
To: james.morse@arm.com, ben.horgan@arm.com
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, reinette.chatre@intel.com,
fenghuay@nvidia.com, Ping Li <leeonion.muyu@gmail.com>
Subject: [PATCH] arm_mpam: Do not access MPAMF_ESR on MSCs that do not have it
Date: Mon, 19 Oct 2026 20:46:12 +0800 [thread overview]
Message-ID: <20261019124612.134035-1-leeonion.muyu@gmail.com> (raw)
mpam_msc_clear_esr() and mpam_msc_read_esr() read MPAMF_ESR
unconditionally, but the MPAM architecture only provides this
register when MPAMF_IDR.HAS_ESR is set. On an implementation without
ESR these accesses reach unimplemented register space.
Read HAS_ESR from the IDR during probe, make clear_esr() a no-op on
such MSCs, and have read_esr() return -ENODEV as the register
cannot be read.
Signed-off-by: Ping Li <leeonion.muyu@gmail.com>
---
drivers/resctrl/mpam_devices.c | 7 +++++++
drivers/resctrl/mpam_internal.h | 1 +
2 files changed, 8 insertions(+)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 48adc49b833c..a473b2872183 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -388,6 +388,9 @@ static int mpam_msc_clear_esr(struct mpam_msc *msc)
u32 esr_low;
int ret;
+ if (!msc->has_esr)
+ return 0;
+
ret = __mpam_read_reg(msc, MPAMF_ESR, &esr_low);
if (ret)
return ret;
@@ -415,6 +418,9 @@ static int mpam_msc_read_esr(struct mpam_msc *msc, u64 *res)
u32 esr_high, esr_low;
int ret;
+ if (!msc->has_esr)
+ return -ENODEV;
+
ret = __mpam_read_reg(msc, MPAMF_ESR, &esr_low);
if (ret)
return ret;
@@ -1205,6 +1211,7 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
pmg_max = FIELD_GET(MPAMF_IDR_PMG_MAX, idr);
msc->partid_max = min(msc->partid_max, partid_max);
msc->pmg_max = min(msc->pmg_max, pmg_max);
+ msc->has_esr = FIELD_GET(MPAMF_IDR_HAS_ESR, idr);
msc->has_extd_esr = FIELD_GET(MPAMF_IDR_HAS_EXTD_ESR, idr);
scoped_guard(mutex, &mpam_list_lock) {
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 1f86cc158100..b648c006e102 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -80,6 +80,7 @@ struct mpam_msc {
int fb_id;
u32 nrdy_usec;
cpumask_t accessibility;
+ bool has_esr;
bool has_extd_esr;
int reenable_error_ppi;
base-commit: 8ea457f746d915d55f78b43d33b1cd618f3d93ad
--
2.34.1
next reply other threads:[~2026-10-19 12:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 12:46 Ping Li [this message]
2026-10-19 16:18 ` Ben Horgan
2026-10-20 2:57 ` Ping Li
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=20261019124612.134035-1-leeonion.muyu@gmail.com \
--to=leeonion.muyu@gmail.com \
--cc=ben.horgan@arm.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=reinette.chatre@intel.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®