diff options
Diffstat (limited to 'arch/i386/kernel/smp.c')
-rw-r--r-- | arch/i386/kernel/smp.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c index 465188e2d701..1b080ab8a49f 100644 --- a/arch/i386/kernel/smp.c +++ b/arch/i386/kernel/smp.c | |||
@@ -700,3 +700,30 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, | |||
700 | return 0; | 700 | return 0; |
701 | } | 701 | } |
702 | EXPORT_SYMBOL(smp_call_function_single); | 702 | EXPORT_SYMBOL(smp_call_function_single); |
703 | |||
704 | static int convert_apicid_to_cpu(int apic_id) | ||
705 | { | ||
706 | int i; | ||
707 | |||
708 | for (i = 0; i < NR_CPUS; i++) { | ||
709 | if (x86_cpu_to_apicid[i] == apic_id) | ||
710 | return i; | ||
711 | } | ||
712 | return -1; | ||
713 | } | ||
714 | |||
715 | int safe_smp_processor_id(void) | ||
716 | { | ||
717 | int apicid, cpuid; | ||
718 | |||
719 | if (!boot_cpu_has(X86_FEATURE_APIC)) | ||
720 | return 0; | ||
721 | |||
722 | apicid = hard_smp_processor_id(); | ||
723 | if (apicid == BAD_APICID) | ||
724 | return 0; | ||
725 | |||
726 | cpuid = convert_apicid_to_cpu(apicid); | ||
727 | |||
728 | return cpuid >= 0 ? cpuid : 0; | ||
729 | } | ||