x86/apic: Use u32 for [gs]et_apic_id()
authorThomas Gleixner <tglx@linutronix.de>
Mon, 14 Aug 2023 08:18:44 +0000 (10:18 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 10 Oct 2023 12:38:19 +0000 (14:38 +0200)
APIC IDs are used with random data types u16, u32, int, unsigned int,
unsigned long.

Make it all consistently use u32 because that reflects the hardware
register width.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Juergen Gross <jgross@suse.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230814085113.172569282@linutronix.de
arch/x86/include/asm/apic.h
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_phys.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/xen/apic.c

index 0788c4663b6df503fcbef75dcce5fa1dab7d4330..e7b45f224c47dae6eea80322e19c56bcc882fa6e 100644 (file)
@@ -298,8 +298,8 @@ struct apic {
        u32     (*cpu_present_to_apicid)(int mps_cpu);
        u32     (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
 
-       u32     (*get_apic_id)(unsigned long x);
-       u32     (*set_apic_id)(unsigned int id);
+       u32     (*get_apic_id)(u32 id);
+       u32     (*set_apic_id)(u32 apicid);
 
        /* wakeup_secondary_cpu */
        int     (*wakeup_secondary_cpu)(int apicid, unsigned long start_eip);
@@ -493,16 +493,6 @@ static inline bool lapic_vector_set_in_irr(unsigned int vector)
        return !!(irr & (1U << (vector % 32)));
 }
 
-static inline unsigned default_get_apic_id(unsigned long x)
-{
-       unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
-
-       if (APIC_XAPIC(ver) || boot_cpu_has(X86_FEATURE_EXTD_APICID))
-               return (x >> 24) & 0xFF;
-       else
-               return (x >> 24) & 0x0F;
-}
-
 /*
  * Warm reset vector position:
  */
index ca05acaf5a6b38ed0c7cc827e0522d4ad38c9dca..37daa3fd68199b95d8f1a69b8dee93b1097e3e54 100644 (file)
@@ -56,12 +56,12 @@ flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)
        _flat_send_IPI_mask(mask, vector);
 }
 
-static unsigned int flat_get_apic_id(unsigned long x)
+static u32 flat_get_apic_id(u32 x)
 {
        return (x >> 24) & 0xFF;
 }
 
-static u32 set_apic_id(unsigned int id)
+static u32 set_apic_id(u32 id)
 {
        return (id & 0xFF) << 24;
 }
index 28ea3427a893e127cb78c1c89739ad89c20f14a7..f1114861938c5f9556c4a6f696eaf4e90362814b 100644 (file)
@@ -30,7 +30,7 @@ static void noop_apic_icr_write(u32 low, u32 id) { }
 static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip) { return -1; }
 static u64 noop_apic_icr_read(void) { return 0; }
 static u32 noop_phys_pkg_id(u32 cpuid_apic, int index_msb) { return 0; }
-static unsigned int noop_get_apic_id(unsigned long x) { return 0; }
+static u32 noop_get_apic_id(u32 apicid) { return 0; }
 static void noop_apic_eoi(void) { }
 
 static u32 noop_apic_read(u32 reg)
index c35181c4aa144cc1dca52994f03e6759fef4cb09..af350b4dad564418a6a8c2bfaf88c0d8e4476eae 100644 (file)
@@ -25,7 +25,7 @@ static const struct apic apic_numachip1;
 static const struct apic apic_numachip2;
 static void (*numachip_apic_icr_write)(int apicid, unsigned int val) __read_mostly;
 
-static unsigned int numachip1_get_apic_id(unsigned long x)
+static u32 numachip1_get_apic_id(u32 x)
 {
        unsigned long value;
        unsigned int id = (x >> 24) & 0xff;
@@ -38,12 +38,12 @@ static unsigned int numachip1_get_apic_id(unsigned long x)
        return id;
 }
 
-static u32 numachip1_set_apic_id(unsigned int id)
+static u32 numachip1_set_apic_id(u32 id)
 {
        return (id & 0xff) << 24;
 }
 
-static unsigned int numachip2_get_apic_id(unsigned long x)
+static u32 numachip2_get_apic_id(u32 x)
 {
        u64 mcfg;
 
@@ -51,7 +51,7 @@ static unsigned int numachip2_get_apic_id(unsigned long x)
        return ((mcfg >> (28 - 8)) & 0xfff00) | (x >> 24);
 }
 
-static u32 numachip2_set_apic_id(unsigned int id)
+static u32 numachip2_set_apic_id(u32 id)
 {
        return id << 24;
 }
index 3c95e0b03e8637929b4c0101a2cc05647ed31a49..7ee3c486cb3365c07b69e2a1bb739b5249bfd44a 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "local.h"
 
-static unsigned bigsmp_get_apic_id(unsigned long x)
+static u32 bigsmp_get_apic_id(u32 x)
 {
        return (x >> 24) & 0xFF;
 }
index 2bf0d1c78d71ed4141444e971d11575a20cb6a49..9ea6186ea88c2dc701bafb92dc50acb628dabf98 100644 (file)
@@ -15,8 +15,8 @@
 
 /* X2APIC */
 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);
+u32 x2apic_get_apic_id(u32 id);
+u32 x2apic_set_apic_id(u32 id);
 u32 x2apic_phys_pkg_id(u32 initial_apicid, int index_msb);
 
 void x2apic_send_IPI_all(int vector);
index 2867fa61c4cdde51502848dae103cbc98990f3e4..5eb3fbe472da9d3f5b80f9cc5c0c534e15215859 100644 (file)
@@ -23,6 +23,16 @@ static u32 default_phys_pkg_id(u32 cpuid_apic, int index_msb)
        return cpuid_apic >> index_msb;
 }
 
+static u32 default_get_apic_id(u32 x)
+{
+       unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
+
+       if (APIC_XAPIC(ver) || boot_cpu_has(X86_FEATURE_EXTD_APICID))
+               return (x >> 24) & 0xFF;
+       else
+               return (x >> 24) & 0x0F;
+}
+
 /* should be called last. */
 static int probe_default(void)
 {
index 55cbceccea085fc4577c2155887c858d4988cfb5..7c9fe28f742f51999db374f4f13d3fc47a3ab5fa 100644 (file)
@@ -124,12 +124,12 @@ static int x2apic_phys_probe(void)
        return apic == &apic_x2apic_phys;
 }
 
-unsigned int x2apic_get_apic_id(unsigned long id)
+u32 x2apic_get_apic_id(u32 id)
 {
        return id;
 }
 
-u32 x2apic_set_apic_id(unsigned int id)
+u32 x2apic_set_apic_id(u32 id)
 {
        return id;
 }
index 3589ab610dbc48179266ee0b8921fc29c01c164b..46d4de2f00a1b2d7111cb6c250b5187b14726b43 100644 (file)
@@ -779,7 +779,7 @@ static void uv_send_IPI_all(int vector)
        uv_send_IPI_mask(cpu_online_mask, vector);
 }
 
-static u32 set_apic_id(unsigned int id)
+static u32 set_apic_id(u32 id)
 {
        return id;
 }
index 40538b23e20b4d474be66d22087dd8b45c39cf75..9dd5490b3318923b0810b89076697ab9b8b91d52 100644 (file)
@@ -33,13 +33,13 @@ static unsigned int xen_io_apic_read(unsigned apic, unsigned reg)
        return 0xfd;
 }
 
-static u32 xen_set_apic_id(unsigned int x)
+static u32 xen_set_apic_id(u32 x)
 {
        WARN_ON(1);
        return x;
 }
 
-static unsigned int xen_get_apic_id(unsigned long x)
+static u32 xen_get_apic_id(u32 x)
 {
        return ((x)>>24) & 0xFFu;
 }