Hi Anshul, On Thu Jul 3, 2025 at 4:35 PM EEST, Anshul Dalal wrote: > k3_mem_map is used by u-boot to configure the MMU on k3 devices but > currently it's a static array which does not scale for platforms with > non-standard load addresses for ATF and OP-TEE. Additionally on systems > with limited DRAM, more space is mapped than is available on the device. > > Therefore this patch adds a new k3_mem_map_init function which can > be called from dram_init to configure the table at runtime where we > can query the required DDR information and reserved regions from the > device-tree.
Is this a problem for k3 only? This kind of code should be aimed at the mmu support and improving armv8 overall, not specific platforms > > A dummy implementation is also added in r5/common.c to allow the build > to pass without masking each call to k3_mem_map_init behind an ifdef > CONFIG_ARM64. > > Signed-off-by: Anshul Dalal <[email protected]> [...] > + > +static void k3_mmu_add_cachable_entry(u64 start, u64 end, unsigned int > *map_idx) > +{ > + if (start >= end) > + return; > + > + k3_mem_map[*map_idx].virt = start, > + k3_mem_map[*map_idx].phys = start, > + k3_mem_map[*map_idx].size = end - start, > + k3_mem_map[*map_idx].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | > + PTE_BLOCK_INNER_SHARE; > + (*map_idx)++; > +} Doesn't this need a break-before-make? Also why does it have to be a board specific function? Is there something mmu_change_region_attr() doesn't do ? > + > +/* It is assumed that if ATF and OPTEE are loaded in DDR, they are loaded to > + * first bank only > + > +static int k3_setup_extra_mem_banks(unsigned int *map_idx) > +{ > + unsigned int bank; > + int ret; > + > + ret = fdtdec_setup_memory_banksize(); > + if (ret) > + return ret; > + > + for (bank = 1; bank < CONFIG_NR_DRAM_BANKS; bank++) { > + k3_mmu_add_cachable_entry(gd->bd->bi_dram[bank].start, > + gd->bd->bi_dram[bank].start + > + gd->bd->bi_dram[bank].size, > + map_idx); > + } > + ditto > +static int k3_uboot_mem_map_init(unsigned int *map_idx) > +{ > + int ret; > + > + /* Overwrite the 128MiB SPL entry */ > + (*map_idx)--; > + > + ret = k3_setup_first_mem_bank(map_idx); > + if (ret) > + return ret; > + > + if (CONFIG_NR_DRAM_BANKS > 1) > + ret = k3_setup_extra_mem_banks(map_idx); > + > + return ret; > +} > + > diff --git a/arch/arm/mach-k3/include/mach/k3-ddr.h > b/arch/arm/mach-k3/include/mach/k3-ddr.h [..] Thanks /Ilias

