Commit ccad6001 authored by Ben Horgan's avatar Ben Horgan Committed by Catalin Marinas
Browse files

arm_mpam: Improve check for whether or not NRDY is hardware managed



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: 8c90dc68 ("arm_mpam: Probe the hardware features resctrl supports")
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarBen Horgan <ben.horgan@arm.com>
Reviewed-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 4387970b
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -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);