U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Lalaev <andrey.lalaev@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: guodong@riscstar.com, hfranco@baylibre.com,
	jh80.chung@samsung.com, junhui.liu@pigmoral.tech,
	leo.liang@sifive.com, lukma@denx.de, me@ziyao.cc,
	peng.fan@nxp.com, schwab@suse.de, seashell11234455@gmail.com,
	stefan.roese@mailbox.org, thomas.bonnefille@bootlin.com,
	tim609@andestech.com, trini@konsulko.com, zhuxu_ran@zohomail.com,
	andrey.lalaev@gmail.com
Subject: Re: [PATCH v3 4/7] riscv: milkv_duo: Use upstream devicetree
Date: Thu, 27 Aug 2026 19:35:40 +0200	[thread overview]
Message-ID: <20260827173540.621755-1-andrey.lalaev@gmail.com> (raw)
In-Reply-To: <20260806-milkv-duo-upstream-dts-v3-4-917cf70a2337@zohomail.com>

Hi Zhuxu,

Thank you for your patches.

I am playing with Duo and Duo-256M and faced an interesting thing
regarding reserved-memory on these boards.

It looks like your patchset may cause a memory corruption
of U-Boot or coprocessor FW for Milk-V Duo.

DTS in U-Boot limits RAM to 63.25 MB:

  memory@80000000 {
          device_type = "memory";
          reg = <0x80000000 0x3f40000>;
  };

Because the last 0.75 MB (0xc0000) is reserved for coprocessor.
Kernel uses different approach by declaring all RAM and
relying on `reserved-memory` for coprocessor.

However, this doesn't work for U-Boot because it places its stack
and heap near the top of RAM, therefore region in the top of RAM
is not reserved. So coprocessor FW or U-Boot may be corrupted.

With your patches it also gives an ERROR during reserving (because the region
is already used by U-Boot itself):

  U-Boot 2026.10-rc3-00007-g8e48ce755361 (Aug 27 2026 - 18:53:59 +0200)milkv_duo

  DRAM:  64 MiB
  ERROR: reserving fdt memory region failed (addr=83f40000 size=c0000 flags=2): -17
  Core:  23 devices, 15 uclasses, devicetree: separate
  MMC:   mmc@4310000: 0
  Loading Environment from nowhere... OK
  In:    serial@4140000
  Out:   serial@4140000
  Err:   serial@4140000
  Net:
  Warning: ethernet@4070000 (eth0) using random MAC address - 0a:06:39:79:c7:ed
  eth0: ethernet@4070000

  milkv_duo# bdinfo
  boot_params = 0x0000000000000000
  DRAM bank   = 0x0000000000000000
  -> start    = 0x0000000080000000
  -> size     = 0x0000000004000000
     ...
  relocaddr   = 0x0000000083f73000
  reloc off   = 0x0000000003d73000
     ...
  fdt_blob    = 0x000000008372ec60
  lmb_dump_all:
   memory.count = 0x1
   memory[0]      [0x80000000-0x83ffffff], 0x4000000 bytes, flags: none
   reserved.count = 0x3
   reserved[0]    [0x80000000-0x8005ffff], 0x60000 bytes, flags: no-map
   reserved[1]    [0x8272b000-0x8272dfff], 0x3000 bytes, flags: no-notify, no-overwrite
   reserved[2]    [0x8272ec50-0x83ffffff], 0x18d13b0 bytes, flags: no-overwrite
  devicetree  = separate
     ...
  stack ptr   = 0x000000008372e980
  ram_top ptr = 0x0000000084000000
  malloc base = 0x0000000083733000
  boot hart   = 0x0000000000000000
  firmware fdt= 0x0000000080080000

  milkv_duo# meminfo
  DRAM:  64 MiB

  Region                Base          Size           End           Gap
  --------------------------------------------------------------------
  code              83f73000         8cc30      83fffc30
  malloc            83733000        840000      83f73000             0
  board_info        83732fb0            50      83733000             0
  global_data       83732e40           168      83732fa8             8
  devicetree        8372ec60          41da      83732e3a             6
  stack             8272ec50       1000000      8372ec50            10
  lmb               8272ec50             0      8272ec50             0
  lmb               8272b000          3c50      8272ec50             0
  lmb               80000000       272b000      8272b000             0
  free              80000000             0      80000000             0


