Skip to contentSkip to conversation

Fix for buggy u-boot memory banks

PATCH RESEND Superseded Laura Abbott 5 participants 10 messages Jul 15, 2014 – Jul 30, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Fix for buggy u-boot memory banks

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

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw

PATCH RESEND v2 1/3 of: Split early_init_dt_scan into two parts

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.

---
 drivers/of/fdt.c       | 18 +++++++++++++++++-
 include/linux/of_fdt.h |  2 ++
 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/of/fdt.c +17 -1
index c4cddf0..55bfca9 100644
@@ -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;
 }
 
include/linux/of_fdt.h +2 -0
index 0511789..d600993 100644
@@ -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,
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#2 lore raw

PATCH RESEND v2 2/3 of: Add memory limiting function for flattened devicetrees

In reply to Laura Abbott

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.

---
 drivers/of/fdt.c       | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of_fdt.h |  1 +
 2 files changed, 49 insertions(+)
drivers/of/fdt.c +48 -0
index 55bfca9..fd5db5a 100644
@@ -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
include/linux/of_fdt.h +1 -0
index d600993..1aea25c 100644
@@ -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; }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#3 lore raw

PATCH RESEND v2 3/3 arm: Add devicetree fixup machine function

In reply to Laura Abbott

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.

---
 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(-)
arch/arm/include/asm/mach/arch.h +1 -0
index 060a75e..0406cb3 100644
@@ -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	*/
arch/arm/kernel/devtree.c +6 -1
index e94a157..893db60 100644
@@ -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;
 
arch/arm/mach-exynos/exynos.c +10 -0
index f38cf7c..5a7b5c3 100644
@@ -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 <[email protected]> */
 	/* Maintainer: Kukjin Kim <[email protected]> */
@@ -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
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#4 lore raw

v2 cover Fix for buggy u-boot memory banks

In reply to Laura Abbott

Hi Laura,

Am 15.07.2014 19:03, schrieb Laura Abbott:

Quoted 5 lines

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

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imend?rffer; HRB 16746 AG N?rnberg
#5 lore raw
Quoted 11 lines · Andreas Färber

Hi Laura,

Am 15.07.2014 19:03, schrieb Laura Abbott:

Quoted 1 line

This is a resend of the series to fix the uboot bug exposed by the

removal

Quoted 3 lines

of meminfo. I haven't gotten any acks though.

Please help with review/acks. Grant/Rob, I'd still like this to go

through

Quoted 1 line

the devicetree tree if possible.

Quoted 9 lines

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.

Quoted 15 lines

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 [email protected] <javascript:;> More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Regards,
Sachin.
#6 lore raw

v2 cover Fix for buggy u-boot memory banks

Am 27.07.2014 06:28, schrieb Sachin Kamat:

Quoted 18 lines

On Sunday, July 27, 2014, Andreas F?rber <[email protected] <mailto:[email protected]>> 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.

Quoted 8 lines

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.

Quoted 1 line

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!

Cheers,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imend?rffer; HRB 16746 AG N?rnberg
#7 lore raw

v2 cover Fix for buggy u-boot memory banks

In reply to Laura Abbott
Quoted 4 lines · Laura Abbott

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

Quoted 11 lines

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

#8 lore raw

v2 cover Fix for buggy u-boot memory banks

Quoted 9 lines · Rob Herring
Quoted 4 lines · Laura Abbott

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

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#9 lore raw

v2 cover Fix for buggy u-boot memory banks

Quoted 7 lines · Laura Abbott
Quoted 6 lines · Rob Herring
Quoted 4 lines · Laura Abbott

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.

Quoted 6 lines
Quoted 3 lines

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.