Skip to contentSkip to conversation

arm: mediatek: mt7988: restore full DRAM bank reporting

PATCH In review Rudy Andram 3 participants 8 messages Jun 2 – Jun 10

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mediatek: mt7988: restore full DRAM bank reporting

MT7988 detects the full installed DRAM in dram_init(), but after commit bddd6bbef3dc ("arm: mediatek: mt7988: drop dram_init_banksize()") it fell back to the generic dram_init_banksize() implementation.

That generic path populates bd->bi_dram[0].size with get_effective_memsize(), which is capped by CFG_MAX_MEM_MAPPED. On MT7988 this limits the exported DRAM bank to 3 GiB even when 8 GiB is installed.

As a result, U-Boot reports the full DRAM in gd->ram_size but exposes only the low 3 GiB through bd->bi_dram[]. This truncated map can then propagate to later stages through memory handoff and DT fixups.

On a Banana Pi R4 Pro 8G (MT7988), bdinfo shows:

Before:

  DRAM bank   = 0x000000000
  -> start    = 0x0000000040000000
  -> size     = 0x00000000c0000000

After:

  DRAM bank   = 0x000000000
  -> start    = 0x0000000040000000
  -> size     = 0x0000000200000000

Restore the MT7988-specific dram_init_banksize() implementation so bd->bi_dram[0] publishes gd->ram_base and gd->ram_size again.

Version tested
U-Boot 2026.07-rc2-bpi-g6a1580973a11-dirty (May 27 2026 - 14:39:18 +0000)

Fixes bddd6bbef3dc ("arm: mediatek: mt7988: drop dram_init_banksize()")
---
 arch/arm/mach-mediatek/mt7988/init.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/mach-mediatek/mt7988/init.c +9 -0
index 7f4d934bfe9..08eb73d42b1 100644
@@ -26,6 +26,15 @@ int dram_init(void)
 	return 0;
 }
 
+int dram_init_banksize(void)
+{
+	/* Report the full detected DRAM size to later stages. */
+	gd->bd->bi_dram[0].start = gd->ram_base;
+	gd->bd->bi_dram[0].size = gd->ram_size;
+
+	return 0;
+}
+
 void reset_cpu(ulong addr)
 {
 	psci_system_reset();
Signature · 1 line
2.54.0
#1 lore raw
Quoted 9 lines · Rudy Andram

MT7988 detects the full installed DRAM in dram_init(), but after commit bddd6bbef3dc ("arm: mediatek: mt7988: drop dram_init_banksize()") it fell back to the generic dram_init_banksize() implementation.

That generic path populates bd->bi_dram[0].size with get_effective_memsize(), which is capped by CFG_MAX_MEM_MAPPED. On MT7988 this limits the exported DRAM bank to 3 GiB even when 8 GiB is installed.

Can we just remove the #define CFG_MAX_MEM_MAPPED (and the header file that contains it)? Or is it used somewhere else?

#2 lore raw

Not the header file as TARGET_MT7988 sets SYS_CONFIG_NAME="mt7988" in arch/arm/mach-mediatek/Kconfig

In the mt7988 I don't see CFG_MAX_MEM_MAPPED used elsewhere than just in common/memsize.c where it limits get_effective_memsize()

Unsetting/removing CFG_MAX_MEM_MAPPED would take u-boot above 4gb... Some MediaTek ARM64 ports may keep U-Boot below 4 GiB because peripherals such as MMC need DMA buffers below 4 GiB ... so, it may work on my setup but not others. Also, not an expert on u-boot I would suggest for others to comment/review

-----Original Message-----
From: David Lechner <[email protected]>
Sent: 05 June 2026 13:52
To: Rudy Andram <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] arm: mediatek: mt7988: restore full DRAM bank reporting

Quoted 9 lines · Rudy Andram

