Skip to content

Commit 59f7928

Browse files
committed
x86/apic: Use u32 for [gs]et_apic_id()
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 <[email protected]> Tested-by: Juergen Gross <[email protected]> Tested-by: Sohil Mehta <[email protected]> Tested-by: Michael Kelley <[email protected]> Tested-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Zhang Rui <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 01ccf9b commit 59f7928

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

arch/x86/include/asm/apic.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ struct apic {
298298
u32 (*cpu_present_to_apicid)(int mps_cpu);
299299
u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
300300

301-
u32 (*get_apic_id)(unsigned long x);
302-
u32 (*set_apic_id)(unsigned int id);
301+
u32 (*get_apic_id)(u32 id);
302+
u32 (*set_apic_id)(u32 apicid);
303303

304304
/* wakeup_secondary_cpu */
305305
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)
493493
return !!(irr & (1U << (vector % 32)));
494494
}
495495

496-
static inline unsigned default_get_apic_id(unsigned long x)
497-
{
498-
unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
499-
500-
if (APIC_XAPIC(ver) || boot_cpu_has(X86_FEATURE_EXTD_APICID))
501-
return (x >> 24) & 0xFF;
502-
else
503-
return (x >> 24) & 0x0F;
504-
}
505-
506496
/*
507497
* Warm reset vector position:
508498
*/

arch/x86/kernel/apic/apic_flat_64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)
5656
_flat_send_IPI_mask(mask, vector);
5757
}
5858

59-
static unsigned int flat_get_apic_id(unsigned long x)
59+
static u32 flat_get_apic_id(u32 x)
6060
{
6161
return (x >> 24) & 0xFF;
6262
}
6363

64-
static u32 set_apic_id(unsigned int id)
64+
static u32 set_apic_id(u32 id)
6565
{
6666
return (id & 0xFF) << 24;
6767
}

arch/x86/kernel/apic/apic_noop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void noop_apic_icr_write(u32 low, u32 id) { }
3030
static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip) { return -1; }
3131
static u64 noop_apic_icr_read(void) { return 0; }
3232
static u32 noop_phys_pkg_id(u32 cpuid_apic, int index_msb) { return 0; }
33-
static unsigned int noop_get_apic_id(unsigned long x) { return 0; }
33+
static u32 noop_get_apic_id(u32 apicid) { return 0; }
3434
static void noop_apic_eoi(void) { }
3535

3636
static u32 noop_apic_read(u32 reg)

arch/x86/kernel/apic/apic_numachip.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static const struct apic apic_numachip1;
2525
static const struct apic apic_numachip2;
2626
static void (*numachip_apic_icr_write)(int apicid, unsigned int val) __read_mostly;
2727

28-
static unsigned int numachip1_get_apic_id(unsigned long x)
28+
static u32 numachip1_get_apic_id(u32 x)
2929
{
3030
unsigned long value;
3131
unsigned int id = (x >> 24) & 0xff;
@@ -38,20 +38,20 @@ static unsigned int numachip1_get_apic_id(unsigned long x)
3838
return id;
3939
}
4040

41-
static u32 numachip1_set_apic_id(unsigned int id)
41+
static u32 numachip1_set_apic_id(u32 id)
4242
{
4343
return (id & 0xff) << 24;
4444
}
4545

46-
static unsigned int numachip2_get_apic_id(unsigned long x)
46+
static u32 numachip2_get_apic_id(u32 x)
4747
{
4848
u64 mcfg;
4949

5050
rdmsrl(MSR_FAM10H_MMIO_CONF_BASE, mcfg);
5151
return ((mcfg >> (28 - 8)) & 0xfff00) | (x >> 24);
5252
}
5353

54-
static u32 numachip2_set_apic_id(unsigned int id)
54+
static u32 numachip2_set_apic_id(u32 id)
5555
{
5656
return id << 24;
5757
}

arch/x86/kernel/apic/bigsmp_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "local.h"
1515

16-
static unsigned bigsmp_get_apic_id(unsigned long x)
16+
static u32 bigsmp_get_apic_id(u32 x)
1717
{
1818
return (x >> 24) & 0xFF;
1919
}

arch/x86/kernel/apic/local.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
/* X2APIC */
1717
void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest);
18-
unsigned int x2apic_get_apic_id(unsigned long id);
19-
u32 x2apic_set_apic_id(unsigned int id);
18+
u32 x2apic_get_apic_id(u32 id);
19+
u32 x2apic_set_apic_id(u32 id);
2020
u32 x2apic_phys_pkg_id(u32 initial_apicid, int index_msb);
2121

2222
void x2apic_send_IPI_all(int vector);

arch/x86/kernel/apic/probe_32.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ static u32 default_phys_pkg_id(u32 cpuid_apic, int index_msb)
2323
return cpuid_apic >> index_msb;
2424
}
2525

26+
static u32 default_get_apic_id(u32 x)
27+
{
28+
unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
29+
30+
if (APIC_XAPIC(ver) || boot_cpu_has(X86_FEATURE_EXTD_APICID))
31+
return (x >> 24) & 0xFF;
32+
else
33+
return (x >> 24) & 0x0F;
34+
}
35+
2636
/* should be called last. */
2737
static int probe_default(void)
2838
{

arch/x86/kernel/apic/x2apic_phys.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ static int x2apic_phys_probe(void)
124124
return apic == &apic_x2apic_phys;
125125
}
126126

127-
unsigned int x2apic_get_apic_id(unsigned long id)
127+
u32 x2apic_get_apic_id(u32 id)
128128
{
129129
return id;
130130
}
131131

132-
u32 x2apic_set_apic_id(unsigned int id)
132+
u32 x2apic_set_apic_id(u32 id)
133133
{
134134
return id;
135135
}

arch/x86/kernel/apic/x2apic_uv_x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static void uv_send_IPI_all(int vector)
779779
uv_send_IPI_mask(cpu_online_mask, vector);
780780
}
781781

782-
static u32 set_apic_id(unsigned int id)
782+
static u32 set_apic_id(u32 id)
783783
{
784784
return id;
785785
}

arch/x86/xen/apic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ static unsigned int xen_io_apic_read(unsigned apic, unsigned reg)
3333
return 0xfd;
3434
}
3535

36-
static u32 xen_set_apic_id(unsigned int x)
36+
static u32 xen_set_apic_id(u32 x)
3737
{
3838
WARN_ON(1);
3939
return x;
4040
}
4141

42-
static unsigned int xen_get_apic_id(unsigned long x)
42+
static u32 xen_get_apic_id(u32 x)
4343
{
4444
return ((x)>>24) & 0xFFu;
4545
}

0 commit comments

Comments
 (0)