Commit 4f096084 authored by Zeng Heng's avatar Zeng Heng
Browse files

arm64/mpam: Add write memory barrier to guarantee monitor results

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8T2RT



--------------------------------

Before configure the PARTID of monitor instances, make sure CFG_MON_SEL
register has already selected the target instance self.

By the same reason, ensure the PARTID has been configured properly before
reading counter result of the monitor instance.

Fixes: bb66b4d1 ("arm_mpam: Add mpam_msmon_read() to read monitor value")
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent 5d0fa28f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -942,6 +942,9 @@ static void __ris_msmon_read(void *arg)
		  FIELD_PREP(MSMON_CFG_MON_SEL_RIS, ris->ris_idx);
	mpam_write_monsel_reg(msc, CFG_MON_SEL, mon_sel);

	/* Selects a monitor instance to configure PARTID. */
	wmb();

	if (m->type == mpam_feat_msmon_mbwu) {
		mbwu_state = &ris->mbwu_state[ctx->mon];
		if (mbwu_state) {
@@ -962,6 +965,12 @@ static void __ris_msmon_read(void *arg)
	if (config_mismatch || reset_on_next_read)
		write_msmon_ctl_flt_vals(m, ctl_val, flt_val);

	/*
	 * Selects the monitor instance associated to the specified PARTID
	 * to read counter value.
	 */
	wmb();

	switch (m->type) {
	case mpam_feat_msmon_csu:
		now = mpam_read_monsel_reg(msc, CSU);