[PATCH v4 1/3] arm_mpam: resctrl: Leave CDP off when there are too few PARTIDs
From: Jinjie Ruan
Date: Wed Nov 11 2026 - 03:18:12 EST
Enabling CDP requires at least 2 PARTIDs. If there are too few PARTIDs,
resctrl_arch_set_cdp_enabled() returns -EINVAL, but only after it has
recorded CDP as enabled, halved the monitor count and turned off the
mbw_max MBA control. resctrl then believes CDP is off, which leaves the
two sides out of step and the halved monitor count and the missing MBA
control are not undone.
Check the PARTID limit before anything is changed so a failed enable has
no effect.
Fixes: 6789fb99282c ("arm_mpam: resctrl: Add CDP emulation")
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx> # 7.1+
---
drivers/resctrl/mpam_resctrl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 563ca99a581d..573617ba09df 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -219,6 +219,9 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
if (enable)
pr_warn("CDP is an expert feature and may cause MPAM to malfunction.\n");
+ if (enable && mpam_partid_max < 1)
+ return -EINVAL;
+
/*
* resctrl_arch_set_cdp_enabled() is only called with enable set to
* false on error and unmount.
@@ -248,9 +251,6 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
mpam_resctrl_controls[RDT_RESOURCE_MBA].resctrl_res.alloc_capable = true;
if (enable) {
- if (mpam_partid_max < 1)
- return -EINVAL;
-
partid_d = resctrl_get_config_index(RESCTRL_RESERVED_CLOSID, CDP_DATA);
partid_i = resctrl_get_config_index(RESCTRL_RESERVED_CLOSID, CDP_CODE);
}
--
2.34.1