hulk inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/8420 ------------------ Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_devices.c | 25 +++++++++++++++++++++---- drivers/platform/mpam/mpam_internal.h | 2 +- drivers/platform/mpam/mpam_resctrl.c | 17 +++++++++++------ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index 283a947720dd..fb52e3104006 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -2574,6 +2574,7 @@ struct mpam_write_config_arg { struct mpam_msc_ris *ris; struct mpam_component *comp; u16 partid; + bool sync; }; static int __write_config(void *arg) @@ -2582,9 +2583,21 @@ static int __write_config(void *arg) struct mpam_write_config_arg *c = arg; u32 reqpartid; + if (c->sync) { + /* This partid should be in the range of reqPARTIDs */ + WARN_ON_ONCE(c->partid < closid_num); + + mpam_reprogram_ris_partid(c->ris, c->partid, + &c->comp->cfg[req2intpartid(c->partid)]); + return 0; + } + /* This partid should be in the range of intPARTIDs */ WARN_ON_ONCE(c->partid >= closid_num); + mpam_reprogram_ris_partid(c->ris, c->partid, + &c->comp->cfg[c->partid]); + /* Synchronize the configuration to each sub-monitoring group. */ for (reqpartid = closid_num; reqpartid < get_num_reqpartid(); reqpartid++) { @@ -2599,7 +2612,7 @@ static int __write_config(void *arg) /* TODO: split into write_config/sync_config */ /* TODO: add config_dirty bitmap to drive sync_config */ int mpam_apply_config(struct mpam_component *comp, u16 partid, - struct mpam_config *cfg) + struct mpam_config *cfg, bool sync) { struct mpam_write_config_arg arg; struct mpam_msc_ris *ris; @@ -2607,12 +2620,16 @@ int mpam_apply_config(struct mpam_component *comp, u16 partid, lockdep_assert_cpus_held(); - if (!memcmp(&comp->cfg[partid], cfg, sizeof(*cfg))) - return 0; + if (!sync) { + if (!memcmp(&comp->cfg[partid], cfg, sizeof(*cfg))) + return 0; + + comp->cfg[partid] = *cfg; + } - comp->cfg[partid] = *cfg; arg.comp = comp; arg.partid = partid; + arg.sync = sync; idx = srcu_read_lock(&mpam_srcu); list_for_each_entry_rcu(ris, &comp->ris, comp_list) { diff --git a/drivers/platform/mpam/mpam_internal.h b/drivers/platform/mpam/mpam_internal.h index 3e9f150e358a..717b0b240582 100644 --- a/drivers/platform/mpam/mpam_internal.h +++ b/drivers/platform/mpam/mpam_internal.h @@ -314,7 +314,7 @@ void mpam_disable(struct work_struct *work); void mpam_reset_class(struct mpam_class *class); int mpam_apply_config(struct mpam_component *comp, u16 partid, - struct mpam_config *cfg); + struct mpam_config *cfg, bool force); int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx, enum mpam_device_features, u64 *val); diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 16c1a036d51c..661d5f26e6c1 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -1300,7 +1300,7 @@ static int check_narrow_mkdir_limit(u32 closid) return 0; } -static int mpam_sync_config(u32 intpartid) +static int mpam_sync_config(u32 reqpartid) { struct mpam_component *comp; struct mpam_class *class; @@ -1308,8 +1308,7 @@ static int mpam_sync_config(u32 intpartid) list_for_each_entry(class, &mpam_classes, classes_list) { list_for_each_entry(comp, &class->components, class_list) { - err = mpam_apply_config(comp, intpartid, - &comp->cfg[intpartid], true); + err = mpam_apply_config(comp, reqpartid, NULL, true); if (err) return err; } @@ -1331,10 +1330,16 @@ int resctrl_arch_expand_rmid(u32 closid) if (reqpartid_map[i] >= resctrl_arch_get_num_closid(NULL)) { if (cdp_enabled) { reqpartid_map[i] = resctrl_get_config_index(closid, CDP_DATA); + mpam_sync_config(i); + reqpartid_map[i + 1] = resctrl_get_config_index(closid, CDP_CODE); + mpam_sync_config(i + 1); + } else { reqpartid_map[i] = resctrl_get_config_index(closid, CDP_NONE); + mpam_sync_config(i); } + update_rmid_entries_for_reqpartid(i); return i; } @@ -1668,15 +1673,15 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, */ if (mpam_resctrl_hide_cdp(r->rid)) { partid = resctrl_get_config_index(closid, CDP_CODE); - err = mpam_apply_config(dom->comp, partid, &cfg); + err = mpam_apply_config(dom->comp, partid, &cfg, false); if (err) return err; partid = resctrl_get_config_index(closid, CDP_DATA); - return mpam_apply_config(dom->comp, partid, &cfg); + return mpam_apply_config(dom->comp, partid, &cfg, false); } else { - return mpam_apply_config(dom->comp, partid, &cfg); + return mpam_apply_config(dom->comp, partid, &cfg, false); } } -- 2.25.1