[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL_Jsq+Feu9NnzTNx=XU5vgHhibGAQXvkuTeWbpu8gJ3rVrzcw@mail.gmail.com>
Date: Wed, 21 Feb 2024 07:06:08 -0700
From: Rob Herring <robh+dt@...nel.org>
To: Saurabh Singh Sengar <ssengar@...ux.microsoft.com>
Cc: Frank Rowand <frowand.list@...il.com>, linux-kernel@...r.kernel.org,
patches@...ts.linux.dev, linux-um@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, kunit-dev@...glegroups.com,
linux-kselftest@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH 2/7] of: Create of_root if no dtb provided by firmware
On Fri, Feb 16, 2024 at 11:08 PM Saurabh Singh Sengar
<ssengar@...ux.microsoft.com> wrote:
>
> On Fri, Feb 16, 2024 at 05:05:51PM -0800, 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, the call to
> > unflatten(_and_copy)?_device_tree() will create an empty root node.
> >
> > We make of_have_populated_dt() return true only if the DTB was loaded by
> > firmware so that existing callers don't change behavior after this
> > patch. The call in the of platform code is removed because it prevents
> > overlays from creating platform devices when the empty root node is
> > used.
> >
> > [sboyd@...nel.org: Update of_have_populated_dt() to treat this empty dtb
> > as not populated. Drop setup_of() initcall]
> >
> > Signed-off-by: Frank Rowand <frowand.list@...il.com>
> > Link: https://lore.kernel.org/r/20230317053415.2254616-2-frowand.list@gmail.com
> > Cc: Rob Herring <robh+dt@...nel.org>
> > Signed-off-by: Stephen Boyd <sboyd@...nel.org>
> > ---
> > @@ -1645,6 +1635,21 @@ static inline bool of_device_is_system_power_controller(const struct device_node
> > return of_property_read_bool(np, "system-power-controller");
> > }
> >
> > +/**
> > + * of_have_populated_dt() - Has DT been populated by bootloader
> > + *
> > + * Return: True if a DTB has been populated by the bootloader and it isn't the
> > + * empty builtin one. False otherwise.
> > + */
> > +static inline bool of_have_populated_dt(void)
> > +{
> > +#ifdef CONFIG_OF
> > + return of_property_present(of_root, "compatible");
>
> This adds the strict check for compatible which makes compatible
> to be mandatory for root nodes. So far, DeviceTree without compatible
> property in root nodes can work. Do we want to make this documented
> somewhere ?
It already is in the DT spec and schemas.
Rob
Powered by blists - more mailing lists