]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
arm_mpam: Improve check for whether or not NRDY is hardware managed
authorBen Horgan <ben.horgan@arm.com>
Thu, 7 May 2026 15:28:14 +0000 (16:28 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 14 May 2026 08:51:55 +0000 (09:51 +0100)
mpam_ris_hw_probe_csu_nrdy() sets and clears MSMON_CSU.NRDY and checks
whether it's configuration sticks. However, hardware isn't given a chance
to disagree. Based on rule LRTGP, in MPAM specification IHI0099 version
B.b, the hardware will set NRDY if it needs time to establish a count after
a configuration change.

Enable the monitor so that NRDY becomes relevant and change the
configuration after clearing NRDY to try and coax the hardware into setting
it.

Fixes: 8c90dc68a5de ("arm_mpam: Probe the hardware features resctrl supports")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: James Morse <james.morse@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
drivers/resctrl/mpam_devices.c

index 58e0c8970e8cf4e5eb60aaa15bec8aeade7d6e5c..e145828f3f736b138cde5665f66ee9cb48ec0add 100644 (file)
@@ -730,8 +730,7 @@ static void mpam_enable_quirks(struct mpam_msc *msc)
  */
 static bool mpam_ris_hw_probe_csu_nrdy(struct mpam_msc_ris *ris)
 {
-       u32 now;
-       u32 mon_sel;
+       u32 now, mon_sel, ctl_val;
        bool can_set, can_clear;
        struct mpam_msc *msc = ris->vmsc->msc;
 
@@ -742,11 +741,21 @@ static bool mpam_ris_hw_probe_csu_nrdy(struct mpam_msc_ris *ris)
                  FIELD_PREP(MSMON_CFG_MON_SEL_RIS, ris->ris_idx);
        mpam_write_monsel_reg(msc, CFG_MON_SEL, mon_sel);
 
+       /* Hardware might ignore nrdy if it's not enabled */
+       ctl_val = MSMON_CFG_CSU_CTL_TYPE_CSU;
+       ctl_val |= MSMON_CFG_x_CTL_MATCH_PARTID;
+       ctl_val |= MSMON_CFG_x_CTL_MATCH_PMG;
+       ctl_val |= MSMON_CFG_x_CTL_EN;
+       mpam_write_monsel_reg(msc, CFG_CSU_FLT, 0);
+       mpam_write_monsel_reg(msc, CFG_CSU_CTL, ctl_val);
+
        _mpam_write_monsel_reg(msc, MSMON_CSU, MSMON___NRDY);
        now = _mpam_read_monsel_reg(msc, MSMON_CSU);
        can_set = now & MSMON___NRDY;
 
        _mpam_write_monsel_reg(msc, MSMON_CSU, 0);
+       /* Configuration change to try and coax hardware into setting nrdy */
+       mpam_write_monsel_reg(msc, CFG_CSU_FLT, 0x1);
        now = _mpam_read_monsel_reg(msc, MSMON_CSU);
        can_clear = !(now & MSMON___NRDY);
        mpam_mon_sel_unlock(msc);