Main branch with the original U-Boot DTS:
  U-Boot 2026.10-rc3-00001-g7cbe3e32b6b4 (Aug 27 2026 - 18:30:42 +0200)milkv_duo

  DRAM:  63.3 MiB
  Core:  22 devices, 15 uclasses, devicetree: separate
  MMC:   mmc@4310000: 0
  Loading Environment from nowhere... OK
  In:    serial@4140000
  Out:   serial@4140000
  Err:   serial@4140000
  Net:
  Warning: ethernet@4070000 (eth0) using random MAC address - 82:8a:04:d3:35:d0
  eth0: ethernet@4070000

  milkv_duo# bdinfo
  boot_params = 0x0000000000000000
  DRAM bank   = 0x0000000000000000
  -> start    = 0x0000000080000000
  -> size     = 0x0000000003f40000
     ...
  relocaddr   = 0x0000000083eb3000
  reloc off   = 0x0000000003cb3000
     ...
  fdt_blob    = 0x00000000836705e0
  lmb_dump_all:
   memory.count = 0x1
   memory[0]      [0x80000000-0x83f3ffff], 0x3f40000 bytes, flags: none
   reserved.count = 0x3
   reserved[0]    [0x80000000-0x8005ffff], 0x60000 bytes, flags: no-map
   reserved[1]    [0x8266d000-0x8266ffff], 0x3000 bytes, flags: no-notify, no-overwrite
   reserved[2]    [0x826705d0-0x83f3ffff], 0x18cfa30 bytes, flags: no-overwrite
  devicetree  = separate
     ...
  stack ptr   = 0x0000000083670300
  ram_top ptr = 0x0000000083f40000
  malloc base = 0x0000000083673000
  boot hart   = 0x0000000000000000
  firmware fdt= 0x0000000080080000


I'm not sure of a better solution here other than limiting the RAM node
to exclude the coprocessor region.

Best regards,
Andrei Lalaev

  parent reply	other threads:[~2026-08-27 19:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 12:13 [PATCH v3 0/7] riscv: sophgo: Use upstream devicetrees for CV18xx boards Zhuxu Ran via U-Boot
2026-08-06 12:13 ` [PATCH v3 1/7] clk: sophgo: cv1800b: Add SoC-specific compatible strings Zhuxu Ran via U-Boot
2026-08-06 12:13 ` [PATCH v3 2/7] mmc: cv1800b: Add SG2002 compatible string Zhuxu Ran via U-Boot
2026-08-06 12:13 ` [PATCH v3 3/7] riscv: licheerv_nano: Enable hardware system reset Zhuxu Ran via U-Boot
2026-08-06 14:19   ` Junhui Liu
2026-08-06 12:13 ` [PATCH v3 4/7] riscv: milkv_duo: Use upstream devicetree Zhuxu Ran via U-Boot
2026-08-06 12:45   ` Zhuxu Ran via U-Boot
2026-08-06 14:22   ` Junhui Liu
2026-08-27 17:35   ` Andrei Lalaev [this message]
2026-08-06 12:13 ` [PATCH v3 5/7] riscv: licheerv_nano: " Zhuxu Ran via U-Boot
2026-08-06 12:13 ` [PATCH v3 6/7] riscv: dts: sophgo: Drop local CV18xx devicetrees Zhuxu Ran via U-Boot
2026-08-06 12:13 ` [PATCH v3 7/7] clk: sophgo: cv1800b: Drop legacy compatible string Zhuxu Ran via U-Boot

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=20260827173540.621755-1-andrey.lalaev@gmail.com \
    --to=andrey.lalaev@gmail.com \
    --cc=guodong@riscstar.com \
    --cc=hfranco@baylibre.com \
    --cc=jh80.chung@samsung.com \
    --cc=junhui.liu@pigmoral.tech \
    --cc=leo.liang@sifive.com \
    --cc=lukma@denx.de \
    --cc=me@ziyao.cc \
    --cc=peng.fan@nxp.com \
    --cc=schwab@suse.de \
    --cc=seashell11234455@gmail.com \
    --cc=stefan.roese@mailbox.org \
    --cc=thomas.bonnefille@bootlin.com \
    --cc=tim609@andestech.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=zhuxu_ran@zohomail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox