diff mbox series

lmb: notify when adjacent regions are added

Message ID 20241018135112.3978130-2-caleb.connolly@linaro.org
State New
Headers show
Series lmb: notify when adjacent regions are added | expand

Commit Message

Caleb Connolly Oct. 18, 2024, 1:51 p.m. UTC
lmb_add_region() returns a positive integer if the added regions causes
existing regions to be coalesced. We still want to notify the EFI
subsystem about these added regions though, so adjust lmb_add() to only
bail on errors.

This fixes EFI memory allocation on boards with adjacent memory banks as is the
case on several Qualcomm boards like the RB3 Gen 2.

Fixes: 2f6191526a13 (lmb: notify of any changes to the LMB memory map)
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
Cc: u-boot-qcom@groups.io
---
 lib/lmb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sughosh Ganu Oct. 18, 2024, 2:04 p.m. UTC | #1
On Fri, 18 Oct 2024 at 19:23, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>
> lmb_add_region() returns a positive integer if the added regions causes
> existing regions to be coalesced. We still want to notify the EFI
> subsystem about these added regions though, so adjust lmb_add() to only
> bail on errors.
>
> This fixes EFI memory allocation on boards with adjacent memory banks as is the
> case on several Qualcomm boards like the RB3 Gen 2.
>
> Fixes: 2f6191526a13 (lmb: notify of any changes to the LMB memory map)
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---

Reviewed-by: Sughosh Ganu <sughosh.ganu@linaro.org>

-sughosh

> Cc: u-boot-qcom@groups.io
> ---
>  lib/lmb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 78fe2d4de7c6..7e90f178763b 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -486,9 +486,9 @@ long lmb_add(phys_addr_t base, phys_size_t size)
>         long ret;
>         struct alist *lmb_rgn_lst = &lmb.free_mem;
>
>         ret = lmb_add_region(lmb_rgn_lst, base, size);
> -       if (ret)
> +       if (ret < 0)
>                 return ret;
>
>         if (lmb_should_notify(LMB_NONE))
>                 return lmb_map_update_notify(base, size, MAP_OP_ADD);
> --
> 2.46.2
>
Neil Armstrong Oct. 18, 2024, 2:06 p.m. UTC | #2
On 18/10/2024 15:51, Caleb Connolly via groups.io wrote:
> lmb_add_region() returns a positive integer if the added regions causes
> existing regions to be coalesced. We still want to notify the EFI
> subsystem about these added regions though, so adjust lmb_add() to only
> bail on errors.
> 
> This fixes EFI memory allocation on boards with adjacent memory banks as is the
> case on several Qualcomm boards like the RB3 Gen 2.
> 
> Fixes: 2f6191526a13 (lmb: notify of any changes to the LMB memory map)
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
> Cc: u-boot-qcom@groups.io
> ---
>   lib/lmb.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 78fe2d4de7c6..7e90f178763b 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -486,9 +486,9 @@ long lmb_add(phys_addr_t base, phys_size_t size)
>   	long ret;
>   	struct alist *lmb_rgn_lst = &lmb.free_mem;
>   
>   	ret = lmb_add_region(lmb_rgn_lst, base, size);
> -	if (ret)
> +	if (ret < 0)
>   		return ret;
>   
>   	if (lmb_should_notify(LMB_NONE))
>   		return lmb_map_update_notify(base, size, MAP_OP_ADD);

Tested-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks !
Neil
Ilias Apalodimas Oct. 18, 2024, 2:07 p.m. UTC | #3
Thanks Caleb,

On Fri, 18 Oct 2024 at 16:53, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>
> lmb_add_region() returns a positive integer if the added regions causes
> existing regions to be coalesced. We still want to notify the EFI
> subsystem about these added regions though, so adjust lmb_add() to only
> bail on errors.
>
> This fixes EFI memory allocation on boards with adjacent memory banks as is the
> case on several Qualcomm boards like the RB3 Gen 2.
>
> Fixes: 2f6191526a13 (lmb: notify of any changes to the LMB memory map)
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
> Cc: u-boot-qcom@groups.io
> ---
>  lib/lmb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 78fe2d4de7c6..7e90f178763b 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -486,9 +486,9 @@ long lmb_add(phys_addr_t base, phys_size_t size)
>         long ret;
>         struct alist *lmb_rgn_lst = &lmb.free_mem;
>
>         ret = lmb_add_region(lmb_rgn_lst, base, size);
> -       if (ret)
> +       if (ret < 0)
>                 return ret;
>
>         if (lmb_should_notify(LMB_NONE))
>                 return lmb_map_update_notify(base, size, MAP_OP_ADD);
> --
> 2.46.2
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Simon Glass Oct. 18, 2024, 3:02 p.m. UTC | #4
Hi Caleb,

On Fri, 18 Oct 2024 at 08:08, Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> Thanks Caleb,
>
> On Fri, 18 Oct 2024 at 16:53, Caleb Connolly <caleb.connolly@linaro.org> wrote:
> >
> > lmb_add_region() returns a positive integer if the added regions causes
> > existing regions to be coalesced. We still want to notify the EFI
> > subsystem about these added regions though, so adjust lmb_add() to only
> > bail on errors.
> >
> > This fixes EFI memory allocation on boards with adjacent memory banks as is the
> > case on several Qualcomm boards like the RB3 Gen 2.
> >
> > Fixes: 2f6191526a13 (lmb: notify of any changes to the LMB memory map)
> > Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> > ---
> > Cc: u-boot-qcom@groups.io
> > ---
> >  lib/lmb.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/lmb.c b/lib/lmb.c
> > index 78fe2d4de7c6..7e90f178763b 100644
> > --- a/lib/lmb.c
> > +++ b/lib/lmb.c
> > @@ -486,9 +486,9 @@ long lmb_add(phys_addr_t base, phys_size_t size)
> >         long ret;
> >         struct alist *lmb_rgn_lst = &lmb.free_mem;
> >
> >         ret = lmb_add_region(lmb_rgn_lst, base, size);
> > -       if (ret)
> > +       if (ret < 0)
> >                 return ret;
> >
> >         if (lmb_should_notify(LMB_NONE))
> >                 return lmb_map_update_notify(base, size, MAP_OP_ADD);
> > --
> > 2.46.2
> >
>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Is it possible to add a test for this case? It is a good idea to plug
a testing gap when fixing a bug.

Regards,
Simon
Tom Rini Oct. 19, 2024, 2:21 a.m. UTC | #5
On Fri, 18 Oct 2024 15:51:07 +0200, Caleb Connolly wrote:

> lmb_add_region() returns a positive integer if the added regions causes
> existing regions to be coalesced. We still want to notify the EFI
> subsystem about these added regions though, so adjust lmb_add() to only
> bail on errors.
> 
> This fixes EFI memory allocation on boards with adjacent memory banks as is the
> case on several Qualcomm boards like the RB3 Gen 2.
> 
> [...]

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/lib/lmb.c b/lib/lmb.c
index 78fe2d4de7c6..7e90f178763b 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -486,9 +486,9 @@  long lmb_add(phys_addr_t base, phys_size_t size)
 	long ret;
 	struct alist *lmb_rgn_lst = &lmb.free_mem;
 
 	ret = lmb_add_region(lmb_rgn_lst, base, size);
-	if (ret)
+	if (ret < 0)
 		return ret;
 
 	if (lmb_should_notify(LMB_NONE))
 		return lmb_map_update_notify(base, size, MAP_OP_ADD);