arm_mpam: propagate MSC access errors for MBWU counters

Allow the mpam_msc_read_mbwu_l() function to return an error, and
propagate errors from the lower level up. This also changes the users
of this function.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Tested-by: Gavin Shan <gshan@redhat.com> # on NVIDIA Grace Hopper
[morse: Fixed merge conflicts in mpam_save_mbwu_state() and __ris_msmon_read()]
Signed-off-by: James Morse <james.morse@arm.com>
This commit is contained in:
Andre Przywara 2026-10-02 16:48:37 +01:00 committed by James Morse
parent 0db1715e4c
commit 7ec57e8b75

View File

@ -1139,8 +1139,9 @@ struct mon_read {
bool waited_timeout;
};
static u64 mpam_msc_read_mbwu_l(struct mpam_msc *msc)
static int mpam_msc_read_mbwu_l(struct mpam_msc *msc, u64 *res)
{
int ret;
int retry = 3;
u32 mbwu_l_low;
u32 mbwu_l_high1, mbwu_l_high2;
@ -1150,20 +1151,30 @@ static u64 mpam_msc_read_mbwu_l(struct mpam_msc *msc)
WARN_ON_ONCE((MSMON_MBWU_L + sizeof(u64)) > msc->mapped_hwpage_sz);
WARN_ON_ONCE(!cpumask_test_cpu(smp_processor_id(), &msc->accessibility));
__mpam_read_reg(msc, MSMON_MBWU_L + 4, &mbwu_l_high2);
ret = __mpam_read_reg(msc, MSMON_MBWU_L + 4, &mbwu_l_high2);
if (ret)
return ret;
do {
mbwu_l_high1 = mbwu_l_high2;
__mpam_read_reg(msc, MSMON_MBWU_L, &mbwu_l_low);
__mpam_read_reg(msc, MSMON_MBWU_L + 4, &mbwu_l_high2);
ret = __mpam_read_reg(msc, MSMON_MBWU_L, &mbwu_l_low);
if (ret)
return ret;
ret = __mpam_read_reg(msc, MSMON_MBWU_L + 4, &mbwu_l_high2);
if (ret)
return ret;
retry--;
} while (mbwu_l_high1 != mbwu_l_high2 && retry > 0);
if (mbwu_l_high1 == mbwu_l_high2)
return ((u64)mbwu_l_high1 << 32) | mbwu_l_low;
if (mbwu_l_high1 == mbwu_l_high2) {
*res = ((u64)mbwu_l_high1 << 32) | mbwu_l_low;
} else {
pr_warn("Failed to read a stable value\n");
*res = MSMON___L_NRDY;
}
pr_warn("Failed to read a stable value\n");
return MSMON___L_NRDY;
return 0;
}
static void mpam_msc_zero_mbwu_l(struct mpam_msc *msc)
@ -1381,7 +1392,9 @@ static void __ris_msmon_read_locked(struct mon_read *m)
case mpam_feat_msmon_mbwu_44counter:
case mpam_feat_msmon_mbwu_63counter:
if (m->type != mpam_feat_msmon_mbwu_31counter) {
now = mpam_msc_read_mbwu_l(msc);
m->err = mpam_msc_read_mbwu_l(msc, &now);
if (m->err)
return;
nrdy = now & MSMON___L_NRDY;
if (m->type == mpam_feat_msmon_mbwu_63counter)