hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/9840 ------------------ 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: 1. For MSCs supporting narrow PARTID, establish the reqPARTID to intPARTID mapping. 2. For MSCs without narrow PARTID support, synchronize the configuration to new PARTIDs directly. Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_devices.c | 29 ++++++++++++++++++++++++--- drivers/platform/mpam/mpam_internal.h | 2 ++ drivers/platform/mpam/mpam_resctrl.c | 5 +++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index a190be18fff8f..7ebb9e5ebf578 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -1371,6 +1371,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, u16 cmax = MPAMCFG_CMAX_CMAX; struct mpam_msc *msc = ris->msc; u16 bwa_fract = MPAMCFG_MBW_MAX_MAX; + u16 intpartid = req2intpartid(partid); struct mpam_props *rprops = &ris->props; spin_lock(&msc->part_sel_lock); @@ -1378,8 +1379,17 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, if (mpam_has_feature(mpam_feat_partid_nrw, rprops)) { mpam_write_partsel_reg(msc, INTPARTID, - (MPAMCFG_PART_SEL_INTERNAL | partid)); - __mpam_intpart_sel(ris->ris_idx, partid, msc); + MPAMCFG_INTPARTID_INTERNAL | + intpartid); + + /* + * Mapping from reqpartid to intpartid already established. + * Sub-monitoring groups share the parent's configuration. + */ + if (partid != intpartid) + goto out; + + __mpam_intpart_sel(ris->ris_idx, intpartid, msc); } if (mpam_has_feature(mpam_feat_cpor_part, rprops)) { @@ -1463,6 +1473,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, mpam_has_feature(mpam_feat_dspri_part, rprops)) mpam_write_partsel_reg(msc, PRI, pri_val); +out: spin_unlock(&msc->part_sel_lock); } @@ -2570,9 +2581,21 @@ struct mpam_write_config_arg { 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_closid(); + req_idx++) { + reqpartid = req_idx * closid_num + c->partid; + + mpam_reprogram_ris_partid(c->ris, reqpartid, + &c->comp->cfg[c->partid]); + } return 0; } diff --git a/drivers/platform/mpam/mpam_internal.h b/drivers/platform/mpam/mpam_internal.h index e4809f2242ec0..adef0aae7cff0 100644 --- a/drivers/platform/mpam/mpam_internal.h +++ b/drivers/platform/mpam/mpam_internal.h @@ -594,4 +594,6 @@ bool mpam_cpbm_hisi_check_invalid(struct rdt_resource *r, unsigned long val); int mpam_resctrl_prepare_offline(void); +u32 get_num_reqpartid_per_closid(void); + #endif /* MPAM_INTERNAL_H */ diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index a2b0267502ef9..7786dc1c087af 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -156,6 +156,11 @@ static u32 get_num_reqpartid(void) return mpam_partid_max + 1; } +u32 get_num_reqpartid_per_closid(void) +{ + return get_num_reqpartid() / resctrl_arch_get_num_closid(NULL); +} + u32 resctrl_arch_system_num_rmid_idx(void) { u8 closid_shift = fls(mpam_pmg_max); -- 2.43.0