Hi,
This is a resend of the series to fix the uboot bug exposed by the removal of meminfo. I haven't gotten any acks though.
Please help with review/acks. Grant/Rob, I'd still like this to go through the devicetree tree if possible.
Thanks, Laura
Currently, early_init_dt_scan validates the header, sets the boot params, and scans for chosen/memory all in one function. Split this up into two separate functions (validation/setting boot params in one, scanning in another) to allow for additional setup between boot params and scanning the memory.
Signed-off-by: Laura Abbott lauraa@codeaurora.org --- drivers/of/fdt.c | 18 +++++++++++++++++- include/linux/of_fdt.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index c4cddf0..55bfca9 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -922,7 +922,7 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, } #endif
-bool __init early_init_dt_scan(void *params) +bool __init early_init_dt_verify(void *params) { if (!params) return false; @@ -936,6 +936,12 @@ bool __init early_init_dt_scan(void *params) return false; }
+ return true; +} + + +void __init early_init_dt_scan_all(void) +{ /* Retrieve various information from the /chosen node */ of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
@@ -944,7 +950,17 @@ bool __init early_init_dt_scan(void *params)
/* Setup memory, calling early_init_dt_add_memory_arch */ of_scan_flat_dt(early_init_dt_scan_memory, NULL); +} + +bool __init early_init_dt_scan(void *params) +{ + bool status; + + status = early_init_dt_verify(params); + if (!status) + return false;
+ early_init_dt_scan_all(); return true; }
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 0511789..d600993 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -73,6 +73,8 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname, int depth, void *data);
extern bool early_init_dt_scan(void *params); +extern bool early_init_dt_verify(void *params); +extern void early_init_dt_scan_all(void);
extern const char *of_flat_dt_get_machine_name(void); extern const void *of_flat_dt_match_machine(const void *default_match,
Buggy bootloaders may pass bogus memory entries in the devicetree. Add of_fdt_limit_memory to add an upper bound on the number of entries that can be present in the devicetree.
Signed-off-by: Laura Abbott lauraa@codeaurora.org --- drivers/of/fdt.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 1 + 2 files changed, 49 insertions(+)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 55bfca9..fd5db5a 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -26,6 +26,54 @@ #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #include <asm/page.h>
+/* + * of_fdt_limit_memory - limit the number of regions in the /memory node + * @limit: maximum entries + * + * Adjust the flattened device tree to have at most 'limit' number of + * memory entries in the /memory node. This function may be called + * any time after initial_boot_param is set. + */ +void of_fdt_limit_memory(int limit) +{ + int memory; + int len; + const void *val; + int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; + int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; + const uint32_t *addr_prop; + const uint32_t *size_prop; + int root_offset; + int cell_size; + + root_offset = fdt_path_offset(initial_boot_params, "/"); + if (root_offset < 0) + return; + + addr_prop = fdt_getprop(initial_boot_params, root_offset, + "#address-cells", NULL); + if (addr_prop) + nr_address_cells = fdt32_to_cpu(*addr_prop); + + size_prop = fdt_getprop(initial_boot_params, root_offset, + "#size-cells", NULL); + if (size_prop) + nr_size_cells = fdt32_to_cpu(*size_prop); + + cell_size = sizeof(uint32_t)*(nr_address_cells + nr_size_cells); + + memory = fdt_path_offset(initial_boot_params, "/memory"); + if (memory > 0) { + val = fdt_getprop(initial_boot_params, memory, "reg", &len); + if (len > limit*cell_size) { + len = limit*cell_size; + pr_debug("Limiting number of entries to %d\n", limit); + fdt_setprop(initial_boot_params, memory, "reg", val, + len); + } + } +} + /** * of_fdt_is_compatible - Return true if given node from the given blob has * compat in its compatible list diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index d600993..1aea25c 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -86,6 +86,7 @@ extern void unflatten_and_copy_device_tree(void); extern void early_init_devtree(void *); extern void early_get_first_memblock_info(void *, phys_addr_t *); 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 const char *of_flat_dt_get_machine_name(void) { return NULL; }
Commit 1c2f87c22566cd057bc8cde10c37ae9da1a1bb76 (ARM: 8025/1: Get rid of meminfo) dropped the upper bound on the number of memory banks that can be added as there was no technical need in the kernel. It turns out though, some bootloaders (specifically the arndale-octa exynos boards) may pass invalid memory information and rely on the kernel to not parse this data. This is a bug in the bootloader but we still need to work around this. Work around this by introducing a dt_fixup function. This function gets called before the flattened devicetree is scanned for memory and the like. In this fixup function for exynos, limit the maximum number of memory regions in the devicetree.
Signed-off-by: Laura Abbott lauraa@codeaurora.org --- arch/arm/include/asm/mach/arch.h | 1 + arch/arm/kernel/devtree.c | 7 ++++++- arch/arm/mach-exynos/exynos.c | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h index 060a75e..0406cb3 100644 --- a/arch/arm/include/asm/mach/arch.h +++ b/arch/arm/include/asm/mach/arch.h @@ -50,6 +50,7 @@ struct machine_desc { struct smp_operations *smp; /* SMP operations */ bool (*smp_init)(void); void (*fixup)(struct tag *, char **); + void (*dt_fixup)(void); void (*init_meminfo)(void); void (*reserve)(void);/* reserve mem blocks */ void (*map_io)(void);/* IO mapping function */ diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index e94a157..893db60 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -212,7 +212,7 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) mdesc_best = &__mach_desc_GENERIC_DT; #endif
- if (!dt_phys || !early_init_dt_scan(phys_to_virt(dt_phys))) + if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys))) return NULL;
mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach); @@ -237,6 +237,11 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) dump_machine_table(); /* does not return */ }
+ if (mdesc->dt_fixup) + mdesc->dt_fixup(); + + early_init_dt_scan_all(); + /* Change machine number to match the mdesc we're using */ __machine_arch_type = mdesc->nr;
diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c index f38cf7c..5a7b5c3 100644 --- a/arch/arm/mach-exynos/exynos.c +++ b/arch/arm/mach-exynos/exynos.c @@ -337,6 +337,15 @@ static void __init exynos_reserve(void) #endif }
+static void __init exynos_dt_fixup(void) +{ + /* + * Some versions of uboot pass garbage entries in the memory node, + * use the old CONFIG_ARM_NR_BANKS + */ + of_fdt_limit_memory(8); +} + DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)") /* Maintainer: Thomas Abraham thomas.abraham@linaro.org */ /* Maintainer: Kukjin Kim kgene.kim@samsung.com */ @@ -350,4 +359,5 @@ DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)") .dt_compat = exynos_dt_compat, .restart = exynos_restart, .reserve = exynos_reserve, + .dt_fixup = exynos_dt_fixup, MACHINE_END
Hi Laura,
Am 15.07.2014 19:03, schrieb Laura Abbott:
This is a resend of the series to fix the uboot bug exposed by the removal of meminfo. I haven't gotten any acks though.
Please help with review/acks. Grant/Rob, I'd still like this to go through the devicetree tree if possible.
Sorry for the delay in testing.
With this v2 applied on top of kgene's for-next branch (plus https://patchwork.kernel.org/patch/4297431/ as build fix) I get:
[ 9.699985] Unhandled fault: asynchronous external abort (0x211) at 0x00000000
Same for v1 that had worked okay before, so it's not your series, but it may explain why you haven't heard on v2 from the others yet.
Regards, Andreas
On Sunday, July 27, 2014, Andreas Färber afaerber@suse.de wrote:
Hi Laura,
Am 15.07.2014 19:03, schrieb Laura Abbott:
This is a resend of the series to fix the uboot bug exposed by the
removal
of meminfo. I haven't gotten any acks though.
Please help with review/acks. Grant/Rob, I'd still like this to go
through
the devicetree tree if possible.
Sorry for the delay in testing.
With this v2 applied on top of kgene's for-next branch (plus https://patchwork.kernel.org/patch/4297431/ as build fix) I get:
[ 9.699985] Unhandled fault: asynchronous external abort (0x211) at 0x00000000
If this is on Arndale octa board, please try disabling MCPM option.
Same for v1 that had worked okay before, so it's not your series, but it may explain why you haven't heard on v2 from the others yet.
Regards, Andreas
-- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org javascript:; More majordomo info at http://vger.kernel.org/majordomo-info.html
Am 27.07.2014 06:28, schrieb Sachin Kamat:
On Sunday, July 27, 2014, Andreas Färber <afaerber@suse.de mailto:afaerber@suse.de> wrote:
Hi Laura, Am 15.07.2014 19:03, schrieb Laura Abbott: > This is a resend of the series to fix the uboot bug exposed by the removal > of meminfo. I haven't gotten any acks though. > > Please help with review/acks. Grant/Rob, I'd still like this to go through > the devicetree tree if possible. Sorry for the delay in testing. With this v2 applied on top of kgene's for-next branch (plus https://patchwork.kernel.org/patch/4297431/ as build fix) I get: [ 9.699985] Unhandled fault: asynchronous external abort (0x211) at 0x00000000
If this is on Arndale octa board,
It is, sorry, that was the board that prompted the series.
please try disabling MCPM option.
Interestingly without MCPM I then get:
drivers/built-in.o: In function `bl_enter_powerdown': /home/andreas/linux/drivers/cpuidle/cpuidle-big_little.c:134: undefined reference to `mcpm_cpu_powered_up' drivers/built-in.o: In function `bl_powerdown_finisher': /home/andreas/linux/drivers/cpuidle/cpuidle-big_little.c:104: undefined reference to `mcpm_set_entry_vector' /home/andreas/linux/drivers/cpuidle/cpuidle-big_little.c:111: undefined reference to `mcpm_cpu_suspend' Makefile:885: recipe for target 'vmlinux' failed make: *** [vmlinux] Error 1
ARM_BIG_LITTLE_CPUIDLE seems to be lacking a dependency on MCPM.
Together they resolved the issue, thanks!
Tested-by: Andreas Färber afaerber@suse.de
Cheers, Andreas
On Tue, Jul 15, 2014 at 12:03 PM, Laura Abbott lauraa@codeaurora.org wrote:
Hi,
This is a resend of the series to fix the uboot bug exposed by the removal of meminfo. I haven't gotten any acks though.
Is the bug with ATAGs that get converted to DT in the decompressor or u-boot puts the wrong info in DT directly?
Rob
Please help with review/acks. Grant/Rob, I'd still like this to go through the devicetree tree if possible.
Thanks, Laura
-- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
On 7/26/2014 2:20 PM, Rob Herring wrote:
On Tue, Jul 15, 2014 at 12:03 PM, Laura Abbott lauraa@codeaurora.org wrote:
Hi,
This is a resend of the series to fix the uboot bug exposed by the removal of meminfo. I haven't gotten any acks though.
Is the bug with ATAGs that get converted to DT in the decompressor or u-boot puts the wrong info in DT directly?
I believe it's u-boot putting the wrong info in DT directly. See http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/266782.html
Thanks, Laura
On Mon, 28 Jul 2014 11:56:42 -0700, Laura Abbott lauraa@codeaurora.org wrote:
On 7/26/2014 2:20 PM, Rob Herring wrote:
On Tue, Jul 15, 2014 at 12:03 PM, Laura Abbott lauraa@codeaurora.org wrote:
Hi,
This is a resend of the series to fix the uboot bug exposed by the removal of meminfo. I haven't gotten any acks though.
Is the bug with ATAGs that get converted to DT in the decompressor or u-boot puts the wrong info in DT directly?
I believe it's u-boot putting the wrong info in DT directly. See http://lists.infradead.org/pipermail/linux-arm-kernel/2014-June/266782.html
I've picked up this series with some very minor changes. I'll ask Linus to pull it into v3.16 as a last minute fix.
g.
linaro-kernel@lists.linaro.org