diff mbox series

[RFC,17/31] lmb: remove call to efi_lmb_reserve()

Message ID 20240607185240.1892031-18-sughosh.ganu@linaro.org
State New
Headers show
Series Make U-Boot memory reservations coherent | expand

Commit Message

Sughosh Ganu June 7, 2024, 6:52 p.m. UTC
The changes in the EFI memory map are now notified to the LMB
module. There is therefore no need to explicitly get the efi memory
map and set aside the EFI allocated memory.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
 lib/lmb.c | 35 -----------------------------------
 1 file changed, 35 deletions(-)

Comments

Ilias Apalodimas June 10, 2024, 11:46 a.m. UTC | #1
On Fri, 7 Jun 2024 at 21:54, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> The changes in the EFI memory map are now notified to the LMB
> module. There is therefore no need to explicitly get the efi memory
> map and set aside the EFI allocated memory.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
>  lib/lmb.c | 35 -----------------------------------
>  1 file changed, 35 deletions(-)
>
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 3059609aea..c9f6ca692e 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -204,38 +204,6 @@ void arch_lmb_reserve_generic(ulong sp, ulong end, ulong align)
>         }
>  }
>
> -/**
> - * efi_lmb_reserve() - add reservations for EFI memory
> - *
> - * Add reservations for all EFI memory areas that are not
> - * EFI_CONVENTIONAL_MEMORY.
> - *
> - * Return:     0 on success, 1 on failure
> - */
> -static __maybe_unused int efi_lmb_reserve(void)
> -{
> -       struct efi_mem_desc *memmap = NULL, *map;
> -       efi_uintn_t i, map_size = 0;
> -       efi_status_t ret;
> -
> -       ret = efi_get_memory_map_alloc(&map_size, &memmap);
> -       if (ret != EFI_SUCCESS)
> -               return 1;
> -
> -       for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) {
> -               if (map->type != EFI_CONVENTIONAL_MEMORY) {
> -                       lmb_reserve_flags(map_to_sysmem((void *)(uintptr_t)
> -                                                       map->physical_start),
> -                                         map->num_pages * EFI_PAGE_SIZE,
> -                                         map->type == EFI_RESERVED_MEMORY_TYPE
> -                                             ? LMB_NOMAP : LMB_NONE);
> -               }
> -       }
> -       efi_free_pool(memmap);
> -
> -       return 0;
> -}
> -
>  /**
>   * lmb_reserve_common() - Reserve memory region occupied by U-Boot image
>   * @fdt_blob: pointer to the FDT blob
> @@ -255,9 +223,6 @@ void lmb_reserve_common(void *fdt_blob)
>
>         if (CONFIG_IS_ENABLED(OF_LIBFDT) && fdt_blob)
>                 boot_fdt_add_mem_rsv_regions(fdt_blob);
> -
> -       if (CONFIG_IS_ENABLED(EFI_LOADER))
> -               efi_lmb_reserve();
>  }
>
>  /**
> --
> 2.34.1
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Heinrich Schuchardt June 11, 2024, 9:11 a.m. UTC | #2
On 07.06.24 20:52, Sughosh Ganu wrote:
> The changes in the EFI memory map are now notified to the LMB
> module. There is therefore no need to explicitly get the efi memory
> map and set aside the EFI allocated memory.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
>   lib/lmb.c | 35 -----------------------------------
>   1 file changed, 35 deletions(-)
>
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 3059609aea..c9f6ca692e 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -204,38 +204,6 @@ void arch_lmb_reserve_generic(ulong sp, ulong end, ulong align)
>   	}
>   }
>
> -/**
> - * efi_lmb_reserve() - add reservations for EFI memory
> - *
> - * Add reservations for all EFI memory areas that are not
> - * EFI_CONVENTIONAL_MEMORY.
> - *
> - * Return:	0 on success, 1 on failure
> - */
> -static __maybe_unused int efi_lmb_reserve(void)
> -{
> -	struct efi_mem_desc *memmap = NULL, *map;
> -	efi_uintn_t i, map_size = 0;
> -	efi_status_t ret;
> -
> -	ret = efi_get_memory_map_alloc(&map_size, &memmap);
> -	if (ret != EFI_SUCCESS)
> -		return 1;
> -
> -	for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) {
> -		if (map->type != EFI_CONVENTIONAL_MEMORY) {
> -			lmb_reserve_flags(map_to_sysmem((void *)(uintptr_t)
> -							map->physical_start),
> -					  map->num_pages * EFI_PAGE_SIZE,
> -					  map->type == EFI_RESERVED_MEMORY_TYPE
> -					      ? LMB_NOMAP : LMB_NONE);


Now that you have removed the last usage of LMB_NOMAP, please, remove it
from enum lmb_flags.

Best regards

Heinrich

> -		}
> -	}
> -	efi_free_pool(memmap);
> -
> -	return 0;
> -}
> -
>   /**
>    * lmb_reserve_common() - Reserve memory region occupied by U-Boot image
>    * @fdt_blob: pointer to the FDT blob
> @@ -255,9 +223,6 @@ void lmb_reserve_common(void *fdt_blob)
>
>   	if (CONFIG_IS_ENABLED(OF_LIBFDT) && fdt_blob)
>   		boot_fdt_add_mem_rsv_regions(fdt_blob);
> -
> -	if (CONFIG_IS_ENABLED(EFI_LOADER))
> -		efi_lmb_reserve();
>   }
>
>   /**
Sughosh Ganu June 11, 2024, 9:49 a.m. UTC | #3
On Tue, 11 Jun 2024 at 14:42, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 07.06.24 20:52, Sughosh Ganu wrote:
> > The changes in the EFI memory map are now notified to the LMB
> > module. There is therefore no need to explicitly get the efi memory
> > map and set aside the EFI allocated memory.
> >
> > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > ---
> >   lib/lmb.c | 35 -----------------------------------
> >   1 file changed, 35 deletions(-)
> >
> > diff --git a/lib/lmb.c b/lib/lmb.c
> > index 3059609aea..c9f6ca692e 100644
> > --- a/lib/lmb.c
> > +++ b/lib/lmb.c
> > @@ -204,38 +204,6 @@ void arch_lmb_reserve_generic(ulong sp, ulong end, ulong align)
> >       }
> >   }
> >
> > -/**
> > - * efi_lmb_reserve() - add reservations for EFI memory
> > - *
> > - * Add reservations for all EFI memory areas that are not
> > - * EFI_CONVENTIONAL_MEMORY.
> > - *
> > - * Return:   0 on success, 1 on failure
> > - */
> > -static __maybe_unused int efi_lmb_reserve(void)
> > -{
> > -     struct efi_mem_desc *memmap = NULL, *map;
> > -     efi_uintn_t i, map_size = 0;
> > -     efi_status_t ret;
> > -
> > -     ret = efi_get_memory_map_alloc(&map_size, &memmap);
> > -     if (ret != EFI_SUCCESS)
> > -             return 1;
> > -
> > -     for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) {
> > -             if (map->type != EFI_CONVENTIONAL_MEMORY) {
> > -                     lmb_reserve_flags(map_to_sysmem((void *)(uintptr_t)
> > -                                                     map->physical_start),
> > -                                       map->num_pages * EFI_PAGE_SIZE,
> > -                                       map->type == EFI_RESERVED_MEMORY_TYPE
> > -                                           ? LMB_NOMAP : LMB_NONE);
>
>
> Now that you have removed the last usage of LMB_NOMAP, please, remove it
> from enum lmb_flags.

Not all instances are removed. This flag gets used for reserving FDT
memory areas as well. Used in
boot/image-fdt.c:boot_fdt_add_mem_rsv_regions().

-sughosh

> > -     }
> > -     efi_free_pool(memmap);
> > -
> > -     return 0;
> > -}
> > -
> >   /**
> >    * lmb_reserve_common() - Reserve memory region occupied by U-Boot image
> >    * @fdt_blob: pointer to the FDT blob
> > @@ -255,9 +223,6 @@ void lmb_reserve_common(void *fdt_blob)
> >
> >       if (CONFIG_IS_ENABLED(OF_LIBFDT) && fdt_blob)
> >               boot_fdt_add_mem_rsv_regions(fdt_blob);
> > -
> > -     if (CONFIG_IS_ENABLED(EFI_LOADER))
> > -             efi_lmb_reserve();
> >   }
> >
> >   /**
>
diff mbox series

Patch

diff --git a/lib/lmb.c b/lib/lmb.c
index 3059609aea..c9f6ca692e 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -204,38 +204,6 @@  void arch_lmb_reserve_generic(ulong sp, ulong end, ulong align)
 	}
 }
 
-/**
- * efi_lmb_reserve() - add reservations for EFI memory
- *
- * Add reservations for all EFI memory areas that are not
- * EFI_CONVENTIONAL_MEMORY.
- *
- * Return:	0 on success, 1 on failure
- */
-static __maybe_unused int efi_lmb_reserve(void)
-{
-	struct efi_mem_desc *memmap = NULL, *map;
-	efi_uintn_t i, map_size = 0;
-	efi_status_t ret;
-
-	ret = efi_get_memory_map_alloc(&map_size, &memmap);
-	if (ret != EFI_SUCCESS)
-		return 1;
-
-	for (i = 0, map = memmap; i < map_size / sizeof(*map); ++map, ++i) {
-		if (map->type != EFI_CONVENTIONAL_MEMORY) {
-			lmb_reserve_flags(map_to_sysmem((void *)(uintptr_t)
-							map->physical_start),
-					  map->num_pages * EFI_PAGE_SIZE,
-					  map->type == EFI_RESERVED_MEMORY_TYPE
-					      ? LMB_NOMAP : LMB_NONE);
-		}
-	}
-	efi_free_pool(memmap);
-
-	return 0;
-}
-
 /**
  * lmb_reserve_common() - Reserve memory region occupied by U-Boot image
  * @fdt_blob: pointer to the FDT blob
@@ -255,9 +223,6 @@  void lmb_reserve_common(void *fdt_blob)
 
 	if (CONFIG_IS_ENABLED(OF_LIBFDT) && fdt_blob)
 		boot_fdt_add_mem_rsv_regions(fdt_blob);
-
-	if (CONFIG_IS_ENABLED(EFI_LOADER))
-		efi_lmb_reserve();
 }
 
 /**