| Message ID | 20180105200454.31245-1-swarren@wwwdotorg.org |
|---|---|
| State | Accepted |
| Commit | 15751403b6072acabdd7ccad10013cb80b6c6a34 |
| Delegated to: | Tom Warren |
| Headers | show |
| Series | [U-Boot] ARM: bootm: don't assume sp is in DRAM bank 0 | expand |
On 5 January 2018 at 13:04, Stephen Warren <swarren@wwwdotorg.org> wrote: > From: Stephen Warren <swarren@nvidia.com> > > arch_lmb_reserve() currently assumes that the stack pointer is within DRAM > bank 0. This is not necessarily true. Enhance the code to search through > DRAM banks until the bank that does contain SP is found, and then reserve > the tail of that bank. > > Fixes: 2d1916e48bd8 ("ARM: add flat device tree support") > Signed-off-by: Stephen Warren <swarren@nvidia.com> > --- > It would be best to apply this patch before "ARM: Tegra186: search for > best RAM bank" is applied. > --- > arch/arm/lib/bootm.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 5c62d9c14406..89740657e0c5 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -47,7 +47,8 @@ static ulong get_sp(void) void arch_lmb_reserve(struct lmb *lmb) { - ulong sp; + ulong sp, bank_end; + int bank; /* * Booting a (Linux) kernel image @@ -63,8 +64,16 @@ void arch_lmb_reserve(struct lmb *lmb) /* adjust sp by 4K to be safe */ sp -= 4096; - lmb_reserve(lmb, sp, - gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - sp); + for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { + if (sp < gd->bd->bi_dram[bank].start) + continue; + bank_end = gd->bd->bi_dram[bank].start + + gd->bd->bi_dram[bank].size; + if (sp >= bank_end) + continue; + lmb_reserve(lmb, sp, bank_end - sp); + break; + } } __weak void board_quiesce_devices(void)