From: Paul Kocialkowski <paulk@sys-base.io>
To: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Cc: u-boot@lists.denx.de, "Tom Rini" <trini@konsulko.com>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"André Przywara" <andre.przywara@arm.com>,
"Cody Eksal" <masterr3c0rd@epochal.quest>
Subject: Re: [PATCH] ARM: fdt: copy TF-A reserved memory into fdt passed to Linux
Date: Sun, 14 Jun 2026 23:06:26 +0200 [thread overview]
Message-ID: <ai8X0ovb5V1zTJR9@collins> (raw)
In-Reply-To: <b0ff98144d34468c133cd62935afc546135b47ec.camel@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6088 bytes --]
Hi Alexander,
Le Sun 14 Jun 26, 20:57, Alexander Sverdlin a écrit :
> Hi Paul,
>
> On Sun, 2026-06-14 at 15:54 +0200, Paul Kocialkowski wrote:
> > > Currently some ARM-based platforms reserve TF-A memory in their own ways:
> > > - Mediatek gets BL31 region via SMC call in ft_system_setup()
> > > - K3 uses CONFIG_K3_ATF_LOAD_ADDR, effectively in ft_system_setup()
> > >
> > > And others like Allwinner simply forget to do it, which results in Linux
> > > overwriting TF-A and crashing.
> >
> > To be fair we've been adding the reserved memory regions statically in
> > the Linux device-trees to mitigate the issue.
>
> once for H616, but it could be the only SoC among ARM64 platforms doing
> this and discouraged for A133:
> https://lore.kernel.org/all/b428d57ba5464f1226daf099877f4c25fa4fc191.camel@gmail.com/
Yes of course it would be better to have a proper solution for this.
I was only mentioning this for context.
> > But another thing we do overwrite current is the cpu idle states, which
> > are added by fdt_add_cpu_idle_states in tf-a. These are only set when the
> > SCP firmware is available (which is checked at run-time) and they are
> > never propagated to the final device-tree. Including the definitions
> > statically would result in cpu idle calls done even without the SCP
> > firmware, which would probably fail (although maybe some states can
> > still be supported).
>
> Do you refer to some unmerged code? Didn't find it in the current TF-A
> sources...
fdt_add_cpu_idle_states is in common/fdt_fixup.c and it is called by the
common allwinner code in plat/allwinner/common/sunxi_prepare_dtb.c based
on the sunxi_psci_is_scpi check (which currently always returns false
for A133).
> > Also note that the usual way to deal with this is to not load any
> > device-tree when booting the kernel, which will implicitly let U-Boot
> > use its current device-tree for Linux (with the modifications brought by
> > tf-a).
>
> ?!
> We definitely want to load the very device tree coming in the FIT image
> and pass it to the kernel from this FIT image. Sometimes people would
> have several DTs to chose from. The thing in U-Boot is basically to
> get U-Boot up and running. OF_UPSTREAM is rather to reduce the traffic
> on the U-Boot mailing list and maintainers effort, but in most of the
> cases we shall expect this DT to be not from the kernel we actually load.
Yes maybe "usual way" was not the best way to put it. "Current workaround"
would maybe have been better wording. Anyway we agree that this is not a
satisfying situation.
> > But of course I agree that it is very desirable to "forward" the
> > device-tree modifications to the kernel device-tree so we are not stuck
> > with whatever device-tree U-Boot was built with.
> >
> > > Unfortunately seems that the things are not much better on TF-A side and
> > > there is no universal way to get the reserved memory region across
> > > platforms. But there is at least a most common way in TF-A, namely
> > > reserving memory range in the FDT, in particular:
> > > - Allwinner ("tf-a@40000000" node)
> > > - ARM FPGA ("tf-a@80000000" node)
> > > - Xilinx ("tf-a" node)
> >
> > RaspberryPi seems to be using "atf@0". Generally speaking the property
> > is a free-form argument to fdt_add_reserved_memory in tf-a and I don't
> > think we can have a common way to match them.
> >
> > Introducing a Kconfig property for the prefix would be a satisfying
> > solution in my opinion.
>
> This was a very conservative patch solving the A133 case, but actually
> I don't see anything wrong with just copying all the reserved areas from
> the U-Boot live tree to the device tree we are going to pass to the
> kernel. Maybe fdtdec_add_reserved_memory() needs to be taught to detect
> overlapping ranges and extend them properly, or maybe yet another function
> has to be created for this purpose, to avoid duplicated reserved-memory
> nodes by all means,
Yes maybe a more generic approach that goes over each reserved memory
node and decides whether it needs to be copied or not would be best.
I would still be satisfied with a Kconfig prefix though.
> but would also solve the PSCI cpuidle issue, as well
> as potentially Raspi case of TF-A side and simplify TI K3 on U-Boot side.
Well the idle-state node is not in reserved-memory, it is part of the
cpus node, but it would be fairly easy to copy it over if no such node
already exists.
> > > While this patch aims to improve the situation for Allwinner platforms,
> > > it's deliberately adding more generic code to pave the potential way of
> > > unification for other platforms.
> > >
> > > Note that fdtdec_add_reserved_memory() has a check for an already existing
> > > carveout with exactly matching boundaries and will not create a duplicate
> > > even if the name doesn't match. It would not however detect an already
> > > existing bigger carveout fully containing the one requested.
> > >
> > > Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> > > ---
> > > The patch has been developed to faciliate Allwinner A133 SoC support, where
> > > most of the work currently happens on TF-A [1] and Linux [2] sides, but
> > > I wanted to send this patch upfront to get the first feedback and because
> > > already supported H616 SoC would already benefit from the patch.
> >
> > Thanks for looking at this!
> >
> > Like I said, I guess the same needs to be done for the cpuidle psci
> > nodes.
>
> See above, maybe there is a way to carefully copy all /reserved-memory nodes?
> Maybe this full copy shall be configurable, but with a proper overlapping-aware
> implementation maybe even a Kconfig option is not required...
It is separate from reserved-memory.
All the best,
Paul
--
Paul Kocialkowski,
Independent contractor - sys-base - https://www.sys-base.io/
Free software developer - https://www.paulk.fr/
Expert in multimedia, graphics and embedded hardware support with Linux.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-06-14 21:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 20:41 [PATCH] ARM: fdt: copy TF-A reserved memory into fdt passed to Linux Alexander Sverdlin
2026-06-14 13:54 ` Paul Kocialkowski
2026-06-14 18:57 ` Alexander Sverdlin
2026-06-14 21:06 ` Paul Kocialkowski [this message]
2026-06-14 22:08 ` Alexander Sverdlin
2026-06-15 10:30 ` Paul Kocialkowski
2026-06-16 14:10 ` Andre Przywara
2026-06-16 14:11 ` Andre Przywara
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=ai8X0ovb5V1zTJR9@collins \
--to=paulk@sys-base.io \
--cc=alexander.sverdlin@gmail.com \
--cc=andre.przywara@arm.com \
--cc=jernej.skrabec@gmail.com \
--cc=masterr3c0rd@epochal.quest \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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.