Pull video into test branch
[linux-drm-fsl-dcu.git] / arch / i386 / mm / discontig.c
index 51e3739dd22700f13a28a0627163fcc6bfb94bb0..e0c390d6ceb526464d3c3b220e0fdc59f138ec8e 100644 (file)
@@ -153,8 +153,7 @@ static void __init find_max_pfn_node(int nid)
         */
        if (node_start_pfn[nid] > max_pfn)
                node_start_pfn[nid] = max_pfn;
-       if (node_start_pfn[nid] > node_end_pfn[nid])
-               BUG();
+       BUG_ON(node_start_pfn[nid] > node_end_pfn[nid]);
 }
 
 /* 
@@ -169,7 +168,7 @@ static void __init allocate_pgdat(int nid)
        if (nid && node_has_online_mem(nid))
                NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid];
        else {
-               NODE_DATA(nid) = (pg_data_t *)(__va(min_low_pfn << PAGE_SHIFT));
+               NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(min_low_pfn));
                min_low_pfn += PFN_UP(sizeof(pg_data_t));
        }
 }
@@ -357,11 +356,12 @@ void __init numa_kva_reserve(void)
 void __init zone_sizes_init(void)
 {
        int nid;
-       unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-               max_low_pfn,
-               highend_pfn
-       };
+       unsigned long max_zone_pfns[MAX_NR_ZONES];
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+       max_zone_pfns[ZONE_DMA] =
+               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+       max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 
        /* If SRAT has not registered memory, register it now */
        if (find_max_pfn_with_active_regions() == 0) {
@@ -405,3 +405,31 @@ void __init set_highmem_pages_init(int bad_ppro)
        totalram_pages += totalhigh_pages;
 #endif
 }
+
+#ifdef CONFIG_MEMORY_HOTPLUG
+int paddr_to_nid(u64 addr)
+{
+       int nid;
+       unsigned long pfn = PFN_DOWN(addr);
+
+       for_each_node(nid)
+               if (node_start_pfn[nid] <= pfn &&
+                   pfn < node_end_pfn[nid])
+                       return nid;
+
+       return -1;
+}
+
+/*
+ * This function is used to ask node id BEFORE memmap and mem_section's
+ * initialization (pfn_to_nid() can't be used yet).
+ * If _PXM is not defined on ACPI's DSDT, node id must be found by this.
+ */
+int memory_add_physaddr_to_nid(u64 addr)
+{
+       int nid = paddr_to_nid(addr);
+       return (nid >= 0) ? nid : 0;
+}
+
+EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
+#endif