Pull kmalloc into release branch
[pandora-kernel.git] / arch / ia64 / kernel / acpi.c
index 4722ec5..99761b8 100644 (file)
@@ -32,7 +32,6 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -68,8 +67,6 @@ EXPORT_SYMBOL(pm_power_off);
 unsigned char acpi_kbd_controller_present = 1;
 unsigned char acpi_legacy_devices;
 
-static unsigned int __initdata acpi_madt_rev;
-
 unsigned int acpi_cpei_override;
 unsigned int acpi_cpei_phys_cpuid;
 
@@ -243,6 +240,8 @@ acpi_parse_iosapic(acpi_table_entry_header * header, const unsigned long end)
        return iosapic_init(iosapic->address, iosapic->global_irq_base);
 }
 
+static unsigned int __initdata acpi_madt_rev;
+
 static int __init
 acpi_parse_plat_int_src(acpi_table_entry_header * header,
                        const unsigned long end)
@@ -415,11 +414,28 @@ static int __initdata srat_num_cpus;      /* number of cpus */
 static u32 __devinitdata pxm_flag[PXM_FLAG_LEN];
 #define pxm_bit_set(bit)       (set_bit(bit,(void *)pxm_flag))
 #define pxm_bit_test(bit)      (test_bit(bit,(void *)pxm_flag))
-/* maps to convert between proximity domain and logical node ID */
-int __devinitdata pxm_to_nid_map[MAX_PXM_DOMAINS];
-int __initdata nid_to_pxm_map[MAX_NUMNODES];
 static struct acpi_table_slit __initdata *slit_table;
 
+static int get_processor_proximity_domain(struct acpi_table_processor_affinity *pa)
+{
+       int pxm;
+
+       pxm = pa->proximity_domain;
+       if (ia64_platform_is("sn2"))
+               pxm += pa->reserved[0] << 8;
+       return pxm;
+}
+
+static int get_memory_proximity_domain(struct acpi_table_memory_affinity *ma)
+{
+       int pxm;
+
+       pxm = ma->proximity_domain;
+       if (ia64_platform_is("sn2"))
+               pxm += ma->reserved1[0] << 8;
+       return pxm;
+}
+
 /*
  * ACPI 2.0 SLIT (System Locality Information Table)
  * http://devresource.hp.com/devresource/Docs/TechPapers/IA64/slit.pdf
@@ -443,13 +459,20 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
 void __init
 acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
 {
+       int pxm;
+
+       if (!pa->flags.enabled)
+               return;
+
+       pxm = get_processor_proximity_domain(pa);
+
        /* record this node in proximity bitmap */
-       pxm_bit_set(pa->proximity_domain);
+       pxm_bit_set(pxm);
 
        node_cpuid[srat_num_cpus].phys_id =
            (pa->apic_id << 8) | (pa->lsapic_eid);
        /* nid should be overridden as logical node id later */
-       node_cpuid[srat_num_cpus].nid = pa->proximity_domain;
+       node_cpuid[srat_num_cpus].nid = pxm;
        srat_num_cpus++;
 }
 
