Skip to contentSkip to conversation

lib: fdtdec: Fill initial ram top with DDR start value from dt

PATCH Superseded Siva Durga Prasad Paladugu 4 participants 6 messages Jun 5, 2018 – Jun 14, 2018 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 lib: fdtdec: Fill initial ram top with DDR start value from dt

Fill initial ram top with DDR base addr value from DT as not filling it here always assumes it as zero while calculating relocation offset and hence lead to failures in somecases. This will assumed as zero if CONFIG_SYS_SDRAM_BASE is not defined.

---
 lib/fdtdec.c | 1 +
 1 file changed, 1 insertion(+)
lib/fdtdec.c +1 -0
index f4e8dbf..34ef9b8 100644
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
        }
 
        gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+       gd->ram_top = (unsigned long)res.start;
        debug("%s: Initial DRAM size %llx\n", __func__,
              (unsigned long long)gd->ram_size);
 

--
2.7.4

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#1 lore raw

PATCH 1/4 lib: fdtdec: Fill initial ram top with DDR start value from dt

Hi,

Quoted 17 lines · Siva Durga Prasad Paladugu

Fill initial ram top with DDR base addr value from DT as not filling it here always assumes it as zero while calculating relocation offset and hence lead to failures in somecases. This will assumed as zero if CONFIG_SYS_SDRAM_BASE is not defined.

---
 lib/fdtdec.c | 1 +
 1 file changed, 1 insertion(+)
lib/fdtdec.c +0 -0
index f4e8dbf..34ef9b8 100644

lib/fdtdec.c int fdtdec_setup_memory_size(void) · line 1178

Quoted 7 lines
lib/fdtdec.c +1 -0
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
 	}
 
 	gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+	gd->ram_top = (unsigned long)res.start;
 	debug("%s: Initial DRAM size %llx\n", __func__,
 	      (unsigned long long)gd->ram_size);
 

I am curious about ram_top meaning. It is used more as ram_base.

I expect we can workaround it by board_get_usable_ram_top() where we decode it exactly the same as patched fdtdec_setup_memory_size() but I don't think it is better solution than this one.

Simon/Tom: any comment?

Thanks,
Michal

#2 lore raw

PATCH 1/4 lib: fdtdec: Fill initial ram top with DDR start value from dt

Hi,

Quoted 30 lines · Michal Simek

Hi,

Quoted 17 lines · Siva Durga Prasad Paladugu

Fill initial ram top with DDR base addr value from DT as not filling it here always assumes it as zero while calculating relocation offset and hence lead to failures in somecases. This will assumed as zero if CONFIG_SYS_SDRAM_BASE is not defined.

---
 lib/fdtdec.c | 1 +
 1 file changed, 1 insertion(+)
lib/fdtdec.c +0 -0
index f4e8dbf..34ef9b8 100644

lib/fdtdec.c int fdtdec_setup_memory_size(void) · line 1178

Quoted 7 lines
lib/fdtdec.c +1 -0
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
      }
 
      gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+     gd->ram_top = (unsigned long)res.start;
      debug("%s: Initial DRAM size %llx\n", __func__,
            (unsigned long long)gd->ram_size);
 

I am curious about ram_top meaning. It is used more as ram_base.

Quoted 5 lines

I expect we can workaround it by board_get_usable_ram_top() where we decode it exactly the same as patched fdtdec_setup_memory_size() but I don't think it is better solution than this one.

Simon/Tom: any comment?

I wonder why it is not set to res.end in this patch?

Comments from global_data.h:

unsigned long ram_top; /* Top address of RAM used by U-Boot */ phys_size_t ram_size; /* RAM size */

Regards,
Simon

#3 lore raw

PATCH 1/4 lib: fdtdec: Fill initial ram top with DDR start value from dt

Quoted 38 lines · Simon Glass

Hi,

Quoted 34 lines · Michal Simek

Hi,

Quoted 17 lines · Siva Durga Prasad Paladugu

Fill initial ram top with DDR base addr value from DT as not filling it here always assumes it as zero while calculating relocation offset and hence lead to failures in somecases. This will assumed as zero if CONFIG_SYS_SDRAM_BASE is not defined.

---
 lib/fdtdec.c | 1 +
 1 file changed, 1 insertion(+)
lib/fdtdec.c +0 -0
index f4e8dbf..34ef9b8 100644

lib/fdtdec.c int fdtdec_setup_memory_size(void) · line 1178

Quoted 7 lines
lib/fdtdec.c +1 -0
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
      }
 
      gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+     gd->ram_top = (unsigned long)res.start;
      debug("%s: Initial DRAM size %llx\n", __func__,
            (unsigned long long)gd->ram_size);
 

I am curious about ram_top meaning. It is used more as ram_base.

I expect we can workaround it by board_get_usable_ram_top() where we decode it exactly the same as patched fdtdec_setup_memory_size() but I don't think it is better solution than this one.

Quoted 8 lines
Quoted 1 line

Simon/Tom: any comment?

I wonder why it is not set to res.end in this patch?

Comments from global_data.h:

unsigned long ram_top; /* Top address of RAM used by U-Boot */ phys_size_t ram_size; /* RAM size */

I am aware about this but in common/ but I have incorrectly read this code in setup_dest_addr()

DP: Can you please check this again why you have created this patch?

Thanks,
Michal

#4 lore raw

PATCH 1/4 lib: fdtdec: Fill initial ram top with DDR start value from dt

In reply to Simon Glass

Hi Simon,

Quoted 48 lines

