mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-mm@kvack.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Mike Rapoport <rppt@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Saravana Kannan <saravanak@kernel.org>,
	Oreoluwa Babatunde <oreoluwa.babatunde@oss.qualcomm.com>,
	Wandun <chenwandun1@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-riscv <linux-riscv@lists.infradead.org>
Subject: Re: [PATCH v3 2/2] of: reserved_mem: allocate and map the reserved_mem array early
Date: Tue, 3 Nov 2026 20:25:08 +0100	[thread overview]
Message-ID: <b71ac175-fba5-4f61-bbdb-0b98dec9ccee@samsung.com> (raw)
In-Reply-To: <CAMuHMdXcM9yvwLBSi-aYRinG3omhu5aoeNVYynfFQsnDDWR-Hw@mail.gmail.com>

Hi Geert,

On 03.11.2026 19:04, Geert Uytterhoeven wrote:
> On Thu, 15 Oct 2026 at 10:29, Marek Szyprowski <m.szyprowski@samsung.com> wrote:
>> Get rid of the static, limited-size reserved_mem array and replace it
>> with array allocated by memblock_alloc_raw() and accessed directly or
>> through a temporary early_memremap() mapping (depending on the
>> architecture support). Such mapping is needed for some architectures
>> (like ARM64), where linear map is not yet available during early boot
>> scan. The array is allocated from the bottom of RAM to avoid placing it
>> in highmem area, because some architectures (e.g. Xtensa, C-SKY, MIPS32)
>> set the memblock limit to the end of lowmem only after the early scan.
>> The early mapping is not used on PPC64, where the scan is done before
>> early_ioremap_setup(), but the memory allocated by memblock is already
>> accessible at that point.
>>
>> Having a single, writeable array with all reserved regions removes the
>> need to perform two step initialization introduced by commit
>> 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory
>> regions are processed"), so all regions can be processed during the
>> early scan again.
>>
>> The reserved_mem array is allocated only after all static (defined by
>> the 'reg' property) regions are marked as reserved or no-map, so it
>> cannot be placed in any of them. Errors of the early reservations are
>> not recorded per region, only the fact that some of them failed is
>> stored and a message asking to fix the device-tree is printed. The
>> region specific init functions for the static regions are then called
>> in a separate pass, once the array is available. Then all dynamically
>> allocated reserved regions are processed.
>>
>> Suggested-by: Mike Rapoport <rppt@kernel.org>
>> Link: https://lore.kernel.org/all/asc6brs_g0ky0wOM@kernel.org/
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Thanks for your patch, which is now commit aa05faf815836c47 ("of:
> reserved_mem: allocate and map the reserved_mem array early")
> in dt-rh/for-next.
>
> This causes an early crash on BeagleV Starlight Beta:
>
>  [...]
>  earlycon: uart0 MMIO32:0x0000000012440000 (options '115200n8')
>  printk: legacy bootconsole [uart0] enabled
>  printk: debug: skip boot console de-registration.
>  efi: UEFI not found.
> -OF: reserved mem: 0x00000000fb000000..0x00000000fcffffff (32768 KiB)
> map non-reusable framebuffer@fb000000
> -OF: reserved mem: 0x00000000f9000000..0x00000000f9ffffff (16384 KiB)
> map non-reusable framebuffer@f9000000
> -OF: reserved mem: 0x00000000d0000000..0x00000000f7ffffff (655360 KiB)
> map non-reusable framebuffer@d0000000
> -OF: reserved mem: 0x00000000c9000000..0x00000000ccffffff (65536 KiB)
> map non-reusable framebuffer@c9000000
> -OF: reserved mem: 0x00000000fa000000..0x00000000faffffff (16384 KiB)
> nomap non-reusable dma-reserved@fa000000
> -Reserved memory: created DMA memory pool at 0x000000107a000000, size 16384 KiB
> -OF: reserved mem: initialized node linux,dma@107a000000, compatible
> id shared-dma-pool
> -OF: reserved mem: 0x000000107a000000..0x000000107affffff (16384 KiB)
> nomap non-reusable linux,dma@107a000000
> -SBI HSM extension detected
> -[...]
> +Oops - store (or AMO) access fault [#1]
> +Modules linked in:
> +CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted
> 7.4.0-rc1-starlight-00002-gaa05faf81583 #411 PREEMPT
> +Hardware name: BeagleV Starlight Beta (DT)
> +epc : __memset+0x68/0xfe
> + ra : fdt_scan_reserved_mem+0x3a4/0x80a
> +epc : ffffffff8087fd88 ra : ffffffff80a313c8 sp : ffffffff81403c20
> + gp : ffffffff814dc6c0 tp : ffffffff8140cf80 t0 : ffffffc4fea38ff0
> + t1 : 0000000080200000 t2 : ffffffc4fec03008 s0 : ffffffff81403d10
> + s1 : ffffffffffffffff a0 : ffffffc4fea39000 a1 : 0000000000000000
> + a2 : 00000000000000f0 a3 : ffffffc4fea390f0 a4 : 0000000000000008
> + a5 : ffffffff8087fd88 a6 : 00000000000000f0 a7 : 0000000000001000
> + s2 : ffffffc4fec00000 s3 : 00000000000000f0 s4 : 0000000000000000
> + s5 : 0000000000002de0 s6 : 0000000000000006 s7 : fffffffffefefefe
> + s8 : ffffffc4fec02fd4 s9 : ffffffff8148e318 s10: fffffffffefefeff
> + s11: ffffffc4fea39000 t3 : ffffffff8150df00 t4 : ffffffff8150df00
> + t5 : ffffffff8150df00 t6 : ffffffff8150df78 ssp : 0000000000000000
> +status: 0000000200000100 badaddr: ffffffc4fea39000 cause: 0000000000000007
> +[<ffffffff8087fd88>] __memset+0x68/0xfe
> +[<ffffffff80a2f63a>] early_init_fdt_scan_reserved_mem+0xa4/0x110
> +[<ffffffff80a06c8e>] paging_init+0x17c/0x46a
> +[<ffffffff80a046dc>] setup_arch+0xdc/0x584
> +[<ffffffff80a009b8>] start_kernel+0x98/0x940
> +Code: 0000 8793 00e7 8305 97ba 8782 b023 00b2 b423 00b2 (b823) 00b2
> +---[ end trace 0000000000000000 ]---
> +Kernel panic - not syncing: Fatal exception in interrupt
> +---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
>
> Reverting the commit fixes the issue.

Does moving early_init_fdt_scan_reserved_mem() to the end of setup_bootmem()
in arch/riscv/mm/init.c change anything?

Could You provide a full boot log from the working kernel and /proc/iomem dump?


Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


  reply	other threads:[~2026-11-03 19:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20261015082333eucas1p28bad74cde14ee0afac2eea11bbe6696c@eucas1p2.samsung.com>
2026-10-15  8:23 ` [PATCH v3 0/2] of: reserved_mem: use dynamically allocated reserved_mem array Marek Szyprowski
     [not found]   ` <CGME20261015082333eucas1p2ab2904e28a33bf2c74f5c7c9befeedb8@eucas1p2.samsung.com>
2026-10-15  8:23     ` [PATCH v3 1/2] of: reserved_mem: group allocation helpers together Marek Szyprowski
     [not found]   ` <CGME20261015082334eucas1p2a3bbf3650f279abbd39d05d63e35aba6@eucas1p2.samsung.com>
2026-10-15  8:23     ` [PATCH v3 2/2] of: reserved_mem: allocate and map the reserved_mem array early Marek Szyprowski
2026-11-03 18:04       ` Geert Uytterhoeven
2026-11-03 19:25         ` Marek Szyprowski [this message]
2026-10-21 13:41   ` [PATCH v3 0/2] of: reserved_mem: use dynamically allocated reserved_mem array Rob Herring
2026-10-22  9:59     ` Marek Szyprowski
2026-10-23  1:46       ` Wandun
2026-10-23  9:11         ` Marek Szyprowski

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=b71ac175-fba5-4f61-bbdb-0b98dec9ccee@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenwandun1@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=oreoluwa.babatunde@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=rppt@kernel.org \
    --cc=saravanak@kernel.org \
    /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

all inboxes | Powered by JetHome®