@@ -457,10 +480,10 @@ void __init
 acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
 {
        unsigned long paddr, size;
-       u8 pxm;
+       int pxm;
        struct node_memblk_s *p, *q, *pend;
 
-       pxm = ma->proximity_domain;
+       pxm = get_memory_proximity_domain(ma);
 
        /* fill node memory chunk structure */
        paddr = ma->base_addr_hi;
@@ -506,22 +529,17 @@ void __init acpi_numa_arch_fixup(void)
         * MCD - This can probably be dropped now.  No need for pxm ID to node ID
         * mapping with sparse node numbering iff MAX_PXM_DOMAINS <= MAX_NUMNODES.
         */
-       /* calculate total number of nodes in system from PXM bitmap */
-       memset(pxm_to_nid_map, -1, sizeof(pxm_to_nid_map));
-       memset(nid_to_pxm_map, -1, sizeof(nid_to_pxm_map));
        nodes_clear(node_online_map);
        for (i = 0; i < MAX_PXM_DOMAINS; i++) {
                if (pxm_bit_test(i)) {
-                       int nid = num_online_nodes();
-                       pxm_to_nid_map[i] = nid;
-                       nid_to_pxm_map[nid] = i;
+                       int nid = acpi_map_pxm_to_node(i);
                        node_set_online(nid);
                }
        }
 
        /* set logical node id in memory chunk structure */
        for (i = 0; i < num_node_memblks; i++)
-               node_memblk[i].nid = pxm_to_nid_map[node_memblk[i].nid];
+               node_memblk[i].nid = pxm_to_node(node_memblk[i].nid);
 
        /* assign memory bank numbers for each chunk on each node */
        for_each_online_node(i) {
@@ -535,7 +553,7 @@ void __init acpi_numa_arch_fixup(void)
 
        /* set logical node id in cpu structure */
        for (i = 0; i < srat_num_cpus; i++)
-               node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid];
+               node_cpuid[i].nid = pxm_to_node(node_cpuid[i].nid);
 
        printk(KERN_INFO "Number of logical nodes in system = %d\n",
               num_online_nodes());
@@ -548,11 +566,11 @@ void __init acpi_numa_arch_fixup(void)
        for (i = 0; i < slit_table->localities; i++) {
                if (!pxm_bit_test(i))
                        continue;
-               node_from = pxm_to_nid_map[i];
+               node_from = pxm_to_node(i);
                for (j = 0; j < slit_table->localities; j++) {
                        if (!pxm_bit_test(j))
                                continue;
-                       node_to = pxm_to_nid_map[j];
+                       node_to = pxm_to_node(j);
                        node_distance(node_from, node_to) =
                            slit_table->entry[i * slit_table->localities + j];
                }
@@ -599,7 +617,7 @@ EXPORT_SYMBOL(acpi_unregister_gsi);
 static int __init acpi_parse_fadt(unsigned long phys_addr, unsigned long size)
 {
        struct acpi_table_header *fadt_header;
-       struct fadt_descriptor_rev2 *fadt;
+       struct fadt_descriptor *fadt;
 
        if (!phys_addr || !size)
                return -EINVAL;
@@ -608,7 +626,7 @@ static int __init acpi_parse_fadt(unsigned long phys_addr, unsigned long size)
        if (fadt_header->revision != 3)
                return -ENODEV; /* Only deal with ACPI 2.0 FADT */
 
-       fadt = (struct fadt_descriptor_rev2 *)fadt_header;
+       fadt = (struct fadt_descriptor *)fadt_header;
 
        if (!(fadt->iapc_boot_arch & BAF_8042_KEYBOARD_CONTROLLER))
                acpi_kbd_controller_present = 0;
@@ -624,9 +642,9 @@ unsigned long __init acpi_find_rsdp(void)
 {
        unsigned long rsdp_phys = 0;
 
-       if (efi.acpi20)
-               rsdp_phys = __pa(efi.acpi20);
-       else if (efi.acpi)
+       if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
+               rsdp_phys = efi.acpi20;
+       else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
                printk(KERN_WARNING PREFIX
                       "v1.0/r0.71 tables no longer supported\n");
        return rsdp_phys;
@@ -758,9 +776,9 @@ int acpi_map_cpu2node(acpi_handle handle, int cpu, long physid)
 
        /*
         * Assuming that the container driver would have set the proximity
-        * domain and would have initialized pxm_to_nid_map[pxm_id] && pxm_flag
+        * domain and would have initialized pxm_to_node(pxm_id) && pxm_flag
         */
-       node_cpuid[cpu].nid = (pxm_id < 0) ? 0 : pxm_to_nid_map[pxm_id];
+       node_cpuid[cpu].nid = (pxm_id < 0) ? 0 : pxm_to_node(pxm_id);
 
        node_cpuid[cpu].phys_id = physid;
 #endif
@@ -838,7 +856,7 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu)
        obj = buffer.pointer;
        if (obj->type != ACPI_TYPE_BUFFER ||
            obj->buffer.length < sizeof(*lsapic)) {
-               acpi_os_free(buffer.pointer);
+               kfree(buffer.pointer);
                return -EINVAL;
        }
 
@@ -846,13 +864,13 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu)
 
        if ((lsapic->header.type != ACPI_MADT_LSAPIC) ||
            (!lsapic->flags.enabled)) {
-               acpi_os_free(buffer.pointer);
+               kfree(buffer.pointer);
                return -EINVAL;
        }
 
        physid = ((lsapic->id << 8) | (lsapic->eid));
 
-       acpi_os_free(buffer.pointer);
+       kfree(buffer.pointer);
        buffer.length = ACPI_ALLOCATE_BUFFER;
        buffer.pointer = NULL;
 
@@ -916,20 +934,20 @@ acpi_map_iosapic(acpi_handle handle, u32 depth, void *context, void **ret)
        obj = buffer.pointer;
        if (obj->type != ACPI_TYPE_BUFFER ||
            obj->buffer.length < sizeof(*iosapic)) {
-               acpi_os_free(buffer.pointer);
+               kfree(buffer.pointer);
                return AE_OK;
        }
 
        iosapic = (struct acpi_table_iosapic *)obj->buffer.pointer;
 
        if (iosapic->header.type != ACPI_MADT_IOSAPIC) {
-               acpi_os_free(buffer.pointer);
+               kfree(buffer.pointer);
                return AE_OK;
        }
 
        gsi_base = iosapic->global_irq_base;
 
-       acpi_os_free(buffer.pointer);
+       kfree(buffer.pointer);
 
        /*
         * OK, it's an IOSAPIC MADT entry, look for a _PXM value to tell
@@ -939,7 +957,7 @@ acpi_map_iosapic(acpi_handle handle, u32 depth, void *context, void **ret)
        if (pxm < 0)
                return AE_OK;
 
-       node = pxm_to_nid_map[pxm];
+       node = pxm_to_node(pxm);
 
        if (node >= MAX_NUMNODES || !node_online(node) ||
            cpus_empty(node_to_cpumask(node)))