@@ -565,9 +565,11 @@ int boot_ramdisk_high(ulong rd_data, ulong rd_len, ulong *initrd_start,
lmb_reserve_flags(rd_data, rd_len, LMB_NONE);
} else {
if (initrd_high)
- *initrd_start = (ulong)lmb_alloc_base(rd_len,
- 0x1000,
- initrd_high);
+ *initrd_start =
+ (ulong)lmb_alloc_base_flags(rd_len,
+ 0x1000,
+ initrd_high,
+ LMB_NONE);
else
*initrd_start = (ulong)lmb_alloc(rd_len,
0x1000);
@@ -838,8 +840,9 @@ int boot_get_cmdline(ulong *cmd_start, ulong *cmd_end)
return 0;
barg = IF_ENABLED_INT(CONFIG_SYS_BOOT_GET_CMDLINE, CONFIG_SYS_BARGSIZE);
- cmdline = (char *)(ulong)lmb_alloc_base(barg, 0xf,
- env_get_bootm_mapsize() + env_get_bootm_low());
+ cmdline = (char *)(ulong)lmb_alloc_base_flags(barg, 0xf,
+ env_get_bootm_mapsize() + env_get_bootm_low(),
+ LMB_NONE);
if (!cmdline)
return -1;
@@ -871,10 +874,11 @@ int boot_get_cmdline(ulong *cmd_start, ulong *cmd_end)
*/
int boot_get_kbd(struct bd_info **kbd)
{
- *kbd = (struct bd_info *)(ulong)lmb_alloc_base(sizeof(struct bd_info),
- 0xf,
- env_get_bootm_mapsize() +
- env_get_bootm_low());
+ *kbd = (struct bd_info *)(ulong)lmb_alloc_base_flags(sizeof(struct bd_info),
+ 0xf,
+ env_get_bootm_mapsize() +
+ env_get_bootm_low(),
+ LMB_NONE);
if (!*kbd)
return -1;
@@ -188,7 +188,8 @@ int boot_relocate_fdt(char **of_flat_tree, ulong *of_size)
LMB_NONE);
disable_relocation = 1;
} else if (desired_addr) {
- addr = lmb_alloc_base(of_len, 0x1000, desired_addr);
+ addr = lmb_alloc_base_flags(of_len, 0x1000, desired_addr,
+ LMB_NONE);
of_start = map_sysmem(addr, of_len);
if (of_start == NULL) {
puts("Failed using fdt_high value for Device Tree");
@@ -217,7 +218,8 @@ int boot_relocate_fdt(char **of_flat_tree, ulong *of_size)
* for LMB allocation.
*/
usable = min(start + size, low + mapsize);
- addr = lmb_alloc_base(of_len, 0x1000, usable);
+ addr = lmb_alloc_base_flags(of_len, 0x1000, usable,
+ LMB_NONE);
of_start = map_sysmem(addr, of_len);
/* Allocation succeeded, use this block. */
if (of_start != NULL)
@@ -93,7 +93,6 @@ long lmb_add(phys_addr_t base, phys_size_t size);
long lmb_reserve_flags(phys_addr_t base, phys_size_t size,
enum lmb_flags flags);
phys_addr_t lmb_alloc(phys_size_t size, ulong align);
-phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr);
phys_size_t lmb_get_free_size(phys_addr_t addr);
phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align,
@@ -747,20 +747,7 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align,
phys_addr_t lmb_alloc(phys_size_t size, ulong align)
{
- return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE);
-}
-
-phys_addr_t lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr)
-{
- phys_addr_t alloc;
-
- alloc = _lmb_alloc_base(size, align, max_addr, LMB_NONE);
-
- if (alloc == 0)
- printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
- (ulong)size, (ulong)max_addr);
-
- return alloc;
+ return lmb_alloc_base_flags(size, align, LMB_ALLOC_ANYWHERE, LMB_NONE);
}
/**
@@ -128,7 +128,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram,
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2, alloc_64k_addr, 0x10000,
ram_end - 4, 4, 0, 0);
/* alloc below end of reserved region -> below reserved region */
- b = lmb_alloc_base(4, 1, alloc_64k_end);
+ b = lmb_alloc_base_flags(4, 1, alloc_64k_end, LMB_NONE);
ut_asserteq(b, alloc_64k_addr - 4);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 4, 0x10000 + 4, ram_end - 4, 4, 0, 0);
@@ -138,7 +138,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram,
ut_asserteq(c, ram_end - 8);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 4, 0x10000 + 4, ram_end - 8, 8, 0, 0);
- d = lmb_alloc_base(4, 1, alloc_64k_end);
+ d = lmb_alloc_base_flags(4, 1, alloc_64k_end, LMB_NONE);
ut_asserteq(d, alloc_64k_addr - 8);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 8, 0, 0);
@@ -163,7 +163,7 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram,
alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000,
ram_end - 8, 4);
/* allocate again to ensure we get the same address */
- b2 = lmb_alloc_base(4, 1, alloc_64k_end);
+ b2 = lmb_alloc_base_flags(4, 1, alloc_64k_end, LMB_NONE);
ut_asserteq(b, b2);
ASSERT_LMB(mem_lst, used_lst, 0, 0, 2,
alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0);
@@ -363,7 +363,7 @@ static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram,
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 0, 0, 0, 0, 0, 0, 0);
/* allocate a block with base*/
- b = lmb_alloc_base(alloc_size, align, ram_end);
+ b = lmb_alloc_base_flags(alloc_size, align, ram_end, LMB_NONE);
ut_assert(a == b);
ASSERT_LMB(mem_lst, used_lst, ram, ram_size, 1,
ram + ram_size - alloc_size_aligned,
lmb_alloc_base() is just calling lmb_alloc_base_flags() with LMB_NONE. There's not much we gain from this abstraction, so let's remove the former and make the code a bit easier to follow. The code size increase is minimal - e.g for sandbox which includes all of the LMB tests add/remove: 1/2 grow/shrink: 4/1 up/down: 316/-382 (-66) Function old new delta lmb_alloc_base_flags - 299 +299 test_multi_alloc.constprop 3036 3042 +6 lmb_alloc 4 9 +5 boot_relocate_fdt 601 605 +4 test_noreserved 1207 1209 +2 lmb_alloc_base 48 - -48 efi_allocate_pages.part 303 249 -54 _lmb_alloc_base.lto_priv 280 - -280 Total: Before=2492763, After=2492697, chg -0.00% Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> --- boot/image-board.c | 22 +++++++++++++--------- boot/image-fdt.c | 6 ++++-- include/lmb.h | 1 - lib/lmb.c | 15 +-------------- test/lib/lmb.c | 8 ++++---- 5 files changed, 22 insertions(+), 30 deletions(-)