mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] arm_mpam: Do not access MPAMF_ESR on MSCs that do not have it
@ 2026-10-19 12:46 Ping Li
  2026-10-19 16:18 ` Ben Horgan
  0 siblings, 1 reply; 3+ messages in thread
From: Ping Li @ 2026-10-19 12:46 UTC (permalink / raw)
  To: james.morse, ben.horgan
  Cc: linux-kernel, linux-arm-kernel, reinette.chatre, fenghuay, Ping Li

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-20  2:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-19 12:46 [PATCH] arm_mpam: Do not access MPAMF_ESR on MSCs that do not have it Ping Li
2026-10-19 16:18 ` Ben Horgan
2026-10-20  2:57   ` Ping Li

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®