]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
arm_mpam: resctrl: Add resctrl_arch_get_config()
authorJames Morse <james.morse@arm.com>
Fri, 13 Mar 2026 14:45:54 +0000 (14:45 +0000)
committerJames Morse <james.morse@arm.com>
Fri, 27 Mar 2026 15:29:48 +0000 (15:29 +0000)
Implement resctrl_arch_get_config() by testing the live configuration for a
CPOR bitmap. For any other configuration type return the default.

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>
drivers/resctrl/mpam_resctrl.c

index b2217d11561d8bbba405c37d3f734ecbd658f00f..3af57b6f2c1b51738e66aa8af2acc04ddb08f663 100644 (file)
@@ -170,6 +170,49 @@ static int mpam_resctrl_pick_domain_id(int cpu, struct mpam_component *comp)
        return comp->comp_id;
 }
 
+u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
+                           u32 closid, enum resctrl_conf_type type)
+{
+       u32 partid;
+       struct mpam_config *cfg;
+       struct mpam_props *cprops;
+       struct mpam_resctrl_res *res;
+       struct mpam_resctrl_dom *dom;
+       enum mpam_device_features configured_by;
+
+       lockdep_assert_cpus_held();
+
+       if (!mpam_is_enabled())
+               return resctrl_get_default_ctrl(r);
+
+       res = container_of(r, struct mpam_resctrl_res, resctrl_res);
+       dom = container_of(d, struct mpam_resctrl_dom, resctrl_ctrl_dom);
+       cprops = &res->class->props;
+
+       partid = resctrl_get_config_index(closid, type);
+       cfg = &dom->ctrl_comp->cfg[partid];
+
+       switch (r->rid) {
+       case RDT_RESOURCE_L2:
+       case RDT_RESOURCE_L3:
+               configured_by = mpam_feat_cpor_part;
+               break;
+       default:
+               return resctrl_get_default_ctrl(r);
+       }
+
+       if (!r->alloc_capable || partid >= resctrl_arch_get_num_closid(r) ||
+           !mpam_has_feature(configured_by, cfg))
+               return resctrl_get_default_ctrl(r);
+
+       switch (configured_by) {
+       case mpam_feat_cpor_part:
+               return cfg->cpbm;
+       default:
+               return resctrl_get_default_ctrl(r);
+       }
+}
+
 void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
 {
        struct mpam_resctrl_res *res;