]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arm_mpam: Reset when feature configuration bit unset
authorBen Horgan <ben.horgan@arm.com>
Fri, 13 Mar 2026 14:45:39 +0000 (14:45 +0000)
committerJames Morse <james.morse@arm.com>
Fri, 27 Mar 2026 15:26:52 +0000 (15:26 +0000)
To indicate that the configuration, of the controls used by resctrl, in a
RIS need resetting to driver defaults the reset flags in mpam_config are
set. However, these flags are only ever set temporarily at RIS scope in
mpam_reset_ris() and hence mpam_cpu_online() will never reset these
controls to default. As the hardware reset is unknown this leads to unknown
configuration when the control values haven't been configured away from the
defaults.

Use the policy that an unset feature configuration bit means reset. In this
way the mpam_config in the component can encode that it should be in reset
state and mpam_reprogram_msc() will reset controls as needed.

Fixes: 09b89d2a72f3 ("arm_mpam: Allow configuration to be applied and restored during cpu online")
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: James Morse <james.morse@arm.com>
Tested-by: Gavin Shan <gshan@redhat.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Jesse Chick <jessechick@os.amperecomputing.com>
[ morse: Removed unused reset flags from config structure ]
Signed-off-by: James Morse <james.morse@arm.com>
drivers/resctrl/mpam_devices.c
drivers/resctrl/mpam_internal.h

index 0fd6590a9b5c0bc211ece2915d2bb5706df69960..ff861291bd4e1ca28ef532906b3f7ea18ee17085 100644 (file)
@@ -1364,17 +1364,15 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
                __mpam_intpart_sel(ris->ris_idx, partid, msc);
        }
 
-       if (mpam_has_feature(mpam_feat_cpor_part, rprops) &&
-           mpam_has_feature(mpam_feat_cpor_part, cfg)) {
-               if (cfg->reset_cpbm)
-                       mpam_reset_msc_bitmap(msc, MPAMCFG_CPBM, rprops->cpbm_wd);
-               else
+       if (mpam_has_feature(mpam_feat_cpor_part, rprops)) {
+               if (mpam_has_feature(mpam_feat_cpor_part, cfg))
                        mpam_write_partsel_reg(msc, CPBM, cfg->cpbm);
+               else
+                       mpam_reset_msc_bitmap(msc, MPAMCFG_CPBM, rprops->cpbm_wd);
        }
 
-       if (mpam_has_feature(mpam_feat_mbw_part, rprops) &&
-           mpam_has_feature(mpam_feat_mbw_part, cfg)) {
-               if (cfg->reset_mbw_pbm)
+       if (mpam_has_feature(mpam_feat_mbw_part, rprops)) {
+               if (mpam_has_feature(mpam_feat_mbw_part, cfg))
                        mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops->mbw_pbm_bits);
                else
                        mpam_write_partsel_reg(msc, MBW_PBM, cfg->mbw_pbm);
@@ -1384,16 +1382,14 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
            mpam_has_feature(mpam_feat_mbw_min, cfg))
                mpam_write_partsel_reg(msc, MBW_MIN, 0);
 
-       if (mpam_has_feature(mpam_feat_mbw_max, rprops) &&
-           mpam_has_feature(mpam_feat_mbw_max, cfg)) {
-               if (cfg->reset_mbw_max)
-                       mpam_write_partsel_reg(msc, MBW_MAX, MPAMCFG_MBW_MAX_MAX);
-               else
+       if (mpam_has_feature(mpam_feat_mbw_max, rprops)) {
+               if (mpam_has_feature(mpam_feat_mbw_max, cfg))
                        mpam_write_partsel_reg(msc, MBW_MAX, cfg->mbw_max);
+               else
+                       mpam_write_partsel_reg(msc, MBW_MAX, MPAMCFG_MBW_MAX_MAX);
        }
 
-       if (mpam_has_feature(mpam_feat_mbw_prop, rprops) &&
-           mpam_has_feature(mpam_feat_mbw_prop, cfg))
+       if (mpam_has_feature(mpam_feat_mbw_prop, rprops))
                mpam_write_partsel_reg(msc, MBW_PROP, 0);
 
        if (mpam_has_feature(mpam_feat_cmax_cmax, rprops))
@@ -1491,16 +1487,6 @@ static int mpam_save_mbwu_state(void *arg)
        return 0;
 }
 
-static void mpam_init_reset_cfg(struct mpam_config *reset_cfg)
-{
-       *reset_cfg = (struct mpam_config) {
-               .reset_cpbm = true,
-               .reset_mbw_pbm = true,
-               .reset_mbw_max = true,
-       };
-       bitmap_fill(reset_cfg->features, MPAM_FEATURE_LAST);
-}
-
 /*
  * Called via smp_call_on_cpu() to prevent migration, while still being
  * pre-emptible. Caller must hold mpam_srcu.
@@ -1508,14 +1494,12 @@ static void mpam_init_reset_cfg(struct mpam_config *reset_cfg)
 static int mpam_reset_ris(void *arg)
 {
        u16 partid, partid_max;
-       struct mpam_config reset_cfg;
+       struct mpam_config reset_cfg = {};
        struct mpam_msc_ris *ris = arg;
 
        if (ris->in_reset_state)
                return 0;
 
-       mpam_init_reset_cfg(&reset_cfg);
-
        spin_lock(&partid_max_lock);
        partid_max = mpam_partid_max;
        spin_unlock(&partid_max_lock);
index e8971842b124f23c39d76348057c384581e2a39b..7af762c98efc4a2caac12443bf5f9f08a226a60c 100644 (file)
@@ -266,10 +266,6 @@ struct mpam_config {
        u32     mbw_pbm;
        u16     mbw_max;
 
-       bool    reset_cpbm;
-       bool    reset_mbw_pbm;
-       bool    reset_mbw_max;
-
        struct mpam_garbage     garbage;
 };