of/fdt: split off FDT self reservation from memreserve processing
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 1 Jun 2015 11:40:31 +0000 (13:40 +0200)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 2 Jun 2015 15:31:25 +0000 (16:31 +0100)
This splits off the reservation of the memory occupied by the FDT
binary itself from the processing of the memory reservations it
contains. This is necessary because the physical address of the FDT,
which is needed to perform the reservation, may not be known to the
FDT driver core, i.e., it may be mapped outside the linear direct
mapping, in which case __pa() returns a bogus value.

Cc: Russell King <linux@arm.linux.org.uk>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm/mm/init.c
arch/arm64/mm/init.c
arch/powerpc/kernel/prom.c
drivers/of/fdt.c
include/linux/of_fdt.h

index be92fa0f2f35b58cc46004f371c83ad443fe6862..8a63b4cdc0f27d0fa7cf69f0bb1ffa51b6289e39 100644 (file)
@@ -268,6 +268,7 @@ void __init arm_memblock_init(const struct machine_desc *mdesc)
        if (mdesc->reserve)
                mdesc->reserve();
 
+       early_init_fdt_reserve_self();
        early_init_fdt_scan_reserved_mem();
 
        /* reserve memory for DMA contiguous allocations */
index 597831bdddf3db2c7d8f44e4d33fbc13bcb286cb..89a05f467ffb07470af0d668ac4160bcf79018f9 100644 (file)
@@ -170,6 +170,7 @@ void __init arm64_memblock_init(void)
                memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start);
 #endif
 
+       early_init_fdt_reserve_self();
        early_init_fdt_scan_reserved_mem();
 
        /* 4GB maximum for 32-bit only capable devices */
index 308c5e15676b9160141ddcd86939c82f91029f3f..51ea36f793079a99bb0c1ac76f5797f2ff24ad55 100644 (file)
@@ -573,6 +573,7 @@ static void __init early_reserve_mem_dt(void)
        int len;
        const __be32 *prop;
 
+       early_init_fdt_reserve_self();
        early_init_fdt_scan_reserved_mem();
 
        dt_root = of_get_flat_dt_root();
index cde35c5d0191bd5950c7953d5b8e88a2d139306f..f2dd23a32267d0476104af2547084d36d7d834f9 100644 (file)
@@ -580,11 +580,6 @@ void __init early_init_fdt_scan_reserved_mem(void)
        if (!initial_boot_params)
                return;
 
-       /* Reserve the dtb region */
-       early_init_dt_reserve_memory_arch(__pa(initial_boot_params),
-                                         fdt_totalsize(initial_boot_params),
-                                         0);
-
        /* Process header /memreserve/ fields */
        for (n = 0; ; n++) {
                fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
@@ -597,6 +592,20 @@ void __init early_init_fdt_scan_reserved_mem(void)
        fdt_init_reserved_mem();
 }
 
+/**
+ * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob
+ */
+void __init early_init_fdt_reserve_self(void)
+{
+       if (!initial_boot_params)
+               return;
+
+       /* Reserve the dtb region */
+       early_init_dt_reserve_memory_arch(__pa(initial_boot_params),
+                                         fdt_totalsize(initial_boot_params),
+                                         0);
+}
+
 /**
  * of_scan_flat_dt - scan flattened tree blob and call callback on each.
  * @it: callback function
index 587ee507965d78a1b16112a0e3c0bba7856f1d3e..fd627a58068f3473a58240064efd7ed7171ebfad 100644 (file)
@@ -64,6 +64,7 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
 extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
                                     int depth, void *data);
 extern void early_init_fdt_scan_reserved_mem(void);
+extern void early_init_fdt_reserve_self(void);
 extern void early_init_dt_add_memory_arch(u64 base, u64 size);
 extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size,
                                             bool no_map);
@@ -91,6 +92,7 @@ extern u64 fdt_translate_address(const void *blob, int node_offset);
 extern void of_fdt_limit_memory(int limit);
 #else /* CONFIG_OF_FLATTREE */
 static inline void early_init_fdt_scan_reserved_mem(void) {}
+static inline void early_init_fdt_reserve_self(void) {}
 static inline const char *of_flat_dt_get_machine_name(void) { return NULL; }
 static inline void unflatten_device_tree(void) {}
 static inline void unflatten_and_copy_device_tree(void) {}