From: Ben Horgan <ben.horgan@arm.com>
To: ben.horgan@arm.com, will@kernel.org
Cc: james.morse@arm.com, fenghuay@nvidia.com,
linux-arm-kernel@lists.infradead.org, andre.przywara@arm.com,
gshan@redhat.com, tan.shaopeng@jp.fujitsu.com,
sdonthineni@nvidia.com, jonathan.cameron@oss.qualcomm.com,
Jonathan Cameron <jonathan.cameron@huawei.com>
Subject: [PATCH 3/6] arm_mpam: resctrl: Add resctrl_arch_config_cntr() for ABMC use
Date: Fri, 31 Jul 2026 18:52:40 +0100 [thread overview]
Message-ID: <20260731175243.904730-4-ben.horgan@arm.com> (raw)
In-Reply-To: <20260731175243.904730-1-ben.horgan@arm.com>
From: James Morse <james.morse@arm.com>
ABMC, mbm_event mode, has a helper resctrl_arch_config_cntr() for changing
the mapping between 'cntr_id' and a CLOSID/RMID pair.
Add the helper.
For MPAM this is done by updating the mon->mbwu_idx_to_mon[] array, and as
usual CDP means it needs doing in three different ways.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Fenghua Yu <fenghuay@nvidia.com>
Tested-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
---
Changes since new rfc:
Mention mbm_event mode in commit message
Changes since v3:
Warning bound (Sashiko)
Changes since v4:
resctrl_arch_reset_rmid() -> reset_arch_reset_cntr()
Changes since v5:
Add Gavin's R-b & T-b
---
drivers/resctrl/mpam_resctrl.c | 48 +++++++++++++++++++++++++++++-----
1 file changed, 42 insertions(+), 6 deletions(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 0698a235d15c..ab322865c51b 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -125,12 +125,6 @@ void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *d
{
}
-void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
- enum resctrl_event_id evtid, u32 rmid, u32 closid,
- u32 cntr_id, bool assign)
-{
-}
-
int resctrl_arch_cntr_read(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
u32 unused, u32 rmid, int cntr_id,
enum resctrl_event_id eventid, u64 *val)
@@ -1082,6 +1076,48 @@ static void mpam_resctrl_pick_counters(void)
}
}
+static void __config_cntr(struct mpam_resctrl_mon *mon, u32 cntr_id,
+ enum resctrl_conf_type cdp_type, u32 closid, u32 rmid,
+ bool assign)
+{
+ /* Same CDP index remap as closid; maps cntr_id to assigned_counters[]. */
+ u32 mbwu_idx, mon_idx = resctrl_get_config_index(cntr_id, cdp_type);
+
+ closid = resctrl_get_config_index(closid, cdp_type);
+ mbwu_idx = resctrl_arch_rmid_idx_encode(closid, rmid);
+
+ if (assign)
+ mon->mbwu_idx_to_mon[mbwu_idx] = mon->assigned_counters[mon_idx];
+ else
+ mon->mbwu_idx_to_mon[mbwu_idx] = -1;
+}
+
+void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *d,
+ enum resctrl_event_id evtid, u32 rmid, u32 closid,
+ u32 cntr_id, bool assign)
+{
+ struct mpam_resctrl_mon *mon = &mpam_resctrl_counters[evtid];
+
+ if (evtid != QOS_L3_MBM_TOTAL_EVENT_ID) {
+ pr_debug("unexpected event id\n");
+ return;
+ }
+
+ if (!mon->mbwu_idx_to_mon || !mon->assigned_counters) {
+ pr_debug("monitor arrays not allocated\n");
+ return;
+ }
+
+ if (cdp_enabled) {
+ __config_cntr(mon, cntr_id, CDP_CODE, closid, rmid, assign);
+ __config_cntr(mon, cntr_id, CDP_DATA, closid, rmid, assign);
+ } else {
+ __config_cntr(mon, cntr_id, CDP_NONE, closid, rmid, assign);
+ }
+
+ resctrl_arch_reset_cntr(r, d, closid, rmid, cntr_id, QOS_L3_MBM_TOTAL_EVENT_ID);
+}
+
static int mpam_resctrl_control_init(struct mpam_resctrl_res *res)
{
struct mpam_class *class = res->class;
--
2.43.0
next prev parent reply other threads:[~2026-07-31 17:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 17:52 MPAM changes for v7.3 Ben Horgan
2026-07-31 17:52 ` [PATCH 1/6] arm_mpam: resctrl: Pick classes for use as MBM counters Ben Horgan
2026-07-31 17:52 ` [PATCH 2/6] arm_mpam: resctrl: Pre-allocate assignable monitors Ben Horgan
2026-07-31 17:52 ` Ben Horgan [this message]
2026-07-31 17:52 ` [PATCH 4/6] arm_mpam: resctrl: Add resctrl_arch_cntr_read() & resctrl_arch_reset_cntr() Ben Horgan
2026-07-31 17:52 ` [PATCH 5/6] arm64: mpam: Add memory bandwidth usage (MBWU) documentation Ben Horgan
2026-07-31 17:52 ` [PATCH 6/6] arm_mpam: Apply T241-MPAM-6 to 63-bit counters Ben Horgan
2026-08-01 0:23 ` Ben Horgan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260731175243.904730-4-ben.horgan@arm.com \
--to=ben.horgan@arm.com \
--cc=andre.przywara@arm.com \
--cc=fenghuay@nvidia.com \
--cc=gshan@redhat.com \
--cc=james.morse@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=sdonthineni@nvidia.com \
--cc=tan.shaopeng@jp.fujitsu.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox