Skip to content

Commit 5a12a59

Browse files
labbottglikely
authored andcommitted
arm: Add devicetree fixup machine function
Commit 1c2f87c (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 <[email protected]> Tested-by: Andreas Färber <[email protected]> [glikely: Added a comment and fixed up function name] Signed-off-by: Grant Likely <[email protected]>
1 parent 704033c commit 5a12a59

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

arch/arm/include/asm/mach/arch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct machine_desc {
5050
struct smp_operations *smp; /* SMP operations */
5151
bool (*smp_init)(void);
5252
void (*fixup)(struct tag *, char **);
53+
void (*dt_fixup)(void);
5354
void (*init_meminfo)(void);
5455
void (*reserve)(void);/* reserve mem blocks */
5556
void (*map_io)(void);/* IO mapping function */

arch/arm/kernel/devtree.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
212212
mdesc_best = &__mach_desc_GENERIC_DT;
213213
#endif
214214

215-
if (!dt_phys || !early_init_dt_scan(phys_to_virt(dt_phys)))
215+
if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys)))
216216
return NULL;
217217

218218
mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);
@@ -237,6 +237,12 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
237237
dump_machine_table(); /* does not return */
238238
}
239239

240+
/* We really don't want to do this, but sometimes firmware provides buggy data */
241+
if (mdesc->dt_fixup)
242+
mdesc->dt_fixup();
243+
244+
early_init_dt_scan_nodes();
245+
240246
/* Change machine number to match the mdesc we're using */
241247
__machine_arch_type = mdesc->nr;
242248

arch/arm/mach-exynos/exynos.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,15 @@ static void __init exynos_reserve(void)
335335
#endif
336336
}
337337

338+
static void __init exynos_dt_fixup(void)
339+
{
340+
/*
341+
* Some versions of uboot pass garbage entries in the memory node,
342+
* use the old CONFIG_ARM_NR_BANKS
343+
*/
344+
of_fdt_limit_memory(8);
345+
}
346+
338347
DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
339348
/* Maintainer: Thomas Abraham <[email protected]> */
340349
/* Maintainer: Kukjin Kim <[email protected]> */
@@ -348,4 +357,5 @@ DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
348357
.dt_compat = exynos_dt_compat,
349358
.restart = exynos_restart,
350359
.reserve = exynos_reserve,
360+
.dt_fixup = exynos_dt_fixup,
351361
MACHINE_END

0 commit comments

Comments
 (0)