Skip to content

Commit 3796f75

Browse files
James Morsectmarinas
authored andcommitted
arm_mpam: Use a static key to indicate when mpam is enabled
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@arm.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Ben Horgan <ben.horgan@arm.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Fenghua Yu <fenghuay@nvidia.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Zeng Heng <zengheng4@huawei.com> Tested-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 49aa621 commit 3796f75

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

drivers/resctrl/mpam_devices.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#include "mpam_internal.h"
3131

32+
DEFINE_STATIC_KEY_FALSE(mpam_enabled); /* This moves to arch code */
33+
3234
/*
3335
* mpam_list_lock protects the SRCU lists when writing. Once the
3436
* mpam_enabled key is enabled these lists are read-only,
@@ -936,6 +938,9 @@ static int mpam_discovery_cpu_online(unsigned int cpu)
936938
struct mpam_msc *msc;
937939
bool new_device_probed = false;
938940

941+
if (mpam_is_enabled())
942+
return 0;
943+
939944
guard(srcu)(&mpam_srcu);
940945
list_for_each_entry_srcu(msc, &mpam_all_msc, all_msc_list,
941946
srcu_read_lock_held(&mpam_srcu)) {
@@ -1471,6 +1476,10 @@ static irqreturn_t __mpam_irq_handler(int irq, struct mpam_msc *msc)
14711476
/* Disable this interrupt. */
14721477
mpam_disable_msc_ecr(msc);
14731478

1479+
/* Are we racing with the thread disabling MPAM? */
1480+
if (!mpam_is_enabled())
1481+
return IRQ_HANDLED;
1482+
14741483
/*
14751484
* Schedule the teardown work. Don't use a threaded IRQ as we can't
14761485
* unregister the interrupt from the threaded part of the handler.
@@ -1605,6 +1614,7 @@ static void mpam_enable_once(void)
16051614
return;
16061615
}
16071616

1617+
static_branch_enable(&mpam_enabled);
16081618
mpam_register_cpuhp_callbacks(mpam_cpu_online, mpam_cpu_offline,
16091619
"mpam:online");
16101620

@@ -1671,6 +1681,8 @@ void mpam_disable(struct work_struct *ignored)
16711681
}
16721682
mutex_unlock(&mpam_cpuhp_state_lock);
16731683

1684+
static_branch_disable(&mpam_enabled);
1685+
16741686
mpam_unregister_irqs();
16751687

16761688
idx = srcu_read_lock(&mpam_srcu);

drivers/resctrl/mpam_internal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/bitmap.h>
1010
#include <linux/cpumask.h>
1111
#include <linux/io.h>
12+
#include <linux/jump_label.h>
1213
#include <linux/llist.h>
1314
#include <linux/mutex.h>
1415
#include <linux/srcu.h>
@@ -20,6 +21,13 @@
2021

2122
struct platform_device;
2223

24+
DECLARE_STATIC_KEY_FALSE(mpam_enabled);
25+
26+
static inline bool mpam_is_enabled(void)
27+
{
28+
return static_branch_likely(&mpam_enabled);
29+
}
30+
2331
/*
2432
* Structures protected by SRCU may not be freed for a surprising amount of
2533
* time (especially if perf is running). To ensure the MPAM error interrupt can

0 commit comments

Comments
 (0)