All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Kocialkowski <paulk@sys-base.io>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Alexander Sverdlin <alexander.sverdlin@gmail.com>,
	u-boot@lists.denx.de, Tom Rini <trini@konsulko.com>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Cody Eksal <masterr3c0rd@epochal.quest>
Subject: Re: [PATCH] ARM: fdt: copy TF-A reserved memory into fdt passed to Linux
Date: Sat, 20 Jun 2026 14:50:35 +0200	[thread overview]
Message-ID: <ajaMm497ytDEu-Nu@collins> (raw)
In-Reply-To: <bd873f94-32af-43f2-be0a-a807fa1ad263@arm.com>

[-- Attachment #1: Type: text/plain, Size: 9109 bytes --]

Hi Andre,

Le Tue 16 Jun 26, 16:10, Andre Przywara a écrit :
> On 6/14/26 20:57, Alexander Sverdlin wrote:
> > ?!
> > 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.
> 
> Sorry, buy I completely and strongly disagree here. This concept of "let me
> load the DT that shipped with the kernel I am going to load" was ill-fated
> from the very beginning, but back 15 years ago it was just the only
> practical way of handling things, because the bootloaders were not ready. I
> understand that this is how embedded people use to do things ever since, but
> I don't think we should continue doing so.
> 
> By definition firmware (the combination of SPL, TF-A, U-Boot, crust in our
> case) is device specific, so the board DT living in firmware is a good
> match. As you said, U-Boot needs the DT anyway, and since the DT describes
> the hardware, it's the same DT the kernel gets. Following this idea, there
> should be one best (golden) DT for a board at any point in time, probably
> the one from the latest kernel tree. And that's the one that goes into the
> firmware image, and that both U-Boot and the kernel use.

I think this is a vast debate that has no clear consensus. Yes there are
arguments in favor of sticking everything with the boot software, very
much like the ACPI approach of x86. But anyone who worked with ACPI also
knows the pain of having to deal with a hardware description that is not
shipped with the kernel. A large part of it is due to proprietary
bootloaders and the impossibility of modification.

With a default approach that encourages shipping the device-tree with the
bootloader, we can be guaranteed that we will see proprietary bootloaders
that will provide broken device-trees that we can never change in the
future and no way to load a different one. On the other hand if we make it
clear that the device-tree is tied to the kernel then we can safely assume
that bootloaders will provide a way to load a revised device-tree, which
has been the case so far.

It may not affect sunxi where we have a fully free and upstream boot
chain, but it will definitely happen at some point on some platforms and
we can imagine the worst case scenario with a device that has a signed
proprietary bootloader that will only load its non-standard
vendor-customized device-tree for its downstream kernel. This will make
it extremely painful to just support an upstream kernel later on.

And one could also argue that U-Boot does not need to have the same
device-tree as Linux (it could be a subset that works for multiple boards
for instance, or just have less units defined -- something I've seen a few
vendors do). It can also have specific bits that are irrelevant to Linux
(and not necessarily specified in common bindings) added to it
(the -u-boot.dtsi files). So I don't think we can really talk about a
single canonical source for the device-tree. This might also be the case
for other systems (maybe FreeBSD) that might need to tweak the device-tree
a bit at times.

In my opinion the device-tree remains related to the software that
consumes it, even though we have a lot of sharing in place. And in fact
the device-trees are still stored separately by each project and there
is no single unified canonical source that would work for everybody.

And to state the obvious, many (if not most) users still expect to load
the device-tree from the kernel and this is not going to change
overnight, so deciding to avoid this use case for new features like
passing tf-a nodes does not seem very reasonable to me.

And honestly it also makes the development process on the device-tree
side rather painful, having to reflash the bootloader everytime a new
change needs to be tested. I find it much more convenient to have
clearly separated device-trees for each project.

So I definitely strongly support the idea of doing something to pass
the tf-a node changes from device-tree to the other.

> For distro boot this is basically essential, and for UEFI based boot there
> is actually no other choice. And I like to treat the classic embedded boot
> methods more as special cases of the more generic ones.

I think both uses cases are working fine with a separate device-tree.

> I see a point of loading a custom DT during development, to play around with
> nodes and properties, but I think there are better ways to handle this:
> - Do the DT changes in the U-Boot tree, and load u-boot-sunxi-with-spl.bin
> via FEL. That's what I typically do.
> - Put your changes in DT overlays, and load and apply them in U-Boot:
>  > fdt copy $fdtcontroladdr $fdt_addr_r
>  > load mmc 0 fdtoverlay_addr_r my_ovl.dtbo
>  > fdt apply $fdtoverlay_addr_r
> - Patch your changes in using U-Boot's fdt command:
>  > fdt copy $fdtcontroladdr $fdt_addr_r
>  > fdt set /path/to/node your-property <42>
> 
> And even if you really want to completely load your custom DT, this is
> probably changed anyway, so you could patch in the things that need
> adjustment, like the reserved memory nodes.

I still find this process rather painful and I'm sure a lot of people
would agree. Completely changing the development workflow of a large
number of people does not feel very reasonable to me either.

And to be fair, we currently support both approaches, so people who
prefer to deal with a single device-tree in u-boot can totally do that.

But I don't think we should force everybody to do this anytime soon.

All the best,

Paul

> Cheers,
> Andre
> 
> > > 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, 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.
> > 
> > > > 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...
> > 
> 

-- 
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 --]

  reply	other threads:[~2026-06-20 12:50 UTC|newest]

Thread overview: 9+ 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
2026-06-14 22:08       ` Alexander Sverdlin
2026-06-15 10:30         ` Paul Kocialkowski
2026-06-16 14:10     ` Andre Przywara
2026-06-20 12:50       ` Paul Kocialkowski [this message]
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=ajaMm497ytDEu-Nu@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.