Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

James Morse and committed by
Catalin Marinas
3796f75a 49aa621c

+20
+12
drivers/resctrl/mpam_devices.c
··· 29 29 30 30 #include "mpam_internal.h" 31 31 32 + DEFINE_STATIC_KEY_FALSE(mpam_enabled); /* This moves to arch code */ 33 + 32 34 /* 33 35 * mpam_list_lock protects the SRCU lists when writing. Once the 34 36 * mpam_enabled key is enabled these lists are read-only, ··· 938 936 struct mpam_msc *msc; 939 937 bool new_device_probed = false; 940 938 939 + if (mpam_is_enabled()) 940 + return 0; 941 + 941 942 guard(srcu)(&mpam_srcu); 942 943 list_for_each_entry_srcu(msc, &mpam_all_msc, all_msc_list, 943 944 srcu_read_lock_held(&mpam_srcu)) { ··· 1476 1471 /* Disable this interrupt. */ 1477 1472 mpam_disable_msc_ecr(msc); 1478 1473 1474 + /* Are we racing with the thread disabling MPAM? */ 1475 + if (!mpam_is_enabled()) 1476 + return IRQ_HANDLED; 1477 + 1479 1478 /* 1480 1479 * Schedule the teardown work. Don't use a threaded IRQ as we can't 1481 1480 * unregister the interrupt from the threaded part of the handler. ··· 1614 1605 return; 1615 1606 } 1616 1607 1608 + static_branch_enable(&mpam_enabled); 1617 1609 mpam_register_cpuhp_callbacks(mpam_cpu_online, mpam_cpu_offline, 1618 1610 "mpam:online"); 1619 1611 ··· 1680 1670 mpam_cpuhp_state = 0; 1681 1671 } 1682 1672 mutex_unlock(&mpam_cpuhp_state_lock); 1673 + 1674 + static_branch_disable(&mpam_enabled); 1683 1675 1684 1676 mpam_unregister_irqs(); 1685 1677
+8
drivers/resctrl/mpam_internal.h
··· 9 9 #include <linux/bitmap.h> 10 10 #include <linux/cpumask.h> 11 11 #include <linux/io.h> 12 + #include <linux/jump_label.h> 12 13 #include <linux/llist.h> 13 14 #include <linux/mutex.h> 14 15 #include <linux/srcu.h> ··· 20 19 #define MPAM_MSC_MAX_NUM_RIS 16 21 20 22 21 struct platform_device; 22 + 23 + DECLARE_STATIC_KEY_FALSE(mpam_enabled); 24 + 25 + static inline bool mpam_is_enabled(void) 26 + { 27 + return static_branch_likely(&mpam_enabled); 28 + } 23 29 24 30 /* 25 31 * Structures protected by SRCU may not be freed for a surprising amount of