aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2015-06-01 07:40:31 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2015-06-02 11:31:25 -0400
commit24bbd929e6b9e62afd263c42b4318d3b603c956c (patch)
tree78658f1cf02b8c511195ad9a6c927b71ee143625
parentd00a3810c16207d2541b7796a73cca5a24ea3742 (diff)
of/fdt: split off FDT self reservation from memreserve processing
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>
-rw-r--r--arch/arm/mm/init.c1
-rw-r--r--arch/arm64/mm/init.c1
-rw-r--r--arch/powerpc/kernel/prom.c1
-rw-r--r--drivers/of/fdt.c19
-rw-r--r--include/linux/of_fdt.h2
5 files changed, 19 insertions, 5 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index be92fa0f2f35..8a63b4cdc0f2 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -268,6 +268,7 @@ void __init arm_memblock_init(const struct machine_desc *mdesc)
268 if (mdesc->reserve) 268 if (mdesc->reserve)
269 mdesc->reserve(); 269 mdesc->reserve();
270 270
271 early_init_fdt_reserve_self();
271 early_init_fdt_scan_reserved_mem(); 272 early_init_fdt_scan_reserved_mem();
272 273
273 /* reserve memory for DMA contiguous allocations */ 274 /* reserve memory for DMA contiguous allocations */
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 597831bdddf3..89a05f467ffb 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -170,6 +170,7 @@ void __init arm64_memblock_init(void)
170 memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start); 170 memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start);
171#endif 171#endif
172 172
173 early_init_fdt_reserve_self();
173 early_init_fdt_scan_reserved_mem(); 174 early_init_fdt_scan_reserved_mem();
174 175
175 /* 4GB maximum for 32-bit only capable devices */ 176 /* 4GB maximum for 32-bit only capable devices */
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 308c5e15676b..51ea36f79307 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -573,6 +573,7 @@ static void __init early_reserve_mem_dt(void)
573 int len; 573 int len;
574 const __be32 *prop; 574 const __be32 *prop;
575 575
576 early_init_fdt_reserve_self();
576 early_init_fdt_scan_reserved_mem(); 577 early_init_fdt_scan_reserved_mem();
577 578
578 dt_root = of_get_flat_dt_root(); 579 dt_root = of_get_flat_dt_root();
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index cde35c5d0191..f2dd23a32267 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -580,11 +580,6 @@ void __init early_init_fdt_scan_reserved_mem(void)
580 if (!initial_boot_params) 580 if (!initial_boot_params)
581 return; 581 return;
582 582
583 /* Reserve the dtb region */
584 early_init_dt_reserve_memory_arch(__pa(initial_boot_params),
585 fdt_totalsize(initial_boot_params),
586 0);
587
588 /* Process header /memreserve/ fields */ 583 /* Process header /memreserve/ fields */
589 for (n = 0; ; n++) { 584 for (n = 0; ; n++) {
590 fdt_get_mem_rsv(initial_boot_params, n, &base, &size); 585 fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
@@ -598,6 +593,20 @@ void __init early_init_fdt_scan_reserved_mem(void)
598} 593}
599 594
600/** 595/**
596 * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob
597 */
598void __init early_init_fdt_reserve_self(void)
599{
600 if (!initial_boot_params)
601 return;
602
603 /* Reserve the dtb region */
604 early_init_dt_reserve_memory_arch(__pa(initial_boot_params),
605 fdt_totalsize(initial_boot_params),
606 0);
607}
608
609/**
601 * of_scan_flat_dt - scan flattened tree blob and call callback on each. 610 * of_scan_flat_dt - scan flattened tree blob and call callback on each.
602 * @it: callback function 611 * @it: callback function
603 * @data: context data pointer 612 * @data: context data pointer
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 587ee507965d..fd627a58068f 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -64,6 +64,7 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
64extern int early_init_dt_scan_memory(unsigned long node, const char *uname, 64extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
65 int depth, void *data); 65 int depth, void *data);
66extern void early_init_fdt_scan_reserved_mem(void); 66extern void early_init_fdt_scan_reserved_mem(void);
67extern void early_init_fdt_reserve_self(void);
67extern void early_init_dt_add_memory_arch(u64 base, u64 size); 68extern void early_init_dt_add_memory_arch(u64 base, u64 size);
68extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, 69extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size,
69 bool no_map); 70 bool no_map);
@@ -91,6 +92,7 @@ extern u64 fdt_translate_address(const void *blob, int node_offset);
91extern void of_fdt_limit_memory(int limit); 92extern void of_fdt_limit_memory(int limit);
92#else /* CONFIG_OF_FLATTREE */ 93#else /* CONFIG_OF_FLATTREE */
93static inline void early_init_fdt_scan_reserved_mem(void) {} 94static inline void early_init_fdt_scan_reserved_mem(void) {}
95static inline void early_init_fdt_reserve_self(void) {}
94static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } 96static inline const char *of_flat_dt_get_machine_name(void) { return NULL; }
95static inline void unflatten_device_tree(void) {} 97static inline void unflatten_device_tree(void) {}
96static inline void unflatten_and_copy_device_tree(void) {} 98static inline void unflatten_and_copy_device_tree(void) {}