From e7a4bb5d3b66d6c835b74aa15f47212a00de1de8 Mon Sep 17 00:00:00 2001 From: Zeng Heng Date: Mon, 20 Oct 2025 20:46:11 +0800 Subject: [PATCH 1/2] arm64/mpam: Fix MBWU monitor overflow handling 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 --- 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 c6279b91b3d7d..556cdde88d139 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; -- Gitee From 374c6e2c1ea77ca3e5634e25f1e0606921d147e0 Mon Sep 17 00:00:00 2001 From: Zeng Heng Date: Mon, 20 Oct 2025 20:46:12 +0800 Subject: [PATCH 2/2] arm64/mpam: Print MPAM register operation for debug 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 --- 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 556cdde88d139..eca84342a5fe5 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; } -- Gitee