From: Frank Rowand <frowand.list@gmail.com>
To: "Rob Herring" <robh@kernel.org>,
"Clément Léger" <clement.leger@bootlin.com>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Allan Nielsen <allan.nielsen@microchip.com>,
Horatiu Vultur <horatiu.vultur@microchip.com>,
Steen Hegelund <steen.hegelund@microchip.com>,
Thomas Petazzoni <thomas.petazonni@bootlin.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Mark Brown <broonie@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jakub Kicinski <kuba@kernel.org>,
Hans de Goede <hdegoede@redhat.com>, Andrew Lunn <andrew@lunn.ch>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org
Subject: Re: [PATCH 1/3] of: always populate a root node
Date: Mon, 16 May 2022 23:11:03 -0400 [thread overview]
Message-ID: <d356acbe-daff-1c66-6511-aab97a171c82@gmail.com> (raw)
In-Reply-To: <YnEx5/ni1ddIFCj9@robh.at.kernel.org>
On 5/3/22 08:45, Rob Herring wrote:
> On Wed, Apr 27, 2022 at 11:45:00AM +0200, Clément Léger 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. This commit creates an
>> empty root node if not present.
>
> The existing unittest essentially does the same thing for running the
> tests on non-DT systems. It should be modified to use this support
> instead. Maybe that's just removing the unittest code that set of_root.
>
> I expect Frank will have some comments.
My preference would be for unflatten_and_copy_device_tree() to
use a compiled in FDT that only contains a root node, in the
case that no valid device tree is found (in other words,
"if (!initial_boot_params)".
unflatten_and_copy_device_tree() calls unittest_unflatten_overlay_base()
after unflattening the device tree passed into the booting kernel. This
step is needed for a specific portion of the unittests.
I'm still looking at the bigger picture of using overlays for the PCIe
card, so more comments will be coming about that bigger picture.
-Frank
>
>> Co-developed-by: Rob Herring <robh@kernel.org>
>> Signed-off-by: Rob Herring <robh@kernel.org>
>> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
>> ---
>> drivers/of/base.c | 16 ++++++++++++++--
>> 1 file changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/of/base.c b/drivers/of/base.c
>> index e7d92b67cb8a..6b8584c39f73 100644
>> --- a/drivers/of/base.c
>> +++ b/drivers/of/base.c
>> @@ -177,6 +177,19 @@ void __init of_core_init(void)
>> pr_err("failed to register existing nodes\n");
>> return;
>> }
>> +
>> + if (!of_root) {
>> + of_root = kzalloc(sizeof(*of_root), GFP_KERNEL);
>> + if (!of_root) {
>> + mutex_unlock(&of_mutex);
>> + pr_err("failed to create root node\n");
>> + return;
>> + }
>> +
>> + of_root->full_name = "/";
>> + of_node_init(of_root);
>> + }
>> +
>> for_each_of_allnodes(np) {
>> __of_attach_node_sysfs(np);
>> if (np->phandle && !phandle_cache[of_phandle_cache_hash(np->phandle)])
>> @@ -185,8 +198,7 @@ void __init of_core_init(void)
>> mutex_unlock(&of_mutex);
>>
>> /* Symlink in /proc as required by userspace ABI */
>> - if (of_root)
>> - proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base");
>> + proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base");
>> }
>>
>> static struct property *__of_find_property(const struct device_node *np,
>> --
>> 2.34.1
>>
>>
next prev parent reply other threads:[~2022-05-17 3:11 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 9:44 [PATCH 0/3] add dynamic PCI device of_node creation for overlay Clément Léger
2022-04-27 9:45 ` [PATCH 1/3] of: always populate a root node Clément Léger
2022-05-03 13:45 ` Rob Herring
2022-05-03 15:38 ` Clément Léger
2022-05-03 17:22 ` Frank Rowand
2022-05-17 3:11 ` Frank Rowand [this message]
2022-05-17 7:37 ` Clément Léger
2022-05-17 15:03 ` Frank Rowand
2022-05-18 10:03 ` Clément Léger
2022-04-27 9:45 ` [PATCH 2/3] PCI: of: create DT nodes for PCI devices if they do not exists Clément Léger
2022-04-27 17:37 ` kernel test robot
2022-04-27 17:47 ` kernel test robot
2022-05-03 14:12 ` Rob Herring
2022-05-03 16:05 ` Clément Léger
2022-05-03 22:53 ` Bjorn Helgaas
2022-05-04 13:43 ` Clément Léger
2022-05-18 19:22 ` Lizhi Hou
2022-04-27 9:45 ` [PATCH 3/3] of: overlay: add of_overlay_fdt_apply_to_node() Clément Léger
2022-05-06 18:33 ` [PATCH 0/3] add dynamic PCI device of_node creation for overlay Frank Rowand
2022-05-09 12:16 ` Clément Léger
2022-05-09 15:56 ` Frank Rowand
2022-05-09 16:09 ` Clément Léger
2022-05-09 17:00 ` Andy Shevchenko
2022-05-09 20:11 ` Frank Rowand
2022-05-09 20:40 ` Andy Shevchenko
2022-05-10 7:22 ` Christoph Hellwig
2022-05-09 20:07 ` Frank Rowand
2022-05-10 7:20 ` Clément Léger
2022-05-09 18:36 ` Rob Herring
2022-05-09 20:35 ` Frank Rowand
2022-05-10 14:43 ` Rob Herring
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=d356acbe-daff-1c66-6511-aab97a171c82@gmail.com \
--to=frowand.list@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=allan.nielsen@microchip.com \
--cc=andrew@lunn.ch \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=broonie@kernel.org \
--cc=clement.leger@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=hdegoede@redhat.com \
--cc=horatiu.vultur@microchip.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=pantelis.antoniou@konsulko.com \
--cc=robh@kernel.org \
--cc=steen.hegelund@microchip.com \
--cc=thomas.petazonni@bootlin.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).