diff mbox series

[v5,18/28] efi: Show when allocated pages are used

Message ID 20211204085647.v5.18.I2eff1cd4f12753d0d86e9751fa350458ef5789e0@changeid
State Changes Requested, archived
Delegated to: Heinrich Schuchardt
Headers show
Series efi: Improvements to U-Boot running on top of UEFI | expand

Commit Message

Simon Glass Dec. 4, 2021, 3:56 p.m. UTC
Add a message here so that both paths of memory allocation are reported.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v2)

Changes in v2:
- Use log_info() instead of printf()

 lib/efi/efi_app.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Heinrich Schuchardt Dec. 9, 2021, 7:55 p.m. UTC | #1
On 12/4/21 07:56, Simon Glass wrote:
> Add a message here so that both paths of memory allocation are reported.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v2)
>
> Changes in v2:
> - Use log_info() instead of printf()
>
>   lib/efi/efi_app.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
> index e454f1a1564..36e3f1de427 100644
> --- a/lib/efi/efi_app.c
> +++ b/lib/efi/efi_app.c
> @@ -121,13 +121,14 @@ static efi_status_t setup_memory(struct efi_priv *priv)
>   	ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
>   				   priv->image_data_type, pages, &addr);
>   	if (ret) {

If AllocatePages() fails the system is out of memory. Just return to the
calling firmware with EFI_OUT_OF_RESOURCES.

Best regards

Heinrich

> -		printf("(using pool %lx) ", ret);
> +		log_info("(using pool %lx) ", ret);
>   		priv->ram_base = (ulong)efi_malloc(priv, CONFIG_EFI_RAM_SIZE,
>   						   &ret);
>   		if (!priv->ram_base)
>   			return ret;
>   		priv->use_pool_for_malloc = true;
>   	} else {
> +		log_info("(using allocated RAM address %lx) ", (ulong)addr);
>   		priv->ram_base = addr;
>   	}
>   	gd->ram_size = pages << 12;
>
Simon Glass Dec. 17, 2021, 4:37 p.m. UTC | #2
Hi Heinrich,

On Thu, 9 Dec 2021 at 12:55, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > Add a message here so that both paths of memory allocation are reported.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - Use log_info() instead of printf()
> >
> >   lib/efi/efi_app.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
> > index e454f1a1564..36e3f1de427 100644
> > --- a/lib/efi/efi_app.c
> > +++ b/lib/efi/efi_app.c
> > @@ -121,13 +121,14 @@ static efi_status_t setup_memory(struct efi_priv *priv)
> >       ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> >                                  priv->image_data_type, pages, &addr);
> >       if (ret) {
>
> If AllocatePages() fails the system is out of memory. Just return to the
> calling firmware with EFI_OUT_OF_RESOURCES.

I have left this as it is as sometimes it is possible to allocate from
the pool even if allocate_pages() fails. I hit this on an Intel
platform some years ago.

In any case your comment does not relate to this patch.

Regards,
Simon
diff mbox series

Patch

diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index e454f1a1564..36e3f1de427 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -121,13 +121,14 @@  static efi_status_t setup_memory(struct efi_priv *priv)
 	ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
 				   priv->image_data_type, pages, &addr);
 	if (ret) {
-		printf("(using pool %lx) ", ret);
+		log_info("(using pool %lx) ", ret);
 		priv->ram_base = (ulong)efi_malloc(priv, CONFIG_EFI_RAM_SIZE,
 						   &ret);
 		if (!priv->ram_base)
 			return ret;
 		priv->use_pool_for_malloc = true;
 	} else {
+		log_info("(using allocated RAM address %lx) ", (ulong)addr);
 		priv->ram_base = addr;
 	}
 	gd->ram_size = pages << 12;