]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: caches: protect dram_bank_mmu_setup access to bi_dram
authorPatrick Delaunay <patrick.delaunay@st.com>
Fri, 24 Apr 2020 18:20:15 +0000 (20:20 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 1 May 2020 15:34:01 +0000 (11:34 -0400)
Add protection in dram_bank_mmu_setup() to avoid access to bd->bi_dram
before relocation.

This patch allow to use the generic weak function dram_bank_mmu_setup
to activate the MMU and the data cache in SPL or in U-Boot before
relocation, when bd->bi_dram is not yet initialized.

In this cases, the MMU must be initialized explicitly with
mmu_set_region_dcache_behaviour function.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
arch/arm/lib/cache-cp15.c

index f8d20960da9d6173e2985c5fbcb486eb62438554..54509f11c304389963eb50caed77193881b7ba79 100644 (file)
@@ -91,6 +91,10 @@ __weak void dram_bank_mmu_setup(int bank)
        bd_t *bd = gd->bd;
        int     i;
 
+       /* bd->bi_dram is available only after relocation */
+       if ((gd->flags & GD_FLG_RELOC) == 0)
+               return;
+
        debug("%s: bank: %d\n", __func__, bank);
        for (i = bd->bi_dram[bank].start >> MMU_SECTION_SHIFT;
             i < (bd->bi_dram[bank].start >> MMU_SECTION_SHIFT) +