]> err.no Git - linux-2.6/commitdiff
[PATCH] i386: Support physical cpu hotplug for x86_64
authorAshok Raj <ashok.raj@intel.com>
Tue, 26 Sep 2006 08:52:35 +0000 (10:52 +0200)
committerAndi Kleen <andi@basil.nowhere.org>
Tue, 26 Sep 2006 08:52:35 +0000 (10:52 +0200)
This patch enables ACPI based physical CPU hotplug support for x86_64.
Implements acpi_map_lsapic() and acpi_unmap_lsapic() to support physical cpu
hotplug.

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Andi Kleen <ak@muc.de>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
arch/i386/kernel/acpi/boot.c
arch/i386/kernel/mpparse.c
include/asm-i386/smp.h

index 0fba420d668a12f673fd27c1603eeb3394678098..8a6c5b412348385384353dbdca4e867afad25303 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/acpi.h>
 #include <linux/efi.h>
+#include <linux/cpumask.h>
 #include <linux/module.h>
 #include <linux/dmi.h>
 #include <linux/irq.h>
@@ -512,16 +513,76 @@ EXPORT_SYMBOL(acpi_register_gsi);
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 int acpi_map_lsapic(acpi_handle handle, int *pcpu)
 {
-       /* TBD */
-       return -EINVAL;
+       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       union acpi_object *obj;
+       struct acpi_table_lapic *lapic;
+       cpumask_t tmp_map, new_map;
+       u8 physid;
+       int cpu;
+
+       if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
+               return -EINVAL;
+
+       if (!buffer.length || !buffer.pointer)
+               return -EINVAL;
+
+       obj = buffer.pointer;
+       if (obj->type != ACPI_TYPE_BUFFER ||
+           obj->buffer.length < sizeof(*lapic)) {
+               kfree(buffer.pointer);
+               return -EINVAL;
+       }
+
+       lapic = (struct acpi_table_lapic *)obj->buffer.pointer;
+
+       if ((lapic->header.type != ACPI_MADT_LAPIC) ||
+           (!lapic->flags.enabled)) {
+               kfree(buffer.pointer);
+               return -EINVAL;
+       }
+
+       physid = lapic->id;
+
+       kfree(buffer.pointer);
+       buffer.length = ACPI_ALLOCATE_BUFFER;
+       buffer.pointer = NULL;
+
+       tmp_map = cpu_present_map;
+       mp_register_lapic(physid, lapic->flags.enabled);
+
+       /*
+        * If mp_register_lapic successfully generates a new logical cpu
+        * number, then the following will get us exactly what was mapped
+        */
+       cpus_andnot(new_map, cpu_present_map, tmp_map);
+       if (cpus_empty(new_map)) {
+               printk ("Unable to map lapic to logical cpu number\n");
+               return -EINVAL;
+       }
+
+       cpu = first_cpu(new_map);
+
+       *pcpu = cpu;
+       return 0;
 }
 
 EXPORT_SYMBOL(acpi_map_lsapic);
 
 int acpi_unmap_lsapic(int cpu)
 {
-       /* TBD */
-       return -EINVAL;
+       int i;
+
+       for_each_possible_cpu(i) {
+               if (x86_acpiid_to_apicid[i] == x86_cpu_to_apicid[cpu]) {
+                       x86_acpiid_to_apicid[i] = -1;
+                       break;
+               }
+       }
+       x86_cpu_to_apicid[cpu] = -1;
+       cpu_clear(cpu, cpu_present_map);
+       num_processors--;
+
+       return (0);
 }
 
 EXPORT_SYMBOL(acpi_unmap_lsapic);
index 772a4233bfe674cd38d4b3c2b3de3354f53e8a4f..442aaf8c77ebf593fd249f9f4e69db8df3070be9 100644 (file)
@@ -69,7 +69,7 @@ unsigned int def_to_bigsmp = 0;
 /* Processor that is doing the boot up */
 unsigned int boot_cpu_physical_apicid = -1U;
 /* Internal processor count */
-static unsigned int __devinitdata num_processors;
+unsigned int __cpuinitdata num_processors;
 
 /* Bitmask of physically existing CPUs */
 physid_mask_t phys_cpu_present_map;
index f87826039a5118eeef7e2c033295ef83f09657b0..32ac8c91d5c5ccb2e8856ee2a6943d59609d090e 100644 (file)
@@ -84,6 +84,7 @@ static inline int hard_smp_processor_id(void)
 
 extern int __cpu_disable(void);
 extern void __cpu_die(unsigned int cpu);
+extern unsigned int num_processors;
 
 #endif /* !__ASSEMBLY__ */