memblock: Allow memblock_init to be called early

The Xen setup code needs to call memblock_x86_reserve_range() very early,
so allow it to initialize the memblock subsystem before doing so. The
second memblock_init() is ignored.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
LKML-Reference: <4CACFDAD.3090900@goop.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

authored by Jeremy Fitzhardinge and committed by H. Peter Anvin 236260b9 153db80f

+9
+3
arch/x86/xen/enlighten.c
··· 30 30 #include <linux/console.h> 31 31 #include <linux/pci.h> 32 32 #include <linux/gfp.h> 33 + #include <linux/memblock.h> 33 34 34 35 #include <xen/xen.h> 35 36 #include <xen/interface/xen.h> ··· 1183 1182 1184 1183 local_irq_disable(); 1185 1184 early_boot_irqs_off(); 1185 + 1186 + memblock_init(); 1186 1187 1187 1188 xen_raw_console_write("mapping kernel into physical memory\n"); 1188 1189 pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages);
+6
mm/memblock.c
··· 752 752 753 753 void __init memblock_init(void) 754 754 { 755 + static int init_done __initdata = 0; 756 + 757 + if (init_done) 758 + return; 759 + init_done = 1; 760 + 755 761 /* Hookup the initial arrays */ 756 762 memblock.memory.regions = memblock_memory_init_regions; 757 763 memblock.memory.max = INIT_MEMBLOCK_REGIONS;