From: Chali Anis <chalian...@gmail.com> remove the allocate EFI_ALLOCATE_MAX_ADDRESSES and use a different memsize for x86 since the initrd could be bigger that those used in arm. it might be refactored in the future with a more generic allocation strategy (i.e barebox malloc memory vs an allocator for the boot loader data) something like sdram_request_region or just allocate small memory for the barebox allocator and implement a way to allocate memory for kernel/initrd directly from efi.
Signed-off-by: Chali Anis <chalian...@gmail.com> --- efi/payload/early-mem.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/efi/payload/early-mem.c b/efi/payload/early-mem.c index 0f79a8c30694..150a2a595afc 100644 --- a/efi/payload/early-mem.c +++ b/efi/payload/early-mem.c @@ -9,18 +9,17 @@ void *efi_earlymem_alloc(const struct efi_system_table *sys_table, size_t *memsize, enum efi_memory_type mem_type) { struct efi_boot_services *bs = sys_table->boottime; - enum efi_allocate_type alloc_type = EFI_ALLOCATE_ANY_PAGES; efi_physical_addr_t mem; efi_status_t efiret; + size_t m_sz; - if (IS_ENABLED(CONFIG_X86)) { - /* Try to stay clear of memory mapped devices */ - alloc_type = EFI_ALLOCATE_MAX_ADDRESS; - mem = SZ_1G - 1; - } + if (IS_ENABLED(CONFIG_X86)) + m_sz = SZ_512M; + else + m_sz = SZ_256M; - for (*memsize = SZ_256M; *memsize >= SZ_8M; *memsize /= 2) { - efiret = bs->allocate_pages(alloc_type, mem_type, + for (*memsize = m_sz; *memsize >= SZ_8M; *memsize /= 2) { + efiret = bs->allocate_pages(EFI_ALLOCATE_ANY_PAGES, mem_type, *memsize / EFI_PAGE_SIZE, &mem); if (!EFI_ERROR(efiret) || efiret != EFI_OUT_OF_RESOURCES) break; -- 2.34.1