Skip to content

Commit 8aa2a41

Browse files
committed
x86/apic: Use u32 for cpu_present_to_apicid()
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 and fixup a few related usage sites for consistency sake. 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]> Reviewed-by: Arjan van de Ven <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5d376b8 commit 8aa2a41

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

arch/x86/include/asm/apic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ struct apic {
295295
bool (*check_apicid_used)(physid_mask_t *map, u32 apicid);
296296
void (*init_apic_ldr)(void);
297297
void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap);
298-
int (*cpu_present_to_apicid)(int mps_cpu);
298+
u32 (*cpu_present_to_apicid)(int mps_cpu);
299299
int (*phys_pkg_id)(int cpuid_apic, int index_msb);
300300

301301
u32 (*get_apic_id)(unsigned long x);
@@ -539,7 +539,7 @@ extern u32 apic_default_calc_apicid(unsigned int cpu);
539539
extern u32 apic_flat_calc_apicid(unsigned int cpu);
540540

541541
extern void default_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap);
542-
extern int default_cpu_present_to_apicid(int mps_cpu);
542+
extern u32 default_cpu_present_to_apicid(int mps_cpu);
543543

544544
#else /* CONFIG_X86_LOCAL_APIC */
545545

arch/x86/kernel/apic/apic_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void default_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap)
2828
*retmap = *phys_map;
2929
}
3030

31-
int default_cpu_present_to_apicid(int mps_cpu)
31+
u32 default_cpu_present_to_apicid(int mps_cpu)
3232
{
3333
if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
3434
return (int)per_cpu(x86_cpu_to_apicid, mps_cpu);

arch/x86/kernel/cpu/common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,8 @@ static void generic_identify(struct cpuinfo_x86 *c)
17871787
static void validate_apic_and_package_id(struct cpuinfo_x86 *c)
17881788
{
17891789
#ifdef CONFIG_SMP
1790-
unsigned int apicid, cpu = smp_processor_id();
1790+
unsigned int cpu = smp_processor_id();
1791+
u32 apicid;
17911792

17921793
apicid = apic->cpu_present_to_apicid(cpu);
17931794

arch/x86/kernel/smpboot.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ static void __init smp_quirk_init_udelay(void)
803803
/*
804804
* Wake up AP by INIT, INIT, STARTUP sequence.
805805
*/
806-
static void send_init_sequence(int phys_apicid)
806+
static void send_init_sequence(u32 phys_apicid)
807807
{
808808
int maxlvt = lapic_get_maxlvt();
809809

@@ -829,7 +829,7 @@ static void send_init_sequence(int phys_apicid)
829829
/*
830830
* Wake up AP by INIT, INIT, STARTUP sequence.
831831
*/
832-
static int wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
832+
static int wakeup_secondary_cpu_via_init(u32 phys_apicid, unsigned long start_eip)
833833
{
834834
unsigned long send_status = 0, accept_status = 0;
835835
int num_starts, j, maxlvt;
@@ -976,7 +976,7 @@ int common_cpu_up(unsigned int cpu, struct task_struct *idle)
976976
* Returns zero if startup was successfully sent, else error code from
977977
* ->wakeup_secondary_cpu.
978978
*/
979-
static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
979+
static int do_boot_cpu(u32 apicid, int cpu, struct task_struct *idle)
980980
{
981981
unsigned long start_ip = real_mode_header->trampoline_start;
982982
int ret;
@@ -1044,7 +1044,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
10441044

10451045
int native_kick_ap(unsigned int cpu, struct task_struct *tidle)
10461046
{
1047-
int apicid = apic->cpu_present_to_apicid(cpu);
1047+
u32 apicid = apic->cpu_present_to_apicid(cpu);
10481048
int err;
10491049

10501050
lockdep_assert_irqs_enabled();
@@ -1237,7 +1237,7 @@ void arch_thaw_secondary_cpus_end(void)
12371237
bool smp_park_other_cpus_in_init(void)
12381238
{
12391239
unsigned int cpu, this_cpu = smp_processor_id();
1240-
unsigned int apicid;
1240+
u32 apicid;
12411241

12421242
if (apic->wakeup_secondary_cpu_64 || apic->wakeup_secondary_cpu)
12431243
return false;

arch/x86/xen/apic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static int xen_phys_pkg_id(int initial_apic_id, int index_msb)
115115
return initial_apic_id >> index_msb;
116116
}
117117

118-
static int xen_cpu_present_to_apicid(int cpu)
118+
static u32 xen_cpu_present_to_apicid(int cpu)
119119
{
120120
if (cpu_present(cpu))
121121
return cpu_data(cpu).topo.apicid;

0 commit comments

Comments
 (0)