> +static phys_addr_t lmb_alloc(phys_size_t size)
> +{
> +       int ret;
> +       phys_addr_t addr;
> +
> +       /* All memory regions allocated with a 2MiB alignment */
> +       ret = lmb_alloc_mem(LMB_MEM_ALLOC_ANY, SZ_2M, &addr, size, LMB_NONE);
> +       if (ret)
> +               return 0;
> +
> +       return addr;
> +}
> +

I think we  need a better naming for these. Right now we have
lmb_alloc() here and in tests, addr_alloc() in snapdragon code.
I'd say either export them as API if you think they would be useful,
or get rid of the wrappers.

[...]

> +static phys_addr_t lmb_alloc(phys_size_t size, ulong align)
> +{
> +       int err;
> +       phys_addr_t addr;
> +
> +       err = lmb_alloc_mem(LMB_MEM_ALLOC_ANY, align, &addr, size, LMB_NONE);
> +       if (err)
> +               return 0;


This tends to blow up in random ways. See
commit 67be24906fe. TL;DR 0 is a valid address in some systems.

> +
> +       return addr;
> +}
> +
> +static phys_addr_t lmb_alloc_base(phys_size_t size, ulong align,
> +                                 phys_addr_t max_addr, u32 flags)
> +{
> +       int err;
> +       phys_addr_t addr;
> +
> +       addr = max_addr;
> +       err = lmb_alloc_mem(LMB_MEM_ALLOC_MAX, align, &addr, size, flags);
> +       if (err)
> +               return 0;
> +
> +       return addr;
> +}
> +
>  #define lmb_alloc_addr(addr, size, flags) lmb_reserve(addr, size, flags)
>
>  static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t 
> ram,
> --
> 2.34.1
>

Cheers
/Ilias

Reply via email to