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

From: Rob Herring
Date: Fri Mar 31 2023 - 14:04:44 EST


On Fri, Mar 17, 2023 at 12:34:14AM -0500, Frank Rowand wrote:
> 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(), will create the default root node
> if it does not exist.

I thought of another way to handle this. Every arch except IIRC sparc,
s390, and ia64 calls unflatten(_and_copy)?_device_tree already. At
least any arch anyone is going to care about for this stuff does. It's
just conditional in some cases. So why not make the existing calls
unconditional?

Either way, I think that of_have_populated_dt() calls will need to be
checked whether this change.

Rob