[PATCH OLK-6.6 0/2] arm64/mpam: Fix MBWU monitor overflow handling
Zeng Heng (2): arm64/mpam: Fix MBWU monitor overflow handling arm64/mpam: Print MPAM register operation for debug drivers/platform/mpam/mpam_devices.c | 33 ++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) -- 2.25.1
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. There's no need to subtract mbwu_state->prev_val when calculating overflow_val. 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index c6279b91b3d7..b4ce047b62ab 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -977,6 +977,21 @@ static u64 mpam_csu_hisi_need_halved(struct mpam_msc_ris *ris, u64 now) return now >> 1; } +static bool read_msmon_mbwu_is_overflow(struct mpam_msc *msc) +{ + u32 ctl; + bool overflow; + + ctl = mpam_read_monsel_reg(msc, CFG_MBWU_CTL); + overflow = ctl & MSMON_CFG_x_CTL_OFLOW_STATUS ? true : false; + + if (overflow) + mpam_write_monsel_reg(msc, CFG_MBWU_CTL, ctl & + ~MSMON_CFG_x_CTL_OFLOW_STATUS); + + return overflow; +} + static void __ris_msmon_read(void *arg) { bool nrdy = false; @@ -984,6 +999,7 @@ static void __ris_msmon_read(void *arg) bool config_mismatch; struct mon_read *m = arg; u64 now, overflow_val = 0; + bool mbwu_overflow = false; struct mon_cfg *ctx = m->ctx; bool reset_on_next_read = false; struct mpam_msc_ris *ris = m->ris; @@ -1007,6 +1023,8 @@ static void __ris_msmon_read(void *arg) reset_on_next_read = mbwu_state->reset_on_next_read; mbwu_state->reset_on_next_read = false; } + + mbwu_overflow = read_msmon_mbwu_is_overflow(msc); } /* @@ -1074,8 +1092,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_overflow) + overflow_val = mpam_msmon_overflow_val(ris); mbwu_state->prev_val = now; mbwu_state->correction += overflow_val; -- 2.25.1
hulk inclusion category: cleanup bugzilla: https://gitee.com/openeuler/kernel/issues/ID29QH -------------------------------- To facilitate scoping the problem and making diagnostics easier, MPAM provides print logs for register operations. Enable this feature with the following command: echo 'file mpam_devices.c +p' > /sys/kernel/debug/dynamic_debug/control echo 8 > /proc/sys/kernel/printk Signed-off-by: Zeng Heng <zengheng4@huawei.com> --- drivers/platform/mpam/mpam_devices.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index b4ce047b62ab..2fa3bd2083c3 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -114,12 +114,16 @@ static void __mpam_write_reg(struct mpam_msc *msc, u16 reg, u32 val) lockdep_assert_held_once(&msc->part_sel_lock); \ ____ret = __mpam_read_reg(msc, MPAMF_##reg); \ \ + pr_debug("par r: msc %d reg 0x%x val 0x%x\n", \ + msc->id, MPAMF_##reg, ____ret); \ ____ret; \ }) #define mpam_write_partsel_reg(msc, reg, val) \ ({ \ lockdep_assert_held_once(&msc->part_sel_lock); \ + pr_debug("par w: msc %d reg 0x%x val 0x%lx\n", \ + msc->id, MPAMCFG_##reg, (unsigned long)val); \ __mpam_write_reg(msc, MPAMCFG_##reg, val); \ }) @@ -130,12 +134,16 @@ static void __mpam_write_reg(struct mpam_msc *msc, u16 reg, u32 val) lockdep_assert_held_once(&msc->mon_sel_lock); \ ____ret = __mpam_read_reg(msc, MSMON_##reg); \ \ + pr_debug("mon r: msc %d reg 0x%x val 0x%x\n", \ + msc->id, MSMON_##reg, ____ret); \ ____ret; \ }) #define mpam_write_monsel_reg(msc, reg, val) \ ({ \ lockdep_assert_held_once(&msc->mon_sel_lock); \ + pr_debug("mon w: msc %d reg 0x%x val 0x%lx\n", \ + msc->id, MSMON_##reg, (unsigned long)val); \ __mpam_write_reg(msc, MSMON_##reg, val); \ }) @@ -471,6 +479,9 @@ static int mpam_ris_get_affinity(struct mpam_msc *msc, cpumask_t *affinity, cpumask_and(affinity, affinity, &msc->accessibility); + pr_debug("comp_id %d msc->id %d affinity %*pb\n", + comp->comp_id, msc->id, cpumask_pr_args(affinity)); + return 0; } -- 2.25.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/18559 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/37I... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/18559 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/37I...
participants (2)
-
patchwork bot -
Zeng Heng