public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] common: bootm: reserve memory bank
@ 2018-06-14  7:07 Jason Zhu
  2018-06-18 19:02 ` Tom Rini
  2018-06-25  2:31 ` Kever Yang
  0 siblings, 2 replies; 5+ messages in thread
From: Jason Zhu @ 2018-06-14  7:07 UTC (permalink / raw)
  To: u-boot

Actually the DRAM is not only seperated in one
bank. The DRAM bank information is stored in
gd->bd->bi_dram, so reserve lmb according to
gd->bd->bi_dram.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
---
 common/bootm.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index e789f68..46689fa 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -53,16 +53,23 @@ __weak void board_quiesce_devices(void)
 #ifdef CONFIG_LMB
 static void boot_start_lmb(bootm_headers_t *images)
 {
+	lmb_init(&images->lmb);
+#ifdef CONFIG_NR_DRAM_BANKS
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+		lmb_add(&images->lmb, gd->bd->bi_dram[i].start,
+			gd->bd->bi_dram[i].size);
+	}
+#else
 	ulong		mem_start;
 	phys_size_t	mem_size;
 
-	lmb_init(&images->lmb);
-
 	mem_start = env_get_bootm_low();
 	mem_size = env_get_bootm_size();
 
 	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
-
+#endif
 	arch_lmb_reserve(&images->lmb);
 	board_lmb_reserve(&images->lmb);
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] common: bootm: reserve memory bank
@ 2018-06-14  8:06 Jason Zhu
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Zhu @ 2018-06-14  8:06 UTC (permalink / raw)
  To: u-boot

Actually the DRAM is not only seperated in one
bank. The DRAM bank information is stored in
gd->bd->bi_dram, so reserve lmb according to
gd->bd->bi_dram.

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
---
 common/bootm.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index e789f68..46689fa 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -53,16 +53,23 @@ __weak void board_quiesce_devices(void)
 #ifdef CONFIG_LMB
 static void boot_start_lmb(bootm_headers_t *images)
 {
+	lmb_init(&images->lmb);
+#ifdef CONFIG_NR_DRAM_BANKS
+	int i;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+		lmb_add(&images->lmb, gd->bd->bi_dram[i].start,
+			gd->bd->bi_dram[i].size);
+	}
+#else
 	ulong		mem_start;
 	phys_size_t	mem_size;
 
-	lmb_init(&images->lmb);
-
 	mem_start = env_get_bootm_low();
 	mem_size = env_get_bootm_size();
 
 	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
-
+#endif
 	arch_lmb_reserve(&images->lmb);
 	board_lmb_reserve(&images->lmb);
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] common: bootm: reserve memory bank
  2018-06-14  7:07 [U-Boot] [PATCH] common: bootm: reserve memory bank Jason Zhu
@ 2018-06-18 19:02 ` Tom Rini
  2018-06-19  1:20   ` jason.zhu at rock-chips.com
  2018-06-25  2:31 ` Kever Yang
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Rini @ 2018-06-18 19:02 UTC (permalink / raw)
  To: u-boot

On Thu, Jun 14, 2018 at 03:07:25PM +0800, Jason Zhu wrote:

> Actually the DRAM is not only seperated in one
> bank. The DRAM bank information is stored in
> gd->bd->bi_dram, so reserve lmb according to
> gd->bd->bi_dram.
> 
> Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
> ---
>  common/bootm.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index e789f68..46689fa 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -53,16 +53,23 @@ __weak void board_quiesce_devices(void)
>  #ifdef CONFIG_LMB
>  static void boot_start_lmb(bootm_headers_t *images)
>  {
> +	lmb_init(&images->lmb);
> +#ifdef CONFIG_NR_DRAM_BANKS
> +	int i;
> +
> +	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> +		lmb_add(&images->lmb, gd->bd->bi_dram[i].start,
> +			gd->bd->bi_dram[i].size);
> +	}
> +#else
>  	ulong		mem_start;
>  	phys_size_t	mem_size;
>  
> -	lmb_init(&images->lmb);
> -
>  	mem_start = env_get_bootm_low();
>  	mem_size = env_get_bootm_size();
>  
>  	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> -
> +#endif
>  	arch_lmb_reserve(&images->lmb);
>  	board_lmb_reserve(&images->lmb);
>  }

Can you describe a bit how you ran into this problem?  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180618/ae0c2d01/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] common: bootm: reserve memory bank
  2018-06-18 19:02 ` Tom Rini
