
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. So far, all HISI chipsets follow 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. Therefore, as an instantaneous value for memory bandwidth statistics, there is no possibility of causing the register to overflow. Fixes: 21ac9fc8f275 ("arm_mpam: Track bandwidth counter state for overflow and power management") Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_devices.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index 19bd40814685..169e9d43c70c 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -915,6 +915,11 @@ static u64 mpam_msmon_overflow_val(struct mpam_msc_ris *ris) return GENMASK_ULL(30, 0); } +static bool resctrl_arch_would_mbm_overflow(void) +{ + return read_cpuid_implementor() != ARM_CPU_IMP_HISI; +} + static void __ris_msmon_read(void *arg) { bool nrdy = false; @@ -986,6 +991,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 (!resctrl_arch_would_mbm_overflow()) + 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; -- 2.25.1