]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/apic: Mop up apic::apic_id_registered()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 8 Aug 2023 22:04:02 +0000 (15:04 -0700)
committerDave Hansen <dave.hansen@linux.intel.com>
Wed, 9 Aug 2023 18:58:27 +0000 (11:58 -0700)
Really not a hotpath and again no reason for having a gazillion of empty
callbacks returning 1. Make it return bool and provide one shared
implementation for the remaining users.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Tested-by: Juergen Gross <jgross@suse.com> # Xen PV (dom0 and unpriv. guest)
13 files changed:
arch/x86/include/asm/apic.h
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/apic_common.c
arch/x86/kernel/apic/apic_flat_64.c
arch/x86/kernel/apic/apic_noop.c
arch/x86/kernel/apic/apic_numachip.c
arch/x86/kernel/apic/bigsmp_32.c
arch/x86/kernel/apic/local.h
arch/x86/kernel/apic/probe_32.c
arch/x86/kernel/apic/x2apic_cluster.c
arch/x86/kernel/apic/x2apic_phys.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/xen/apic.c

index 83ecea3baaafbb5a17ed51a2433066f7fc91e626..4fb71b7d597a5b0f1478d149a40b302002adc07f 100644 (file)
@@ -295,7 +295,7 @@ struct apic {
        int     (*probe)(void);
        int     (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
        int     (*apic_id_valid)(u32 apicid);
-       int     (*apic_id_registered)(void);
+       bool    (*apic_id_registered)(void);
 
        bool    (*check_apicid_used)(physid_mask_t *map, int apicid);
        void    (*init_apic_ldr)(void);
index c2656a3ffbec868482786c598527f4c5202a9e7e..4ee95cb2178e72a9988cca02809ec22be41b9b54 100644 (file)
@@ -1571,11 +1571,8 @@ static void setup_local_APIC(void)
                apic_write(APIC_ESR, 0);
        }
 #endif
-       /*
-        * Double-check whether this APIC is really registered.
-        * This is meaningless in clustered apic mode, so we skip it.
-        */
-       BUG_ON(!apic->apic_id_registered());
+       /* Validate that the APIC is registered if required */
+       BUG_ON(apic->apic_id_registered && !apic->apic_id_registered());
 
        /*
         * Intel recommends to set DFR, LDR and TPR before enabling
index d55fdb33b8e5d4fa5fc0fa81348f0d4b59c4ac4e..bbb5d5a6c82057f5e845f1b32432ca403a444738 100644 (file)
@@ -42,6 +42,11 @@ int default_apic_id_valid(u32 apicid)
        return (apicid < 255);
 }
 
+bool default_apic_id_registered(void)
+{
+       return physid_isset(read_apic_id(), phys_cpu_present_map);
+}
+
 /*
  * Set up the logical destination ID when the APIC operates in logical
  * destination mode.
index 83e02b5796e6894352e9fd897aa5b9faadbc2384..a0c875d6ef3e08fe85a59e946f5761ee819ee93f 100644 (file)
@@ -66,16 +66,6 @@ static u32 set_apic_id(unsigned int id)
        return (id & 0xFF) << 24;
 }
 
-static unsigned int read_xapic_id(void)
-{
-       return flat_get_apic_id(apic_read(APIC_ID));
-}
-
-static int flat_apic_id_registered(void)
-{
-       return physid_isset(read_xapic_id(), phys_cpu_present_map);
-}
-
 static int flat_phys_pkg_id(int initial_apic_id, int index_msb)
 {
        return initial_apic_id >> index_msb;
@@ -91,7 +81,7 @@ static struct apic apic_flat __ro_after_init = {
        .probe                          = flat_probe,
        .acpi_madt_oem_check            = flat_acpi_madt_oem_check,
        .apic_id_valid                  = default_apic_id_valid,
-       .apic_id_registered             = flat_apic_id_registered,
+       .apic_id_registered             = default_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = true,
@@ -168,7 +158,7 @@ static struct apic apic_physflat __ro_after_init = {
        .probe                          = physflat_probe,
        .acpi_madt_oem_check            = physflat_acpi_madt_oem_check,
        .apic_id_valid                  = default_apic_id_valid,
-       .apic_id_registered             = flat_apic_id_registered,
+       .apic_id_registered             = default_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = false,
index e7309fd9cb55586bef6024f7b28f519a13f1e729..c73a7a811bb94908b9fe3da68fa24b3015e6edbf 100644 (file)
@@ -57,17 +57,6 @@ static int noop_probe(void)
        return 0;
 }
 
-static int noop_apic_id_registered(void)
-{
-       /*
-        * if we would be really "pedantic"
-        * we should pass read_apic_id() here
-        * but since NOOP suppose APIC ID = 0
-        * lets save a few cycles
-        */
-       return physid_isset(0, phys_cpu_present_map);
-}
-
 static u32 noop_apic_read(u32 reg)
 {
        WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !apic_is_disabled);
