diff mbox series

[v7,1/8] efi_loader: remove unused code from copy_fdt()

Message ID 20250310115750.1019051-2-sughosh.ganu@linaro.org
State New
Headers show
Series Add pmem node for preserving distro ISO's | expand

Commit Message

Sughosh Ganu March 10, 2025, 11:57 a.m. UTC
There is logic in the copy_fdt() function which is iterating over the
platform's DRAM banks and setting the fdt_ram_start variable. However,
this variable is not used subsequently in the function. Remove this
superfluous code.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since V6: New patch

 lib/efi_loader/efi_helper.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

Comments

Ilias Apalodimas March 11, 2025, 1:21 p.m. UTC | #1
Heinrich, do you remember why this was originally here?
 I looked at 6422820ac3e59 which moved that code around, but the same
code was there as well

On Mon, 10 Mar 2025 at 13:58, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> There is logic in the copy_fdt() function which is iterating over the
> platform's DRAM banks and setting the fdt_ram_start variable. However,
> this variable is not used subsequently in the function. Remove this
> superfluous code.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
> Changes since V6: New patch
>
>  lib/efi_loader/efi_helper.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
> index 04b2efc4a3b..15ad042bc61 100644
> --- a/lib/efi_loader/efi_helper.c
> +++ b/lib/efi_loader/efi_helper.c
> @@ -454,23 +454,11 @@ efi_status_t efi_env_set_load_options(efi_handle_t handle,
>   */
>  static efi_status_t copy_fdt(void **fdtp)
>  {
> -       unsigned long fdt_ram_start = -1L, fdt_pages;
> +       unsigned long fdt_pages;
>         efi_status_t ret = 0;
>         void *fdt, *new_fdt;
>         u64 new_fdt_addr;
>         uint fdt_size;
> -       int i;
> -
> -       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> -               u64 ram_start = gd->bd->bi_dram[i].start;
> -               u64 ram_size = gd->bd->bi_dram[i].size;
> -
> -               if (!ram_size)
> -                       continue;
> -
> -               if (ram_start < fdt_ram_start)
> -                       fdt_ram_start = ram_start;
> -       }
>
>         /*
>          * Give us at least 12 KiB of breathing room in case the device tree
> --
> 2.34.1
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Heinrich Schuchardt March 11, 2025, 1:37 p.m. UTC | #2
On 11.03.25 14:21, Ilias Apalodimas wrote:
> Heinrich, do you remember why this was originally here?
>   I looked at 6422820ac3e59 which moved that code around, but the same
> code was there as well
> 
> On Mon, 10 Mar 2025 at 13:58, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>>
>> There is logic in the copy_fdt() function which is iterating over the
>> platform's DRAM banks and setting the fdt_ram_start variable. However,
>> this variable is not used subsequently in the function. Remove this
>> superfluous code.
>>
>> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
>> ---
>> Changes since V6: New patch
>>
>>   lib/efi_loader/efi_helper.c | 14 +-------------
>>   1 file changed, 1 insertion(+), 13 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
>> index 04b2efc4a3b..15ad042bc61 100644
>> --- a/lib/efi_loader/efi_helper.c
>> +++ b/lib/efi_loader/efi_helper.c
>> @@ -454,23 +454,11 @@ efi_status_t efi_env_set_load_options(efi_handle_t handle,
>>    */
>>   static efi_status_t copy_fdt(void **fdtp)
>>   {
>> -       unsigned long fdt_ram_start = -1L, fdt_pages;
>> +       unsigned long fdt_pages;
>>          efi_status_t ret = 0;
>>          void *fdt, *new_fdt;
>>          u64 new_fdt_addr;
>>          uint fdt_size;
>> -       int i;
>> -
>> -       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
>> -               u64 ram_start = gd->bd->bi_dram[i].start;
>> -               u64 ram_size = gd->bd->bi_dram[i].size;
>> -
>> -               if (!ram_size)
>> -                       continue;
>> -
>> -               if (ram_start < fdt_ram_start)
>> -                       fdt_ram_start = ram_start;
>> -       }

The removed code was introduced by Alex in 2016 with patch
ad0c1a3d2cea ("efi_loader: Put fdt into convenient location").

Writing the device-tree at the start of RAM may have worked for some 
boards at the time but on many others this would be inside reserved memory.

Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

>>
>>          /*
>>           * Give us at least 12 KiB of breathing room in case the device tree
>> --
>> 2.34.1
>>
> 
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index 04b2efc4a3b..15ad042bc61 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -454,23 +454,11 @@  efi_status_t efi_env_set_load_options(efi_handle_t handle,
  */
 static efi_status_t copy_fdt(void **fdtp)
 {
-	unsigned long fdt_ram_start = -1L, fdt_pages;
+	unsigned long fdt_pages;
 	efi_status_t ret = 0;
 	void *fdt, *new_fdt;
 	u64 new_fdt_addr;
 	uint fdt_size;
-	int i;
-
-	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-		u64 ram_start = gd->bd->bi_dram[i].start;
-		u64 ram_size = gd->bd->bi_dram[i].size;
-
-		if (!ram_size)
-			continue;
-
-		if (ram_start < fdt_ram_start)
-			fdt_ram_start = ram_start;
-	}
 
 	/*
 	 * Give us at least 12 KiB of breathing room in case the device tree