Message ID | 53AC77A2.4090207@codeaurora.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 06/27/2014 01:12 AM, Laura Abbott wrote: > > +static unsigned int bank_cnt; > +static unsigned int max_cnt; > + > int __init arm_add_memory(u64 start, u64 size) > { > u64 aligned_start; > > /* > + * Some buggy bootloaders rely on the old meminfo behavior of not adding > + * more than n banks since anything past that may contain invalid data. > + */ > + if (bank_cnt >= max_cnt) { > + pr_crit("Max banks too low, ignoring memory at 0x%08llx\n", > + (long long)start); > + return -EINVAL; > + } > + > + bank_cnt++; > + > + /* > * Ensure that start/size are aligned to a page boundary. > * Size is appropriately rounded down, start is rounded up. > */ > @@ -879,6 +894,7 @@ void __init setup_arch(char **cmdline_p) > mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type); > machine_desc = mdesc; > machine_name = mdesc->name; > + max_cnt = mdesc->bank_limit; arm_add_memory is getting called before this is being set, resulting in none of the memory banks getting added[1]. setup_machine_fdt -> early_init_dt_scan -> early_init_dt_scan_memory Would it make sense to re-introduce the config option ARM_NR_BANKS and replace max_cnt with NR_BANKS? [1] http://pastebin.com/MawYD7kb > > if (mdesc->reboot_mode != REBOOT_HARD) > reboot_mode = mdesc->reboot_mode; > diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c > index f38cf7c..91283fd 100644 > --- a/arch/arm/mach-exynos/exynos.c > +++ b/arch/arm/mach-exynos/exynos.c > @@ -350,4 +350,5 @@ DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)") > .dt_compat = exynos_dt_compat, > .restart = exynos_restart, > .reserve = exynos_reserve, > + .bank_limit = 8, > MACHINE_END >
On 6/26/2014 8:06 PM, Tushar Behera wrote: > On 06/27/2014 01:12 AM, Laura Abbott wrote: > >> >> +static unsigned int bank_cnt; >> +static unsigned int max_cnt; >> + >> int __init arm_add_memory(u64 start, u64 size) >> { >> u64 aligned_start; >> >> /* >> + * Some buggy bootloaders rely on the old meminfo behavior of not adding >> + * more than n banks since anything past that may contain invalid data. >> + */ >> + if (bank_cnt >= max_cnt) { >> + pr_crit("Max banks too low, ignoring memory at 0x%08llx\n", >> + (long long)start); >> + return -EINVAL; >> + } >> + >> + bank_cnt++; >> + >> + /* >> * Ensure that start/size are aligned to a page boundary. >> * Size is appropriately rounded down, start is rounded up. >> */ >> @@ -879,6 +894,7 @@ void __init setup_arch(char **cmdline_p) >> mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type); >> machine_desc = mdesc; >> machine_name = mdesc->name; >> + max_cnt = mdesc->bank_limit; > > arm_add_memory is getting called before this is being set, resulting in > none of the memory banks getting added[1]. > > setup_machine_fdt -> early_init_dt_scan -> early_init_dt_scan_memory > > Would it make sense to re-introduce the config option ARM_NR_BANKS and > replace max_cnt with NR_BANKS? > > [1] http://pastebin.com/MawYD7kb > I was hoping to avoid re-introducing the config option but that may be the case if we can't make the machine_info work. I'll take a better look tomorrow. Thanks, Laura
On Fri, Jun 27, 2014 at 02:09:58AM -0700, Laura Abbott wrote: > On 6/26/2014 8:06 PM, Tushar Behera wrote: >> arm_add_memory is getting called before this is being set, resulting in >> none of the memory banks getting added[1]. >> >> setup_machine_fdt -> early_init_dt_scan -> early_init_dt_scan_memory >> >> Would it make sense to re-introduce the config option ARM_NR_BANKS and >> replace max_cnt with NR_BANKS? >> >> [1] http://pastebin.com/MawYD7kb >> > > I was hoping to avoid re-introducing the config option but that may be > the case if we can't make the machine_info work. I'll take a better > look tomorrow. The problem with the config option is that it's not single zImage friendly.
diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h index 060a75e..2a436ac 100644 --- a/arch/arm/include/asm/mach/arch.h +++ b/arch/arm/include/asm/mach/arch.h @@ -40,6 +40,8 @@ struct machine_desc { unsigned int video_start; /* start of video RAM */ unsigned int video_end; /* end of video RAM */ + unsigned int bank_limit; /* maximum number of memory + * banks to add */ unsigned char reserve_lp0 :1; /* never has lp0 */ unsigned char reserve_lp1 :1; /* never has lp1 */ unsigned char reserve_lp2 :1; /* never has lp2 */ @@ -85,7 +87,8 @@ static const struct machine_desc __mach_desc_##_type \ __used \ __attribute__((__section__(".arch.info.init"))) = { \ .nr = MACH_TYPE_##_type, \ - .name = _name, + .name = _name, \ + .bank_limit = 12, #define MACHINE_END \ }; @@ -95,6 +98,7 @@ static const struct machine_desc __mach_desc_##_name \ __used \ __attribute__((__section__(".arch.info.init"))) = { \ .nr = ~0, \ - .name = _namestr, + .name = _namestr, \ + .bank_limit = 12, #endif diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index e94a157..ea9ce92 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -27,6 +27,10 @@ #include <asm/mach/arch.h> #include <asm/mach-types.h> +void __init early_init_dt_add_memory_arch(u64 base, u64 size) +{ + arm_add_memory(base, size); +} #ifdef CONFIG_SMP extern struct of_cpu_method __cpu_method_of_table[]; diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 8a16ee5..3ab94d1 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -629,11 +629,26 @@ void __init dump_machine_table(void) /* can't use cpu_relax() here as it may require MMU setup */; } +static unsigned int bank_cnt; +static unsigned int max_cnt; + int __init arm_add_memory(u64 start, u64 size) { u64 aligned_start; /* + * Some buggy bootloaders rely on the old meminfo behavior of not adding + * more than n banks since anything past that may contain invalid data. + */ + if (bank_cnt >= max_cnt) { + pr_crit("Max banks too low, ignoring memory at 0x%08llx\n", + (long long)start); + return -EINVAL; + } + + bank_cnt++; + + /* * Ensure that start/size are aligned to a page boundary. * Size is appropriately rounded down, start is rounded up. */ @@ -879,6 +894,7 @@ void __init setup_arch(char **cmdline_p) mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type); machine_desc = mdesc; machine_name = mdesc->name; + max_cnt = mdesc->bank_limit; if (mdesc->reboot_mode != REBOOT_HARD) reboot_mode = mdesc->reboot_mode; diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c index f38cf7c..91283fd 100644 --- a/arch/arm/mach-exynos/exynos.c +++ b/arch/arm/mach-exynos/exynos.c @@ -350,4 +350,5 @@ DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)") .dt_compat = exynos_dt_compat, .restart = exynos_restart, .reserve = exynos_reserve, + .bank_limit = 8, MACHINE_END