MT7988 detects the full installed DRAM in dram_init(), but after
commit bddd6bbef3dc ("arm: mediatek: mt7988: drop
dram_init_banksize()") it fell back to the generic dram_init_banksize() implementation.

That generic path populates bd->bi_dram[0].size with get_effective_memsize(), which is capped by CFG_MAX_MEM_MAPPED. On MT7988 this limits the exported DRAM bank to 3 GiB even when 8 GiB is installed.

Can we just remove the #define CFG_MAX_MEM_MAPPED (and the header file that contains it)? Or is it used somewhere else?

#3 lore raw
Quoted 11 lines · On Fri, Jun 5, 2026 at 3:07 PM <[email protected]> wrote:
Quoted 11 lines · Rudy Andram
Quoted 9 lines

MT7988 detects the full installed DRAM in dram_init(), but after
commit bddd6bbef3dc ("arm: mediatek: mt7988: drop
dram_init_banksize()") it fell back to the generic dram_init_banksize() implementation.

That generic path populates bd->bi_dram[0].size with get_effective_memsize(), which is capped by CFG_MAX_MEM_MAPPED. On MT7988 this limits the exported DRAM bank to 3 GiB even when 8 GiB is installed.

Quoted 4 lines
Quoted 2 lines

Can we just remove the #define CFG_MAX_MEM_MAPPED (and the header file that contains it)? Or is it used somewhere else?

Not the header file as TARGET_MT7988 sets SYS_CONFIG_NAME="mt7988" in arch/arm/mach-mediatek/Kconfig

We could drop that config too since the header will be empty.

Quoted 5 lines

In the mt7988 I don't see CFG_MAX_MEM_MAPPED used elsewhere than just in common/memsize.c where it limits get_effective_memsize()

Unsetting/removing CFG_MAX_MEM_MAPPED would take u-boot above 4gb... Some MediaTek ARM64 ports may keep U-Boot below 4 GiB because peripherals such as MMC need DMA buffers below 4 GiB ... so, it may work on my setup but not others. Also, not an expert on u-boot I would suggest for others to comment/review

What I've done on the other MediaTek platforms for now is add this to init.c to take care of the 4GB DMA limit.

phys_size_t get_effective_memsize(void)

{
       /*
        * Limit gd->ram_top not exceeding SZ_4G. Because some peripherals like
        * MMC requires DMA buffer allocated below SZ_4G.
        */
        return min(SZ_4G - gd->ram_base, gd->ram_size);
}

There has been some ongoing discussion of a better way to handle this in general though, the last few weeks. I need to check the mailing list to see if any progress was made since then.

If there isn't something yet, I would still propose to drop CFG_MAX_MEM_MAPPED and add this function so that everything is the same.

#4 lore raw
Quoted 29 lines · David Lechner
Quoted 11 lines · On Fri, Jun 5, 2026 at 3:07 PM <[email protected]> wrote:
Quoted 11 lines · Rudy Andram
Quoted 9 lines

MT7988 detects the full installed DRAM in dram_init(), but after
commit bddd6bbef3dc ("arm: mediatek: mt7988: drop
dram_init_banksize()") it fell back to the generic dram_init_banksize() implementation.

That generic path populates bd->bi_dram[0].size with get_effective_memsize(), which is capped by CFG_MAX_MEM_MAPPED. On MT7988 this limits the exported DRAM bank to 3 GiB even when 8 GiB is installed.

Quoted 4 lines
Quoted 2 lines

Can we just remove the #define CFG_MAX_MEM_MAPPED (and the header file that contains it)? Or is it used somewhere else?

Not the header file as TARGET_MT7988 sets SYS_CONFIG_NAME="mt7988" in arch/arm/mach-mediatek/Kconfig

We could drop that config too since the header will be empty.

Quoted 5 lines

In the mt7988 I don't see CFG_MAX_MEM_MAPPED used elsewhere than just in common/memsize.c where it limits get_effective_memsize()

Unsetting/removing CFG_MAX_MEM_MAPPED would take u-boot above 4gb... Some MediaTek ARM64 ports may keep U-Boot below 4 GiB because peripherals such as MMC need DMA buffers below 4 GiB ... so, it may work on my setup but not others. Also, not an expert on u-boot I would suggest for others to comment/review

What I've done on the other MediaTek platforms for now is add this to init.c to take care of the 4GB DMA limit.

Quoted 8 lines

phys_size_t get_effective_memsize(void)

{
       /*
        * Limit gd->ram_top not exceeding SZ_4G. Because some peripherals like
        * MMC requires DMA buffer allocated below SZ_4G.
        */
        return min(SZ_4G - gd->ram_base, gd->ram_size);
}

Meh... I've just realized that this probably doesn't fix the issue as it does basically the same thing as CFG_MAX_MEM_MAPPED. I will have to come back to this next week when I have more time.

Quoted 8 lines

There has been some ongoing discussion of a better way to handle this in general though, the last few weeks. I need to check the mailing list to see if any progress was made since then.

If there isn't something yet, I would still propose to drop CFG_MAX_MEM_MAPPED and add this function so that everything is the same.

#5 lore raw

Was just about to reply on that... happy to drop this patch and let you work on a solution just thought to report my findings but would suggest in the meantime to revert bddd6bbef3dc ("arm: mediatek: mt7988: drop dram_init_banksize()")

-----Original Message-----
From: David Lechner <[email protected]>
Sent: 05 June 2026 15:48
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] arm: mediatek: mt7988: restore full DRAM bank reporting

Quoted 35 lines · David Lechner
Quoted 12 lines · On Fri, Jun 5, 2026 at 3:07 PM <[email protected]> wrote:
Quoted 12 lines · Rudy Andram
Quoted 10 lines

MT7988 detects the full installed DRAM in dram_init(), but after
commit bddd6bbef3dc ("arm: mediatek: mt7988: drop
dram_init_banksize()") it fell back to the generic dram_init_banksize() implementation.

That generic path populates bd->bi_dram[0].size with get_effective_memsize(), which is capped by CFG_MAX_MEM_MAPPED. On
MT7988 this limits the exported DRAM bank to 3 GiB even when 8 GiB is installed.

Quoted 4 lines
Quoted 2 lines

Can we just remove the #define CFG_MAX_MEM_MAPPED (and the header file that contains it)? Or is it used somewhere else?

Not the header file as TARGET_MT7988 sets SYS_CONFIG_NAME="mt7988" in arch/arm/mach-mediatek/Kconfig

We could drop that config too since the header will be empty.

Quoted 10 lines

In the mt7988 I don't see CFG_MAX_MEM_MAPPED used elsewhere than just in common/memsize.c where it limits get_effective_memsize()

Unsetting/removing CFG_MAX_MEM_MAPPED would take u-boot above 4gb... Some MediaTek ARM64 ports may keep U-Boot below 4 GiB because peripherals such as MMC need DMA buffers below 4 GiB ... so, it may work on my setup but not others. Also, not an expert on u-boot I would suggest for others to comment/review

What I've done on the other MediaTek platforms for now is add this to init.c to take care of the 4GB DMA limit.

Quoted 6 lines
phys_size_t get_effective_memsize(void) {
       /*
        * Limit gd->ram_top not exceeding SZ_4G. Because some peripherals like
        * MMC requires DMA buffer allocated below SZ_4G.
        */
        return min(SZ_4G - gd->ram_base, gd->ram_size); }

Meh... I've just realized that this probably doesn't fix the issue as it does basically the same thing as CFG_MAX_MEM_MAPPED. I will have to come back to this next week when I have more time.

Quoted 8 lines

There has been some ongoing discussion of a better way to handle this in general though, the last few weeks. I need to check the mailing list to see if any progress was made since then.

If there isn't something yet, I would still propose to drop CFG_MAX_MEM_MAPPED and add this function so that everything is the same.

#6 lore raw
Quoted 54 lines · David Lechner
Quoted 35 lines · On Fri, Jun 5, 2026 at 3:07 PM <[email protected]> wrote:
Quoted 12 lines
Quoted 12 lines · Rudy Andram
Quoted 10 lines

MT7988 detects the full installed DRAM in dram_init(), but after
commit bddd6bbef3dc ("arm: mediatek: mt7988: drop
dram_init_banksize()") it fell back to the generic dram_init_banksize() implementation.

That generic path populates bd->bi_dram[0].size with get_effective_memsize(), which is capped by CFG_MAX_MEM_MAPPED. On
MT7988 this limits the exported DRAM bank to 3 GiB even when 8 GiB is installed.

Quoted 4 lines
Quoted 2 lines

Can we just remove the #define CFG_MAX_MEM_MAPPED (and the header file that contains it)? Or is it used somewhere else?

Not the header file as TARGET_MT7988 sets SYS_CONFIG_NAME="mt7988" in arch/arm/mach-mediatek/Kconfig

We could drop that config too since the header will be empty.

Quoted 10 lines

In the mt7988 I don't see CFG_MAX_MEM_MAPPED used elsewhere than just in common/memsize.c where it limits get_effective_memsize()

Unsetting/removing CFG_MAX_MEM_MAPPED would take u-boot above 4gb... Some MediaTek ARM64 ports may keep U-Boot below 4 GiB because peripherals such as MMC need DMA buffers below 4 GiB ... so, it may work on my setup but not others. Also, not an expert on u-boot I would suggest for others to comment/review

What I've done on the other MediaTek platforms for now is add this to init.c to take care of the 4GB DMA limit.

Quoted 6 lines
phys_size_t get_effective_memsize(void) {
       /*
        * Limit gd->ram_top not exceeding SZ_4G. Because some peripherals like
        * MMC requires DMA buffer allocated below SZ_4G.
        */
        return min(SZ_4G - gd->ram_base, gd->ram_size); }

Meh... I've just realized that this probably doesn't fix the issue as it does basically the same thing as CFG_MAX_MEM_MAPPED. I will have to come back to this next week when I have more time.

Quoted 8 lines

There has been some ongoing discussion of a better way to handle this in general though, the last few weeks. I need to check the mailing list to see if any progress was made since then.

If there isn't something yet, I would still propose to drop CFG_MAX_MEM_MAPPED and add this function so that everything is the same.

Quoted 3 lines · On Fri, Jun 5, 2026 at 4:53 PM <[email protected]> wrote:

Was just about to reply on that... happy to drop this patch and let you work on a solution just thought to report my findings but would suggest in the meantime to revert bddd6bbef3dc ("arm: mediatek: mt7988: drop dram_init_banksize()")

I just saw [1] that has a new config option to address the DMA address limit and [2] that renames the config option. [1] has already been applied to master, so perhaps we could still drop CFG_MAX_MEM_MAPPED and use this new option instead? Otherwise, yes, I will consider the revert.

[1]: https://lore.kernel.org/u-boot/[email protected]/
[2]: https://lore.kernel.org/u-boot/[email protected]/

#7 lore raw
Quoted 83 lines · David Lechner
Quoted 73 lines

On Fri, Jun 5, 2026 at 4:30 PM David Lechner <[email protected]

Quoted 49 lines

wrote:

Quoted 17 lines · On Fri, Jun 5, 2026 at 3:07 PM <[email protected]> wrote:
Quoted 17 lines
Quoted 14 lines · Rudy Andram

MT7988 detects the full installed DRAM in dram_init(), but after
commit bddd6bbef3dc ("arm: mediatek: mt7988: drop dram_init_banksize()") it fell back to the generic dram_init_banksize() implementation.

That generic path populates bd->bi_dram[0].size with get_effective_memsize(), which is capped by CFG_MAX_MEM_MAPPED.
On
MT7988 this limits the exported DRAM bank to 3 GiB even when 8
GiB is installed.

Quoted 6 lines
Quoted 3 lines

Can we just remove the #define CFG_MAX_MEM_MAPPED (and the header file that contains it)? Or is it used somewhere else?

Not the header file as TARGET_MT7988 sets
SYS_CONFIG_NAME="mt7988" in arch/arm/mach-mediatek/Kconfig

We could drop that config too since the header will be empty.

Quoted 6 lines

In the mt7988 I don't see CFG_MAX_MEM_MAPPED used elsewhere than
just in common/memsize.c where it limits get_effective_memsize()

Quoted 9 lines

Unsetting/removing CFG_MAX_MEM_MAPPED would take u-boot above 4gb...
Some MediaTek ARM64 ports may keep U-Boot below 4 GiB because peripherals such as MMC need DMA buffers below 4 GiB ... so, it may
work on my setup but not others. Also, not an expert on u- boot I
would suggest for others to comment/review

What I've done on the other MediaTek platforms for now is add this to
init.c to take care of the 4GB DMA limit.

Quoted 7 lines

phys_size_t get_effective_memsize(void) {
/*
* Limit gd->ram_top not exceeding SZ_4G. Because some
peripherals like

        * MMC requires DMA buffer allocated below SZ_4G.
        */
        return min(SZ_4G - gd->ram_base, gd->ram_size); }

Meh... I've just realized that this probably doesn't fix the issue as it does basically the same thing as CFG_MAX_MEM_MAPPED. I will have to come back to this next week when I have more time.

Quoted 11 lines

There has been some ongoing discussion of a better way to handle this
in general though, the last few weeks. I need to check the mailing
list to see if any progress was made since then.

If there isn't something yet, I would still propose to drop CFG_MAX_MEM_MAPPED and add this function so that everything is the
same.

Quoted 5 lines · On Fri, Jun 5, 2026 at 4:53 PM <[email protected]> wrote:

Was just about to reply on that... happy to drop this patch and let you work on a solution just thought to report my findings but would suggest in the meantime to revert
bddd6bbef3dc ("arm: mediatek: mt7988: drop dram_init_banksize()")

Quoted 6 lines

I just saw [1] that has a new config option to address the DMA address
limit and [2] that renames the config option. [1] has already been applied to master, so perhaps we could still drop CFG_MAX_MEM_MAPPED and use this new option instead? Otherwise, yes, I will consider the revert.

The NETSYS DMA of all filogic platform chips can only use DRAM below 4GiB and that's why we added CFG_MAX_MEM_MAPPED to limit the usable memory in U-Boot.

Quoted 7 lines

[1]:
https://lore.kernel.org/u-boot/[email protected]/

[2]:
https://lore.kernel.org/u-boot/[email protected]/