Re: [PATCH v3 1/2] of: create of_root if no dtb provided

From
Frank Rowand <hidden>
Date
2023-03-01 02:06:04
Also in
lkml
Reply to
Rob Herring, 2023-02-27
On 2/27/23 11:17, Rob Herring wrote:
On Thu, Feb 23, 2023 at 3:34 PM Frank Rowand [off-list ref] wrote:
quoted
When enabling CONFIG_OF on a platform where of_root is not populated by
firmware, we end up without a root node. In order to apply overlays and
create subnodes of the root node, we need one. Create this root node
by unflattening an empty builtin dtb.

If firmware provides a flattened device tree (FDT) then the FDT is
unflattened via setup_arch().  Otherwise, setup_of() which is called
immediately after setup_arch(), and will create the default root node
if it does not exist.
Why do we need a hook after setup_arch() rather than an initcall?

Rob
It might work as an initcall today.  Maybe not in the future as other
initcalls are added.

But my main stream of thinking is that before the patch "we know" that
the device tree data structure exists when setup_arch() returns.
Adding setup_of() immediately after setup_arch() retains that
guarantee, but one line later in start_kernel().

I could have instead put the call to setup_of() into each architectures'
setup_arch(), but that would just be duplicating the same code for each
architecture, which did not seem like a good choice.

-Frank
Thread (9 messages) 9 messages, 4 authors, last reply 2023-03-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help