#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,
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)) {
/* 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.
return;
}
+ static_branch_enable(&mpam_enabled);
mpam_register_cpuhp_callbacks(mpam_cpu_online, mpam_cpu_offline,
"mpam:online");
}
mutex_unlock(&mpam_cpuhp_state_lock);
+ static_branch_disable(&mpam_enabled);
+
mpam_unregister_irqs();
idx = srcu_read_lock(&mpam_srcu);
#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>
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