From: Raymond Mao <raymondmaoca@gmail.com>
To: u-boot@lists.denx.de
Cc: uboot@riscstar.com, u-boot-spacemit@groups.io,
raymond.mao@riscstar.com, rick@andestech.com,
ycliang@andestech.com, trini@konsulko.com, lukma@denx.de,
hs@nabladev.com, jh80.chung@samsung.com, peng.fan@nxp.com,
xypron.glpk@gmx.de, randolph@andestech.com, dlan@gentoo.org,
junhui.liu@pigmoral.tech, neil.armstrong@linaro.org,
quentin.schulz@cherry.de, samuel@sholland.org,
raymondmaoca@gmail.com, Guodong Xu <guodong@riscstar.com>
Subject: [PATCH 7/8] cmd: meminfo: fix the lmb info for large DRAM
Date: Fri, 12 Jun 2026 16:19:00 -0400 [thread overview]
Message-ID: <20260612201901.73657-8-raymondmaoca@gmail.com> (raw)
In-Reply-To: <20260612201901.73657-1-raymondmaoca@gmail.com>
From: Guodong Xu <guodong@riscstar.com>
When DRAM size exceeds 4GB, it may be split into two separate banks,
leaving an address hole between them.
To properly handle this configuration, LMB regions must be calculated
individually for each memory bank. Additionally, all address
calculations should support 64-bit to accommodate large memory ranges.
Signed-off-by: Guodong Xu <guodong@riscstar.com>
Signed-off-by: Raymond Mao <raymond.mao@riscstar.com>
---
cmd/meminfo.c | 34 ++++++++++++++++++++++++++++------
1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/cmd/meminfo.c b/cmd/meminfo.c
index 537ef2a0e13..c5cf01f62ef 100644
--- a/cmd/meminfo.c
+++ b/cmd/meminfo.c
@@ -31,31 +31,53 @@ static void print_region(const char *name, phys_addr_t base, phys_addr_t size,
(unsigned long long)base,
(unsigned long long)size,
(unsigned long long)end);
- if (*uptop)
+ if (*uptop > end)
printf(" %13llx", (unsigned long long)(*uptop - end));
+ else
+ printf(" %13llx", (unsigned long long)(end - end));
putc('\n');
*uptop = base;
}
static void show_lmb(const struct lmb *lmb, phys_addr_t *uptop)
{
- int i;
+ int i, j;
+ phys_addr_t bank_top[CONFIG_NR_DRAM_BANKS];
+ struct bd_info *bd = gd->bd;
+ bool get_bank;
+
+ for (j = 0; j < CONFIG_NR_DRAM_BANKS; j++)
+ bank_top[j] = bd->bi_dram[j].start + bd->bi_dram[j].size;
for (i = lmb->used_mem.count - 1; i >= 0; i--) {
const struct lmb_region *rgn = alist_get(&lmb->used_mem, i,
struct lmb_region);
+ for (j = 0, get_bank = false; j < CONFIG_NR_DRAM_BANKS; j++) {
+ if (rgn->base >= bd->bi_dram[j].start &&
+ rgn->base < bank_top[j]) {
+ get_bank = true;
+ break;
+ }
+ }
+ if (!get_bank) {
+ log_err("The region (base:0x%llx, size:0x%llx) does not exists in any DRAM bank.\n",
+ (unsigned long long)rgn->base, (unsigned long long)rgn->size);
+ return;
+ }
/*
* Assume that the top lmb region is the U-Boot region, so just
* take account of the memory not already reported
*/
if (lmb->used_mem.count - 1)
- print_region("lmb", rgn->base, *uptop - rgn->base,
- uptop);
+ print_region("lmb", rgn->base, bank_top[j] - rgn->base,
+ &bank_top[j]);
else
- print_region("lmb", rgn->base, rgn->size, uptop);
- *uptop = rgn->base;
+ print_region("lmb", rgn->base, rgn->size, &bank_top[j]);
+ bank_top[j] = rgn->base;
}
+
+ *uptop = bank_top[0];
}
static int do_meminfo(struct cmd_tbl *cmdtp, int flag, int argc,
--
2.25.1
next prev parent reply other threads:[~2026-06-12 20:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 20:18 [PATCH 0/8] Add SD card and eMMC support for SpacemiT K1 Raymond Mao
2026-06-12 20:18 ` [PATCH 1/8] spacemit: k1: select boot device via config registers Raymond Mao
2026-06-13 3:50 ` Yao Zi
2026-06-12 20:18 ` [PATCH 2/8] mmc: k1: add sdhci platform driver Raymond Mao
2026-06-13 6:43 ` Yao Zi
2026-06-12 20:18 ` [PATCH 3/8] dts: k1: add SD card support in u-boot overlay Raymond Mao
2026-06-12 20:18 ` [PATCH 4/8] configs: k1: enable SD and eMMC support Raymond Mao
2026-06-12 20:18 ` [PATCH 5/8] doc: spacemit: flash on K1 SoC based boards Raymond Mao
2026-06-12 20:18 ` [PATCH 6/8] cmd: meminfo: widen memory map addresses to phys_addr_t Raymond Mao
2026-06-12 20:19 ` Raymond Mao [this message]
2026-06-12 20:19 ` [PATCH 8/8] cmd: tlv_eeprom: fix accessing invalid parameter Raymond Mao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260612201901.73657-8-raymondmaoca@gmail.com \
--to=raymondmaoca@gmail.com \
--cc=dlan@gentoo.org \
--cc=guodong@riscstar.com \
--cc=hs@nabladev.com \
--cc=jh80.chung@samsung.com \
--cc=junhui.liu@pigmoral.tech \
--cc=lukma@denx.de \
--cc=neil.armstrong@linaro.org \
--cc=peng.fan@nxp.com \
--cc=quentin.schulz@cherry.de \
--cc=randolph@andestech.com \
--cc=raymond.mao@riscstar.com \
--cc=rick@andestech.com \
--cc=samuel@sholland.org \
--cc=trini@konsulko.com \
--cc=u-boot-spacemit@groups.io \
--cc=u-boot@lists.denx.de \
--cc=uboot@riscstar.com \
--cc=xypron.glpk@gmx.de \
--cc=ycliang@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.