[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251107123450.664001-23-ben.horgan@arm.com>
Date: Fri, 7 Nov 2025 12:34:39 +0000
From: Ben Horgan <ben.horgan@....com>
To: james.morse@....com
Cc: amitsinght@...vell.com,
baisheng.gao@...soc.com,
baolin.wang@...ux.alibaba.com,
bobo.shaobowang@...wei.com,
carl@...amperecomputing.com,
catalin.marinas@....com,
dakr@...nel.org,
dave.martin@....com,
david@...hat.com,
dfustini@...libre.com,
fenghuay@...dia.com,
gregkh@...uxfoundation.org,
gshan@...hat.com,
guohanjun@...wei.com,
jeremy.linton@....com,
jonathan.cameron@...wei.com,
kobak@...dia.com,
lcherian@...vell.com,
lenb@...nel.org,
linux-acpi@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
lpieralisi@...nel.org,
peternewman@...gle.com,
quic_jiles@...cinc.com,
rafael@...nel.org,
robh@...nel.org,
rohit.mathew@....com,
scott@...amperecomputing.com,
sdonthineni@...dia.com,
sudeep.holla@....com,
tan.shaopeng@...itsu.com,
will@...nel.org,
xhao@...ux.alibaba.com,
Ben Horgan <ben.horgan@....com>,
Shaopeng Tan <tan.shaopeng@...fujitsu.com>
Subject: [PATCH 22/33] arm_mpam: Use a static key to indicate when mpam is enabled
From: James Morse <james.morse@....com>
Once all the MSC have been probed, the system wide usable number of
PARTID is known and the configuration arrays can be allocated.
After this point, checking all the MSC have been probed is pointless,
and the cpuhp callbacks should restore the configuration, instead of
just resetting the MSC.
Add a static key to enable this behaviour. This will also allow MPAM
to be disabled in response to an error, and the architecture code to
enable/disable the context switch of the MPAM system registers.
Signed-off-by: James Morse <james.morse@....com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@...wei.com>
Reviewed-by: Ben Horgan <ben.horgan@....com>
Reviewed-by: Fenghua Yu <fenghuay@...dia.com>
Tested-by: Fenghua Yu <fenghuay@...dia.com>
Tested-by: Shaopeng Tan <tan.shaopeng@...fujitsu.com>
Tested-by: Peter Newman <peternewman@...gle.com>
Signed-off-by: Ben Horgan <ben.horgan@....com>
---
drivers/resctrl/mpam_devices.c | 12 ++++++++++++
drivers/resctrl/mpam_internal.h | 8 ++++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index a543a363443c..3a0ad8d93fff 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -29,6 +29,8 @@
#include "mpam_internal.h"
+DEFINE_STATIC_KEY_FALSE(mpam_enabled); /* This moves to arch code */
+
/*
* mpam_list_lock protects the SRCU lists when writing. Once the
* mpam_enabled key is enabled these lists are read-only,
@@ -937,6 +939,9 @@ static int mpam_discovery_cpu_online(unsigned int cpu)
struct mpam_msc *msc;
bool new_device_probed = false;
+ if (mpam_is_enabled())
+ return 0;
+
guard(srcu)(&mpam_srcu);
list_for_each_entry_srcu(msc, &mpam_all_msc, all_msc_list,
srcu_read_lock_held(&mpam_srcu)) {
@@ -1475,6 +1480,10 @@ static irqreturn_t __mpam_irq_handler(int irq, struct mpam_msc *msc)
/* Disable this interrupt. */
mpam_disable_msc_ecr(msc);
+ /* Are we racing with the thread disabling MPAM? */
+ if (!mpam_is_enabled())
+ return IRQ_HANDLED;
+
/*
* Schedule the teardown work. Don't use a threaded IRQ as we can't
* unregister the interrupt from the threaded part of the handler.
@@ -1609,6 +1618,7 @@ static void mpam_enable_once(void)
return;
}
+ static_branch_enable(&mpam_enabled);
mpam_register_cpuhp_callbacks(mpam_cpu_online, mpam_cpu_offline,
"mpam:online");
@@ -1675,6 +1685,8 @@ void mpam_disable(struct work_struct *ignored)
}
mutex_unlock(&mpam_cpuhp_state_lock);
+ static_branch_disable(&mpam_enabled);
+
mpam_unregister_irqs();
idx = srcu_read_lock(&mpam_srcu);
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 3002c8e6cabc..c6937161877a 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -9,6 +9,7 @@
#include <linux/bitmap.h>
#include <linux/cpumask.h>
#include <linux/io.h>
+#include <linux/jump_label.h>
#include <linux/llist.h>
#include <linux/mutex.h>
#include <linux/srcu.h>
@@ -20,6 +21,13 @@
struct platform_device;
+DECLARE_STATIC_KEY_FALSE(mpam_enabled);
+
+static inline bool mpam_is_enabled(void)
+{
+ return static_branch_likely(&mpam_enabled);
+}
+
/*
* Structures protected by SRCU may not be freed for a surprising amount of
* time (especially if perf is running). To ensure the MPAM error interrupt can
--
2.43.0
Powered by blists - more mailing lists