[RFC PATCH 04/13] arm_mpam: Record PARTID narrowing capacity per MSC

Yunhui Cui cuiyunhui at bytedance.com
Sun Nov 29 18:29:20 PST 2026


PARTID_NRW_IDR reports the number of internal PARTIDs provided by an MSC
and is not selected by RIS, so every RIS in an MSC sees the same
capacity. Record the internal PARTID count when the first usable
narrowing RIS is probed and use it for the existing request PARTID limit
instead of reading the same register for each RIS. No functional change
is intended.

Signed-off-by: Yunhui Cui <cuiyunhui at bytedance.com>
---
 drivers/resctrl/mpam_devices.c  | 25 +++++++++++--------------
 drivers/resctrl/mpam_internal.h |  1 +
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 27abf60f4d675..e2791d5368765 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1131,25 +1131,22 @@ static int mpam_ris_hw_probe(struct mpam_msc_ris *ris)
 		}
 	}
 
-	/*
-	 * RIS with PARTID narrowing don't have enough storage for one
-	 * configuration per PARTID. If these are in a class we could use,
-	 * reduce the supported partid_max to match the number of intpartid.
-	 * If the class is unknown, just ignore it.
-	 */
+	/* Cache the MSC-wide limit without probing unused resource classes. */
 	if (FIELD_GET(MPAMF_IDR_HAS_PARTID_NRW, ris->idr) &&
 	    class->type != MPAM_CLASS_UNKNOWN) {
-		u16 partid_max;
 		u32 nrwidr;
 
-		err = mpam_read_partsel_reg(msc, PARTID_NRW_IDR, &nrwidr);
-		if (err)
-			return err;
-
-		partid_max = FIELD_GET(MPAMF_PARTID_NRW_IDR_INTPARTID_MAX, nrwidr);
-
+		if (!msc->nr_intpartids) {
+			err = mpam_read_partsel_reg(msc, PARTID_NRW_IDR, &nrwidr);
+			if (err)
+				return err;
+			msc->nr_intpartids =
+				FIELD_GET(MPAMF_PARTID_NRW_IDR_INTPARTID_MAX,
+					  nrwidr) + 1;
+		}
 		mpam_set_feature(mpam_feat_partid_nrw, props);
-		msc->partid_max = min(msc->partid_max, partid_max);
+		msc->partid_max = min_t(u32, msc->partid_max,
+					msc->nr_intpartids - 1);
 	}
 
 	return 0;
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 1f86cc158100b..90430bd208ee8 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -94,6 +94,7 @@ struct mpam_msc {
 	struct mutex		probe_lock;
 	bool			probed;
 	u16			partid_max;
+	u32			nr_intpartids;
 	u8			pmg_max;
 	unsigned long		ris_idxs;
 	u32			ris_max;
-- 
2.39.2 (Apple Git-143)




More information about the linux-riscv mailing list