[PATCH v8 next 05/10] arm_mpam: Propagate control group config to sub-monitoring groups

From: Zeng Heng

Date: Mon Apr 13 2026 - 04:56:35 EST


With the Narrow-PARTID feature, each control group is assigned multiple
(req)PARTIDs to expand monitoring capacity. When a control group's
configuration is updated, all associated sub-monitoring groups (each
identified by a unique reqPARTID) should be synchronized.

In __write_config(), iterate over all reqPARTIDs belonging to the
control group and propagate the configuration to each sub-monitoring
group:

* For MSCs supporting Narrow-PARTID, establish the reqPARTID to
intPARTID mapping.
* For MSCs without Narrow-PARTID support, synchronize the configuration
to new PARTIDs directly.

Signed-off-by: Zeng Heng <zengheng4@xxxxxxxxxx>
---
drivers/resctrl/mpam_devices.c | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index cf067bf5092e..8fbc8f9f9688 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1547,6 +1547,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
{
u32 pri_val = 0;
u16 cmax = MPAMCFG_CMAX_CMAX;
+ u16 intpartid = req2intpartid(partid);
struct mpam_msc *msc = ris->vmsc->msc;
struct mpam_props *rprops = &ris->props;
u16 dspri = GENMASK(rprops->dspri_wd, 0);
@@ -1556,15 +1557,17 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
__mpam_part_sel(ris->ris_idx, partid, msc);

if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) {
- /* Update the intpartid mapping */
mpam_write_partsel_reg(msc, INTPARTID,
- MPAMCFG_INTPARTID_INTERNAL | partid);
+ MPAMCFG_INTPARTID_INTERNAL | intpartid);

/*
- * Then switch to the 'internal' partid to update the
- * configuration.
+ * Mapping from reqpartid to intpartid already established.
+ * Sub-monitoring groups share the parent's configuration.
*/
- __mpam_intpart_sel(ris->ris_idx, partid, msc);
+ if (partid != intpartid)
+ goto out;
+
+ __mpam_intpart_sel(ris->ris_idx, intpartid, msc);
}

if (mpam_has_feature(mpam_feat_cpor_part, rprops)) {
@@ -1631,6 +1634,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,

mpam_quirk_post_config_change(ris, partid, cfg);

+out:
mutex_unlock(&msc->part_sel_lock);
}

@@ -1755,11 +1759,28 @@ struct mpam_write_config_arg {
u16 partid;
};

+static u32 get_num_reqpartid_per_intpartid(void)
+{
+ return (mpam_partid_max + 1) / (mpam_intpartid_max + 1);
+}
+
static int __write_config(void *arg)
{
+ int closid_num = resctrl_arch_get_num_closid(NULL);
struct mpam_write_config_arg *c = arg;
+ u32 reqpartid, req_idx;

- mpam_reprogram_ris_partid(c->ris, c->partid, &c->comp->cfg[c->partid]);
+ /* c->partid should be within the range of intPARTIDs */
+ WARN_ON_ONCE(c->partid >= closid_num);
+
+ /* Synchronize the configuration to each sub-monitoring group. */
+ for (req_idx = 0; req_idx < get_num_reqpartid_per_intpartid();
+ req_idx++) {
+ reqpartid = req_idx * closid_num + c->partid;
+
+ mpam_reprogram_ris_partid(c->ris, reqpartid,
+ &c->comp->cfg[c->partid]);
+ }

return 0;
}
--
2.25.1