
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID29QH -------------------------------- Bandwidth counters need to run continuously to correctly reflect the bandwidth. When reading the previously configured MSMON_CFG_MBWU_CTL, software must recognize that the MSMON_CFG_x_CTL_OFLOW_STATUS bit may have been set by hardware because of the counter overflow. The existing logic incorrectly treats this bit as an indication that the monitor configuration has been changed and consequently zeros the MBWU statistics by mistake. Also fix the handling of overflow amount calculation. 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index c6279b91b3d7..556cdde88d13 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -1016,7 +1016,7 @@ static void __ris_msmon_read(void *arg) read_msmon_ctl_flt_vals(m, &cur_ctl, &cur_flt); gen_msmon_ctl_flt_vals(m, &ctl_val, &flt_val); config_mismatch = cur_flt != flt_val || - cur_ctl != (ctl_val | MSMON_CFG_x_CTL_EN); + (cur_ctl & ~MSMON_CFG_x_CTL_OFLOW_STATUS) != (ctl_val | MSMON_CFG_x_CTL_EN); if (config_mismatch || reset_on_next_read) write_msmon_ctl_flt_vals(m, ctl_val, flt_val); @@ -1074,8 +1074,8 @@ static void __ris_msmon_read(void *arg) } /* 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; + if (mbwu_state->prev_val > now && (cur_ctl & MSMON_CFG_x_CTL_OFLOW_STATUS)) + overflow_val = mpam_msmon_overflow_val(ris); mbwu_state->prev_val = now; mbwu_state->correction += overflow_val; -- 2.25.1