On Wed, 31 Jul 2024 at 01:17, Simon Glass <s...@chromium.org> wrote: > > Hi Sughosh, > > On Wed, 24 Jul 2024 at 00:03, Sughosh Ganu <sughosh.g...@linaro.org> wrote: > > > > The current LMB API's for allocating and reserving memory use a > > per-caller based memory view. Memory allocated by a caller can then be > > overwritten by another caller. Make these allocations and reservations > > persistent using the alloced list data structure. > > > > Two alloced lists are declared -- one for the available(free) memory, > > and one for the used memory. Once full, the list can then be extended > > at runtime. > > > > Signed-off-by: Sughosh Ganu <sughosh.g...@linaro.org> > > --- > > Changes since rfc: > > * Squash patches 9 - 11, 13 from the rfc v2 series into a single > > patch to make it bisectable. > > > > arch/arc/lib/cache.c | 4 +- > > arch/arm/lib/stack.c | 4 +- > > arch/arm/mach-apple/board.c | 17 +- > > arch/arm/mach-snapdragon/board.c | 17 +- > > arch/arm/mach-stm32mp/dram_init.c | 8 +- > > arch/arm/mach-stm32mp/stm32mp1/cpu.c | 6 +- > > arch/m68k/lib/bootm.c | 7 +- > > arch/microblaze/lib/bootm.c | 4 +- > > arch/mips/lib/bootm.c | 11 +- > > arch/nios2/lib/bootm.c | 4 +- > > arch/powerpc/cpu/mpc85xx/mp.c | 4 +- > > arch/powerpc/include/asm/mp.h | 4 +- > > arch/powerpc/lib/bootm.c | 14 +- > > arch/riscv/lib/bootm.c | 4 +- > > arch/sh/lib/bootm.c | 4 +- > > arch/x86/lib/bootm.c | 4 +- > > arch/xtensa/lib/bootm.c | 4 +- > > board/xilinx/common/board.c | 8 +- > > boot/bootm.c | 26 +- > > boot/bootm_os.c | 5 +- > > boot/image-board.c | 34 +-- > > boot/image-fdt.c | 36 ++- > > cmd/bdinfo.c | 6 +- > > cmd/booti.c | 2 +- > > cmd/bootz.c | 2 +- > > cmd/elf.c | 2 +- > > cmd/load.c | 7 +- > > drivers/iommu/apple_dart.c | 8 +- > > drivers/iommu/sandbox_iommu.c | 16 +- > > fs/fs.c | 7 +- > > include/image.h | 28 +- > > include/lmb.h | 114 +++----- > > lib/efi_loader/efi_dt_fixup.c | 2 +- > > lib/efi_loader/efi_helper.c | 2 +- > > lib/lmb.c | 395 +++++++++++++++------------ > > net/tftp.c | 5 +- > > net/wget.c | 5 +- > > test/cmd/bdinfo.c | 2 +- > > test/lib/lmb.c | 205 ++++++-------- > > 39 files changed, 477 insertions(+), 560 deletions(-) > > [..] > > > diff --git a/lib/lmb.c b/lib/lmb.c > > index 4d39c0d1f9..dd6f22654c 100644 > > --- a/lib/lmb.c > > +++ b/lib/lmb.c > [..] > > -static void lmb_remove_region(struct lmb_region *rgn, unsigned long r) > > +static void lmb_remove_region(struct alist *lmb_rgn_lst, unsigned long r) > > { > > unsigned long i; > > + struct lmb_region *rgn = lmb_rgn_lst->data; > > > > - for (i = r; i < rgn->cnt - 1; i++) { > > - rgn->region[i].base = rgn->region[i + 1].base; > > - rgn->region[i].size = rgn->region[i + 1].size; > > - rgn->region[i].flags = rgn->region[i + 1].flags; > > + for (i = r; i < lmb_rgn_lst->count - 1; i++) { > > + rgn[i].base = rgn[i + 1].base; > > + rgn[i].size = rgn[i + 1].size; > > + rgn[i].flags = rgn[i + 1].flags; > > This should be: > > rgn[i] = rgn[i+1]
Yes, direct struct assignment is a better way of doing this. Thanks for pointing it out! -sughosh