[RFC PATCH 09/13] arm_mpam: Separate request and internal PARTID limits
From: Yunhui Cui
Date: Sun Nov 29 2026 - 21:31:30 EST
PARTID narrowing allows an MSC to accept more request PARTIDs than it
has internal configuration entries. Treat the request and internal
PARTID limits separately: use the full request PARTID range for
components using narrowing, while direct-index components remain limited
by their internal entry count because the request PARTID directly
selects the configuration entry.
Signed-off-by: Yunhui Cui <cuiyunhui@xxxxxxxxxxxxx>
---
drivers/resctrl/mpam_devices.c | 46 ++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index d0b8f4c3f0c2c..4925b61be162c 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1149,8 +1149,6 @@ static int mpam_ris_hw_probe(struct mpam_msc_ris *ris)
nrwidr) + 1;
}
mpam_set_feature(mpam_feat_partid_nrw, props);
- msc->partid_max = min_t(u32, msc->partid_max,
- msc->nr_intpartids - 1);
}
return 0;
@@ -2952,6 +2950,24 @@ static bool mpam_component_all_mscs_narrow(struct mpam_component *comp)
return found;
}
+static u16 mpam_component_safe_partid_max(struct mpam_component *comp,
+ u16 partid_max)
+{
+ struct mpam_vmsc *vmsc;
+
+ if (comp->uses_partid_narrowing)
+ return partid_max;
+
+ list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
+ struct mpam_msc *msc = vmsc->msc;
+
+ if (msc->nr_intpartids)
+ partid_max = min_t(u32, partid_max, msc->nr_intpartids - 1);
+ }
+
+ return partid_max;
+}
+
bool mpam_component_uses_partid_narrowing(struct mpam_component *comp)
{
return comp->uses_partid_narrowing;
@@ -3300,9 +3316,12 @@ static void mpam_enable_set_partid_narrowing(struct list_head *classes)
{
struct mpam_component *comp;
struct mpam_class *class;
+ u16 partid_max;
bool changed;
lockdep_assert_held(&mpam_list_lock);
+ guard(spinlock)(&partid_max_lock);
+ partid_max = mpam_partid_max;
partid_narrowing_enabled = false;
list_for_each_entry(class, classes, classes_list) {
@@ -3334,6 +3353,16 @@ static void mpam_enable_set_partid_narrowing(struct list_head *classes)
list_for_each_entry(comp, &class->components, class_list)
partid_narrowing_enabled |= comp->uses_partid_narrowing;
}
+
+ list_for_each_entry(class, classes, classes_list) {
+ if (class->type == MPAM_CLASS_UNKNOWN)
+ continue;
+ list_for_each_entry(comp, &class->components, class_list)
+ partid_max = mpam_component_safe_partid_max(comp,
+ partid_max);
+ }
+
+ mpam_partid_max = partid_max;
}
static int mpam_init_msc_partid_mappings(struct mpam_msc *msc)
@@ -3783,14 +3812,6 @@ static void mpam_enable_once(void)
{
int err;
- /*
- * Once the cpuhp callbacks have been changed, mpam_partid_max can no
- * longer change.
- */
- spin_lock(&partid_max_lock);
- partid_max_published = true;
- spin_unlock(&partid_max_lock);
-
/*
* If all the MSC have been probed, enabling the IRQs happens next.
* That involves cross-calling to a CPU that can reach the MSC, and
@@ -3802,6 +3823,11 @@ static void mpam_enable_once(void)
mpam_enable_merge_features(&mpam_classes);
mpam_enable_set_partid_narrowing(&mpam_classes);
+ /* All request and internal PARTID limits are now known. */
+ spin_lock(&partid_max_lock);
+ partid_max_published = true;
+ spin_unlock(&partid_max_lock);
+
err = mpam_register_irqs();
if (err) {
pr_warn("Failed to register irqs: %d\n", err);
--
2.39.2 (Apple Git-143)