-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: Saturday, June 09, 2018 3:29 AM
To: Michal Simek <[email protected]>
Cc: Siva Durga Prasad Paladugu <[email protected]>; U-Boot Mailing List <[email protected]>; Tom Rini <[email protected]>
Subject: Re: [PATCH 1/4] lib: fdtdec: Fill initial ram top with DDR start value from dt

Hi,

Quoted 35 lines · Michal Simek

Hi,

Quoted 18 lines · Siva Durga Prasad Paladugu

Fill initial ram top with DDR base addr value from DT as not filling it here always assumes it as zero while calculating relocation offset and hence lead to failures in somecases. This will assumed as zero if CONFIG_SYS_SDRAM_BASE is not defined.

Signed-off-by: Siva Durga Prasad Paladugu
<[email protected]>

---
 lib/fdtdec.c | 1 +
 1 file changed, 1 insertion(+)
lib/fdtdec.c index f4e8dbf..34ef9b8 renamed from lib/fdtdec.c +0 -0

100644

lib/fdtdec.c int fdtdec_setup_memory_size(void) · line 1178

Quoted 7 lines
lib/fdtdec.c +1 -0
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
      }
 
      gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+     gd->ram_top = (unsigned long)res.start;
      debug("%s: Initial DRAM size %llx\n", __func__,
            (unsigned long long)gd->ram_size);
 

I am curious about ram_top meaning. It is used more as ram_base.

I expect we can workaround it by board_get_usable_ram_top() where we decode it exactly the same as patched fdtdec_setup_memory_size() but I don't think it is better solution than this one.

Quoted 8 lines
Quoted 1 line

Simon/Tom: any comment?

I wonder why it is not set to res.end in this patch?

Comments from global_data.h:

unsigned long ram_top; /* Top address of RAM used by U-Boot */ phys_size_t ram_size; /* RAM size */

Yes, it holds the ram high address but, initially it should contain start address then in routine setup_dest_addr() (file common_board_f.c), it will be updated by getting the total mem size as below.
gd->ram_top += get_effective_memsize();

Lets consider if start address is non zero then it results in wrong ram_top without this patch. So, this patch fixes it by initializing it to ram start address and later in setup_dest_addr(), it will be updated to actual ram high address. Otherway of fixing it is, we should add new variable to gd_t to hold ram_start and then while calculating ram_top in setup_dest_addr(), we should use it as gd->ram_top = gd->ram_start + get_effective_memsize() as gd->bd->bi_dram[0].start didn’t get filled by this time during init.

Thanks,
Siva

Quoted 3 lines

Regards,
Simon

#5 lore raw

PATCH 1/4 lib: fdtdec: Fill initial ram top with DDR start value from dt

Hi Siva,

Quoted 59 lines · Siva Durga Prasad Paladugu

Hi Simon,

Quoted 48 lines

-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: Saturday, June 09, 2018 3:29 AM
To: Michal Simek <[email protected]>
Cc: Siva Durga Prasad Paladugu <[email protected]>; U-Boot Mailing List <[email protected]>; Tom Rini <[email protected]>
Subject: Re: [PATCH 1/4] lib: fdtdec: Fill initial ram top with DDR start value from dt

Hi,

Quoted 35 lines · Michal Simek

Hi,

Quoted 18 lines · Siva Durga Prasad Paladugu

Fill initial ram top with DDR base addr value from DT as not filling it here always assumes it as zero while calculating relocation offset and hence lead to failures in somecases. This will assumed as zero if CONFIG_SYS_SDRAM_BASE is not defined.

Signed-off-by: Siva Durga Prasad Paladugu
<[email protected]>

---
 lib/fdtdec.c | 1 +
 1 file changed, 1 insertion(+)
lib/fdtdec.c index f4e8dbf..34ef9b8 renamed from lib/fdtdec.c +0 -0

100644

lib/fdtdec.c int fdtdec_setup_memory_size(void) · line 1178

Quoted 7 lines
lib/fdtdec.c +1 -0
@@ -1172,6 +1172,7 @@ int fdtdec_setup_memory_size(void)
      }
 
      gd->ram_size = (phys_size_t)(res.end - res.start + 1);
+     gd->ram_top = (unsigned long)res.start;
      debug("%s: Initial DRAM size %llx\n", __func__,
            (unsigned long long)gd->ram_size);
 

I am curious about ram_top meaning. It is used more as ram_base.

I expect we can workaround it by board_get_usable_ram_top() where we decode it exactly the same as patched fdtdec_setup_memory_size() but I don't think it is better solution than this one.

Quoted 8 lines
Quoted 1 line

Simon/Tom: any comment?

I wonder why it is not set to res.end in this patch?

Comments from global_data.h:

unsigned long ram_top; /* Top address of RAM used by U-Boot */ phys_size_t ram_size; /* RAM size */

Quoted 7 lines

Yes, it holds the ram high address but, initially it should contain start address then in routine setup_dest_addr() (file common_board_f.c), it will be updated by getting the total mem size as below.
gd->ram_top += get_effective_memsize();

Lets consider if start address is non zero then it results in wrong ram_top without this patch. So, this patch fixes it by initializing it to ram start address and later in setup_dest_addr(), it will be updated to actual ram high address. Otherway of fixing it is, we should add new variable to gd_t to hold ram_start and then while calculating ram_top in setup_dest_addr(), we should use it as gd->ram_top = gd->ram_start + get_effective_memsize() as gd->bd->bi_dram[0].start didn’t get filled by this time during init.

Thanks for the explanation. I think adding that new variable would be better and less confusing. But then fdtdec_setup_memory_size() needs to be renamed.

Also I think it is confusing to set gd->ram_size to CONFIG_SYS_SDRAM_BASE and then increase it, so you should be able to change that to ram_start also.

Regards,
Simon