Skip to content

Commit 9cd2b52

Browse files
author
James Morse
committed
arm_mpam: resctrl: Implement helpers to update configuration
resctrl has two helpers for updating the configuration. resctrl_arch_update_one() updates a single value, and is used by the software-controller to apply feedback to the bandwidth controls, it has to be called on one of the CPUs in the resctrl:domain. resctrl_arch_update_domains() copies multiple staged configurations, it can be called from anywhere. Both helpers should update any changes to the underlying hardware. Implement resctrl_arch_update_domains() to use resctrl_arch_update_one(). Neither need to be called on a specific CPU as the mpam driver will send IPIs as needed. Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Zeng Heng <zengheng4@huawei.com> Tested-by: Punit Agrawal <punit.agrawal@oss.qualcomm.com> Tested-by: Jesse Chick <jessechick@os.amperecomputing.com> Reviewed-by: Zeng Heng <zengheng4@huawei.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Co-developed-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
1 parent 02cc661 commit 9cd2b52

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

drivers/resctrl/mpam_resctrl.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,76 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
213213
}
214214
}
215215

216+
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
217+
u32 closid, enum resctrl_conf_type t, u32 cfg_val)
218+
{
219+
u32 partid;
220+
struct mpam_config cfg;
221+
struct mpam_props *cprops;
222+
struct mpam_resctrl_res *res;
223+
struct mpam_resctrl_dom *dom;
224+
225+
lockdep_assert_cpus_held();
226+
lockdep_assert_irqs_enabled();
227+
228+
/*
229+
* No need to check the CPU as mpam_apply_config() doesn't care, and
230+
* resctrl_arch_update_domains() relies on this.
231+
*/
232+
res = container_of(r, struct mpam_resctrl_res, resctrl_res);
233+
dom = container_of(d, struct mpam_resctrl_dom, resctrl_ctrl_dom);
234+
cprops = &res->class->props;
235+
236+
partid = resctrl_get_config_index(closid, t);
237+
if (!r->alloc_capable || partid >= resctrl_arch_get_num_closid(r)) {
238+
pr_debug("Not alloc capable or computed PARTID out of range\n");
239+
return -EINVAL;
240+
}
241+
242+
/*
243+
* Copy the current config to avoid clearing other resources when the
244+
* same component is exposed multiple times through resctrl.
245+
*/
246+
cfg = dom->ctrl_comp->cfg[partid];
247+
248+
switch (r->rid) {
249+
case RDT_RESOURCE_L2:
250+
case RDT_RESOURCE_L3:
251+
cfg.cpbm = cfg_val;
252+
mpam_set_feature(mpam_feat_cpor_part, &cfg);
253+
break;
254+
default:
255+
return -EINVAL;
256+
}
257+
258+
return mpam_apply_config(dom->ctrl_comp, partid, &cfg);
259+
}
260+
261+
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
262+
{
263+
int err;
264+
struct rdt_ctrl_domain *d;
265+
266+
lockdep_assert_cpus_held();
267+
lockdep_assert_irqs_enabled();
268+
269+
list_for_each_entry_rcu(d, &r->ctrl_domains, hdr.list) {
270+
for (enum resctrl_conf_type t = 0; t < CDP_NUM_TYPES; t++) {
271+
struct resctrl_staged_config *cfg = &d->staged_config[t];
272+
273+
if (!cfg->have_new_ctrl)
274+
continue;
275+
276+
err = resctrl_arch_update_one(r, d, closid, t,
277+
cfg->new_ctrl);
278+
if (err)
279+
return err;
280+
}
281+
}
282+
283+
return 0;
284+
}
285+
216286
void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
217287
{
218288
struct mpam_resctrl_res *res;

0 commit comments

Comments
 (0)