@@ -85,7 +74,6 @@ struct apic apic_noop __ro_after_init = {
        .acpi_madt_oem_check            = NULL,
 
        .apic_id_valid                  = default_apic_id_valid,
-       .apic_id_registered             = noop_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = true,
index b0d5a6ebc379bebfe31743794d4f4c919c7b7d59..e8e13d7c84d77587c1091bc29f64797a360bbc43 100644 (file)
@@ -62,11 +62,6 @@ static int numachip_apic_id_valid(u32 apicid)
        return 1;
 }
 
-static int numachip_apic_id_registered(void)
-{
-       return 1;
-}
-
 static int numachip_phys_pkg_id(int initial_apic_id, int index_msb)
 {
        return initial_apic_id >> index_msb;
@@ -244,7 +239,6 @@ static const struct apic apic_numachip1 __refconst = {
        .probe                          = numachip1_probe,
        .acpi_madt_oem_check            = numachip1_acpi_madt_oem_check,
        .apic_id_valid                  = numachip_apic_id_valid,
-       .apic_id_registered             = numachip_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = false,
@@ -286,7 +280,6 @@ static const struct apic apic_numachip2 __refconst = {
        .probe                          = numachip2_probe,
        .acpi_madt_oem_check            = numachip2_acpi_madt_oem_check,
        .apic_id_valid                  = numachip_apic_id_valid,
-       .apic_id_registered             = numachip_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = false,
index 9bbdd40107f74c47ecc3f77d503c24fabb08e380..ffff294f4b44faa337483577f28e00438a8d77ff 100644 (file)
@@ -18,11 +18,6 @@ static unsigned bigsmp_get_apic_id(unsigned long x)
        return (x >> 24) & 0xFF;
 }
 
-static int bigsmp_apic_id_registered(void)
-{
-       return 1;
-}
-
 static bool bigsmp_check_apicid_used(physid_mask_t *map, int apicid)
 {
        return false;
@@ -85,7 +80,6 @@ static struct apic apic_bigsmp __ro_after_init = {
        .name                           = "bigsmp",
        .probe                          = probe_bigsmp,
        .apic_id_valid                  = default_apic_id_valid,
-       .apic_id_registered             = bigsmp_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = false,
index 345acdeab4480c15841dd4e0a97dfcb1a95f8762..0c477110baaf8eea2bedd8fa2d9972704df9e2fc 100644 (file)
@@ -15,7 +15,6 @@
 
 /* X2APIC */
 int x2apic_apic_id_valid(u32 apicid);
-int x2apic_apic_id_registered(void);
 void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest);
 unsigned int x2apic_get_apic_id(unsigned long id);
 u32 x2apic_set_apic_id(unsigned int id);
@@ -61,6 +60,8 @@ void default_send_IPI_allbutself(int vector);
 void default_send_IPI_all(int vector);
 void default_send_IPI_self(int vector);
 
+bool default_apic_id_registered(void);
+
 #ifdef CONFIG_X86_32
 void default_send_IPI_mask_sequence_logical(const struct cpumask *mask, int vector);
 void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask, int vector);
index 3f717f4c72bc106700a9475c1acfa75ef66d398f..81c69d766a3048cdf0fc8c9c9618cfa5e9bbcfa5 100644 (file)
 
 #include "local.h"
 
-static int default_apic_id_registered(void)
-{
-       return physid_isset(read_apic_id(), phys_cpu_present_map);
-}
-
 static int default_phys_pkg_id(int cpuid_apic, int index_msb)
 {
        return cpuid_apic >> index_msb;
index 52d4be15a7dcdcebbc8d32fd04a5338bc2bd02fd..705b33d7072a7e99a63c7e52eb6bda5668ab36aa 100644 (file)
@@ -237,7 +237,6 @@ static struct apic apic_x2apic_cluster __ro_after_init = {
        .probe                          = x2apic_cluster_probe,
        .acpi_madt_oem_check            = x2apic_acpi_madt_oem_check,
        .apic_id_valid                  = x2apic_apic_id_valid,
-       .apic_id_registered             = x2apic_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = true,
index c57b5c82b14abfe828d671bf4afeab0e561975c2..e0fdbf5522cd1c0353487e40f9b84e9d55e8741d 100644 (file)
@@ -111,11 +111,6 @@ int x2apic_apic_id_valid(u32 apicid)
        return 1;
 }
 
-int x2apic_apic_id_registered(void)
-{
-       return 1;
-}
-
 void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest)
 {
        unsigned long cfg = __prepare_ICR(0, vector, dest);
@@ -157,7 +152,6 @@ static struct apic apic_x2apic_phys __ro_after_init = {
        .probe                          = x2apic_phys_probe,
        .acpi_madt_oem_check            = x2apic_acpi_madt_oem_check,
        .apic_id_valid                  = x2apic_apic_id_valid,
-       .apic_id_registered             = x2apic_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = false,
index a8caff181adf824034b7a8509b2565910bd44f1d..9e25e3033d0d9acaec3f9a6845c35d1eebae2996 100644 (file)
@@ -783,11 +783,6 @@ static int uv_apic_id_valid(u32 apicid)
        return 1;
 }
 
-static int uv_apic_id_registered(void)
-{
-       return 1;
-}
-
 static u32 apic_uv_calc_apicid(unsigned int cpu)
 {
        return apic_default_calc_apicid(cpu);
@@ -829,7 +824,6 @@ static struct apic apic_x2apic_uv_x __ro_after_init = {
        .probe                          = uv_probe,
        .acpi_madt_oem_check            = uv_acpi_madt_oem_check,
        .apic_id_valid                  = uv_apic_id_valid,
-       .apic_id_registered             = uv_apic_id_registered,
 
        .delivery_mode                  = APIC_DELIVERY_MODE_FIXED,
        .dest_mode_logical              = false,
index 4a27f92b51d153210d0929bba6a0ee0b10d1c0c2..f1cd7f2b3ac0de759668a36103b86d3eb80ec2fb 100644 (file)
@@ -115,11 +115,6 @@ static int xen_id_always_valid(u32 apicid)
        return 1;
 }
 
-static int xen_id_always_registered(void)
-{
-       return 1;
-}
-
 static int xen_phys_pkg_id(int initial_apic_id, int index_msb)
 {
        return initial_apic_id >> index_msb;
@@ -142,7 +137,6 @@ static struct apic xen_pv_apic = {
        .probe                          = xen_apic_probe_pv,
        .acpi_madt_oem_check            = xen_madt_oem_check,
        .apic_id_valid                  = xen_id_always_valid,
-       .apic_id_registered             = xen_id_always_registered,
 
        /* .delivery_mode and .dest_mode_logical not used by XENPV */