Commit 74c0a1ab authored by Zeng Heng's avatar Zeng Heng
Browse files

arm64/mpam: Add judgment to distinguish MSMON_MBWU_CAPTURE definition

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



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

Because MSMON_MBWU_CAPTURE register is implemented in different
definition according to the corresponding versions of the protocol.
This would affect mbm_total_bytes interface returns the various result.

Consequently, it is necessary to determine the specification definition
followed by according to the chip model.

Fixes: 21ac9fc8 ("arm_mpam: Track bandwidth counter state for overflow and power management")
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent 3df1d1b7
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -915,6 +915,12 @@ static u64 mpam_msmon_overflow_val(struct mpam_msc_ris *ris)
		return GENMASK_ULL(30, 0);
}

static const struct midr_range mbwu_flowrate_list[] = {
	MIDR_ALL_VERSIONS(MIDR_HISI_TSV110),
	MIDR_ALL_VERSIONS(MIDR_HISI_LINXICORE9100),
	{ /* sentinel */ }
};

static void __ris_msmon_read(void *arg)
{
	bool nrdy = false;
@@ -986,6 +992,18 @@ static void __ris_msmon_read(void *arg)
		if (!mbwu_state)
			break;

		/*
		 * Following the definition of the DDI0598 version,
		 * the value field of MPAM Memory Bandwidth Usage Monitor Register
		 * indicates the memory bandwidth usage in bytes per second,
		 * instead the scaled count of bytes transferred since the monitor
		 * was last reset in the latest version (DDI0598D_b).
		 */
		if (ris->comp->class->type == MPAM_CLASS_MEMORY) {
			if (is_midr_in_range_list(read_cpuid_id(), mbwu_flowrate_list))
				break;
		}

		/* Add any pre-overflow value to the mbwu_state->val */
		if (mbwu_state->prev_val > now)
			overflow_val = mpam_msmon_overflow_val(ris) - mbwu_state->prev_val;