@ 2018-06-19  1:20   ` jason.zhu at rock-chips.com
  0 siblings, 0 replies; 5+ messages in thread
From: jason.zhu at rock-chips.com @ 2018-06-19  1:20 UTC (permalink / raw)
  To: u-boot

> Actually the DRAM is not only seperated in one
> bank. The DRAM bank information is stored in
> gd->bd->bi_dram, so reserve lmb according to
> gd->bd->bi_dram.
>
> Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
> ---
>  common/bootm.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/common/bootm.c b/common/bootm.c
> index e789f68..46689fa 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -53,16 +53,23 @@ __weak void board_quiesce_devices(void)
>  #ifdef CONFIG_LMB
>  static void boot_start_lmb(bootm_headers_t *images)
>  {
> + lmb_init(&images->lmb);
> +#ifdef CONFIG_NR_DRAM_BANKS
> + int i;
> +
> + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> + lmb_add(&images->lmb, gd->bd->bi_dram[i].start,
> + gd->bd->bi_dram[i].size);
> + }
> +#else
>  ulong mem_start;
>  phys_size_t mem_size;
> 
> - lmb_init(&images->lmb);
> -
>  mem_start = env_get_bootm_low();
>  mem_size = env_get_bootm_size();
> 
>  lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> -
> +#endif
>  arch_lmb_reserve(&images->lmb);
>  board_lmb_reserve(&images->lmb);
>  }
 
Can you describe a bit how you ran into this problem?  Thanks!

>  Run the function dram_init_banksize, then the dram is seperated in several
> banks. Sometimes the bank0's size maybe zero. If we call boot_start_lmb
> to reserve lmb which just only reserve bank0, the lmb's memory size is zero.
> This can cause allocate memory error when we want to reserve lmb for fdt.
> So reserve lmb depend on  CONFIG_NR_DRAM_BANKS(function dram_init_banksize 
> seperates the dram by CONFIG_NR_DRAM_BANKS) but not just bank0.
> Thanks!



jason.zhu at rock-chips.com
 
From: Tom Rini
Date: 2018-06-19 03:02
To: Jason Zhu
CC: Simon Glass; u-boot; Alexander Graf
Subject: Re: [U-Boot] [PATCH] common: bootm: reserve memory bank
On Thu, Jun 14, 2018 at 03:07:25PM +0800, Jason Zhu wrote:
 
> Actually the DRAM is not only seperated in one
> bank. The DRAM bank information is stored in
> gd->bd->bi_dram, so reserve lmb according to
> gd->bd->bi_dram.
> 
> Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
> ---
>  common/bootm.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index e789f68..46689fa 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -53,16 +53,23 @@ __weak void board_quiesce_devices(void)
>  #ifdef CONFIG_LMB
>  static void boot_start_lmb(bootm_headers_t *images)
>  {
> + lmb_init(&images->lmb);
> +#ifdef CONFIG_NR_DRAM_BANKS
> + int i;
> +
> + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> + lmb_add(&images->lmb, gd->bd->bi_dram[i].start,
> + gd->bd->bi_dram[i].size);
> + }
> +#else
>  ulong mem_start;
>  phys_size_t mem_size;
>  
> - lmb_init(&images->lmb);
> -
>  mem_start = env_get_bootm_low();
>  mem_size = env_get_bootm_size();
>  
>  lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> -
> +#endif
>  arch_lmb_reserve(&images->lmb);
>  board_lmb_reserve(&images->lmb);
>  }
 
Can you describe a bit how you ran into this problem?  Thanks!
 
-- 
Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] common: bootm: reserve memory bank
  2018-06-14  7:07 [U-Boot] [PATCH] common: bootm: reserve memory bank Jason Zhu
  2018-06-18 19:02 ` Tom Rini
@ 2018-06-25  2:31 ` Kever Yang
  1 sibling, 0 replies; 5+ messages in thread
From: Kever Yang @ 2018-06-25  2:31 UTC (permalink / raw)
  To: u-boot

Hi Jason,


On 06/14/2018 03:07 PM, Jason Zhu wrote:
> Actually the DRAM is not only seperated in one
> bank. The DRAM bank information is stored in
> gd->bd->bi_dram, so reserve lmb according to
> gd->bd->bi_dram.

This commit message is not clear enough for what you have done in this
patch,
you should mention the LMB is not correctly mapped when DRAM has more
than 1 bank.
>
> Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
> ---
>  common/bootm.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/common/bootm.c b/common/bootm.c
> index e789f68..46689fa 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -53,16 +53,23 @@ __weak void board_quiesce_devices(void)
>  #ifdef CONFIG_LMB
>  static void boot_start_lmb(bootm_headers_t *images)
>  {
> +	lmb_init(&images->lmb);
> +#ifdef CONFIG_NR_DRAM_BANKS
> +	int i;
> +
> +	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> +		lmb_add(&images->lmb, gd->bd->bi_dram[i].start,
> +			gd->bd->bi_dram[i].size);
> +	}
> +#else
>  	ulong		mem_start;
>  	phys_size_t	mem_size;

For the config without CONFIG_NR_DRAM_BANKS enable, there will be a warning.

Thanks,
- Kever
>  
> -	lmb_init(&images->lmb);
> -
>  	mem_start = env_get_bootm_low();
>  	mem_size = env_get_bootm_size();
>  
>  	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> -
> +#endif
>  	arch_lmb_reserve(&images->lmb);
>  	board_lmb_reserve(&images->lmb);
>  }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-25  2:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-14  7:07 [U-Boot] [PATCH] common: bootm: reserve memory bank Jason Zhu
2018-06-18 19:02 ` Tom Rini
2018-06-19  1:20   ` jason.zhu at rock-chips.com
2018-06-25  2:31 ` Kever Yang
  -- strict thread matches above, loose matches on Subject: below --
2018-06-14  8:06 Jason Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox