* [PATCH V2] cmd: mem: fix to display wrong memory information
[not found] <CGME20210128023504epcas1p3cba0cba08a8d5baf7f72baba0ced197f@epcas1p3.samsung.com>
@ 2021-01-28 2:35 ` Jaehoon Chung
2021-01-28 9:33 ` Stefan Roese
0 siblings, 1 reply; 3+ messages in thread
From: Jaehoon Chung @ 2021-01-28 2:35 UTC (permalink / raw)
To: u-boot
When run meminfo command, it's displayed wrong memory information.
Because some boards are that gd->ram_size is reassigned to other value
in board file.
Additionally, display a memory bank information.
On 4G RPI4 target
- Before
U-Boot> meminfo
DRAM: 948MiB
- After
U-Boot> meminfo
Bank #0: 0 948 MiB
Bank #1: 40000000 2.9 GiB
Bank #2: 0 0 Bytes
Bank #3: 0 0 Bytes
DRAM: 3.9GiB
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
Changes in v2:
- Change patch subject prefix from "common: board_f" to "cmd: mem"
- Update commit-msg
- Revert common/board_f.c modification. Instead, add codes in mem.c
---
cmd/mem.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/cmd/mem.c b/cmd/mem.c
index 1d4f2bab2f9a..86f48a6e121a 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -1387,8 +1387,22 @@ U_BOOT_CMD(
static int do_mem_info(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
+ unsigned long long size;
+
+#ifdef CONFIG_NR_DRAM_BANKS
+ int i;
+
+ for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+ size += gd->bd->bi_dram[i].size;
+ printf("Bank #%d: %llx ", i,
+ (unsigned long long)(gd->bd->bi_dram[i].start));
+ print_size(gd->bd->bi_dram[i].size, "\n");
+ }
+#else
+ size = gd->ram_size;
+#endif
puts("DRAM: ");
- print_size(gd->ram_size, "\n");
+ print_size(size, "\n");
return 0;
}
--
2.29.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH V2] cmd: mem: fix to display wrong memory information
2021-01-28 2:35 ` [PATCH V2] cmd: mem: fix to display wrong memory information Jaehoon Chung
@ 2021-01-28 9:33 ` Stefan Roese
2021-01-29 4:24 ` Jaehoon Chung
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Roese @ 2021-01-28 9:33 UTC (permalink / raw)
To: u-boot
On 28.01.21 03:35, Jaehoon Chung wrote:
> When run meminfo command, it's displayed wrong memory information.
> Because some boards are that gd->ram_size is reassigned to other value
> in board file.
> Additionally, display a memory bank information.
>
> On 4G RPI4 target
> - Before
> U-Boot> meminfo
> DRAM: 948MiB
> - After
> U-Boot> meminfo
> Bank #0: 0 948 MiB
> Bank #1: 40000000 2.9 GiB
> Bank #2: 0 0 Bytes
> Bank #3: 0 0 Bytes
> DRAM: 3.9GiB
>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> ---
> Changes in v2:
> - Change patch subject prefix from "common: board_f" to "cmd: mem"
> - Update commit-msg
> - Revert common/board_f.c modification. Instead, add codes in mem.c
> ---
> cmd/mem.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/cmd/mem.c b/cmd/mem.c
> index 1d4f2bab2f9a..86f48a6e121a 100644
> --- a/cmd/mem.c
> +++ b/cmd/mem.c
> @@ -1387,8 +1387,22 @@ U_BOOT_CMD(
> static int do_mem_info(struct cmd_tbl *cmdtp, int flag, int argc,
> char *const argv[])
> {
> + unsigned long long size;
> +
> +#ifdef CONFIG_NR_DRAM_BANKS
> + int i;
> +
> + for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> + size += gd->bd->bi_dram[i].size;
> + printf("Bank #%d: %llx ", i,
> + (unsigned long long)(gd->bd->bi_dram[i].start));
> + print_size(gd->bd->bi_dram[i].size, "\n");
> + }
> +#else
> + size = gd->ram_size;
> +#endif
CONFIG_NR_DRAM_BANKS is always defined! There has been some work to
all #ifdef's in this area, as it's not needed. So please don't add new
#ifdef's here, as they are not needed. Please search for:
Remove CONFIG_NR_DRAM_BANKS option and bi_memstart/memsize from bd_info
If your board does not display the correct size, then you most likely
have some issues in your local dram_init_banksize() or dram_init()
implementation. If the total RAM cannot be used by U-Boot (which is
a common issue) then please use something like
board_get_usable_ram_top() and/or get_effective_memsize() for this.
Here on my 4GiB Octeon MIPS board:
...
DRAM: 256 MiB (4 GiB total)
...
=> meminfo
DRAM: 4 GiB
=> bdinfo
boot_params = 0x0000000000000000
DRAM bank = 0x0000000000000000
-> start = 0xffffffff80000000
-> size = 0x0000000010000000
...
HTH.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH V2] cmd: mem: fix to display wrong memory information
2021-01-28 9:33 ` Stefan Roese
@ 2021-01-29 4:24 ` Jaehoon Chung
0 siblings, 0 replies; 3+ messages in thread
From: Jaehoon Chung @ 2021-01-29 4:24 UTC (permalink / raw)
To: u-boot
On 1/28/21 6:33 PM, Stefan Roese wrote:
> On 28.01.21 03:35, Jaehoon Chung wrote:
>> When run meminfo command, it's displayed wrong memory information.
>> Because some boards are that gd->ram_size is reassigned to other value
>> in board file.
>> Additionally, display a memory bank information.
>>
>> On 4G RPI4 target
>> - Before
>> ??? U-Boot> meminfo
>> ??? DRAM: 948MiB
>> - After
>> ??? U-Boot> meminfo
>> ??? Bank #0: 0 948 MiB
>> ??? Bank #1: 40000000 2.9 GiB
>> ??? Bank #2: 0 0 Bytes
>> ??? Bank #3: 0 0 Bytes
>> ??? DRAM: 3.9GiB
>>
>> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
>> ---
>> Changes in v2:
>> - Change patch subject prefix from "common: board_f" to "cmd: mem"
>> - Update commit-msg
>> - Revert common/board_f.c modification. Instead, add codes in mem.c
>> ---
>> ? cmd/mem.c | 16 +++++++++++++++-
>> ? 1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/cmd/mem.c b/cmd/mem.c
>> index 1d4f2bab2f9a..86f48a6e121a 100644
>> --- a/cmd/mem.c
>> +++ b/cmd/mem.c
>> @@ -1387,8 +1387,22 @@ U_BOOT_CMD(
>> ? static int do_mem_info(struct cmd_tbl *cmdtp, int flag, int argc,
>> ???????????????? char *const argv[])
>> ? {
>> +??? unsigned long long size;
>> +
>> +#ifdef CONFIG_NR_DRAM_BANKS
>> +??? int i;
>> +
>> +??? for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
>> +??????? size += gd->bd->bi_dram[i].size;
>> +??????? printf("Bank #%d: %llx ", i,
>> +????????????? (unsigned long long)(gd->bd->bi_dram[i].start));
>> +??????????? print_size(gd->bd->bi_dram[i].size, "\n");
>> +??? }
>> +#else
>> +??? size = gd->ram_size;
>> +#endif
>
> CONFIG_NR_DRAM_BANKS is always defined! There has been some work to
> all #ifdef's in this area, as it's not needed. So please don't add new
> #ifdef's here, as they are not needed. Please search for:
>
> Remove CONFIG_NR_DRAM_BANKS option and bi_memstart/memsize from bd_info
>
> If your board does not display the correct size, then you most likely
> have some issues in your local dram_init_banksize() or dram_init()
> implementation. If the total RAM cannot be used by U-Boot (which is
> a common issue) then please use something like
> board_get_usable_ram_top() and/or get_effective_memsize() for this.
I understood what you said. Frankly, i had tried to use memory information into my bootscript.
So i have checked mmcinfo command.
Right, there is included information not to use by U-boot side.
I thought a issue what not display Total Ram information with meminfo.
(Because there isn't any description about meminfo.)
But if it's displayed memory that can be used by U-boot, this patch doesn't need.
I have tested on my own targets. (RPI4 2G/4G/8G, meson target - VIM3(4G), Odroid-N2(4G))
- Those boards were displayed almost under 1G.
Thanks for comment and checking!
Best Regards,
Jaehoon Chung
>
> Here on my 4GiB Octeon MIPS board:
>
> ...
> DRAM:? 256 MiB (4 GiB total)
> ...
> => meminfo
> DRAM:? 4 GiB
> => bdinfo
> boot_params = 0x0000000000000000
> DRAM bank?? = 0x0000000000000000
> -> start??? = 0xffffffff80000000
> -> size???? = 0x0000000010000000
> ...
>
> HTH.
>
> Thanks,
> Stefan
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-29 4:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20210128023504epcas1p3cba0cba08a8d5baf7f72baba0ced197f@epcas1p3.samsung.com>
2021-01-28 2:35 ` [PATCH V2] cmd: mem: fix to display wrong memory information Jaehoon Chung
2021-01-28 9:33 ` Stefan Roese
2021-01-29 4:24 ` Jaehoon Chung
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.