Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp776299iob; Tue, 3 May 2022 09:24:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8Nz81K9gPurS9/hjaNVvwE44Yp8EBUDG4KXjYk4jfNavzozeC8LkJgD0dW8lrpx97w0wc X-Received: by 2002:a17:902:d2c8:b0:15e:a266:6487 with SMTP id n8-20020a170902d2c800b0015ea2666487mr10912194plc.8.1651595049305; Tue, 03 May 2022 09:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651595049; cv=none; d=google.com; s=arc-20160816; b=TOsUZc0a97OOOre+eFpmap/CtlH7V7+dTwKcF+8lYwLJNf+P7rHeyMPx86N2Upo9gJ ZTmIDnf7cdE34qLCeZC/3hC+avJgrh2FomphJxLobtL5JpTRRgUGipnu9eB5rkbuHg/6 BdB7y9HL/7NqhLm0+d4yhhLheTQ9T7fvR724njDyiBO1jT28vMX9H3wg08Nw/Z4vJ/bN 7+tEXhmJuaGhfC1ioxMPbO3wbacC51b3EKdW5Gnx97kjOk/CxzzgWmqpA9xQ8H6Xpu7M FFgWX5yED9QaK6QUH2gag+E8nQqYWyOUaWRBevGUBDdIW11txGtvYwaHxANC5tEMntI6 0eeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=Xz1Onj7oTzb7D6aAvbG4r11OnN521cFiAkj6GER4WiE=; b=KD0BfzaC0+9n8cmWu1wAjlaXACwQZYWwVn+YEoswpAr8X6ULHQ6IKzPVkRpumY0Z9A tfM1deAd5uqrzn2LLME8gErgpEi7G5LKSJuvIgKX/NNRrjLCtY8oXlls6w9emgfd3SRr FMI1kW5KfIynwm/6hh9JjieB8FaBldSXxX49kohb1oMtRp8G2ALAqS3zgZIuClIqwyid 4amW9OTlmxE/dt8dB8NR2uxsi2iC2HPRd91ta1Y9/xhm1N4G0f69mY/BP8+nZjJxDNsB 255uw1EsnugAEidMIcdGFNThtuoUTQEZkH/Gtm4na2qhY/SyuIWid0TSirM05TBn1FVi voCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LxgLUU7r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170902f79100b001584875c092si340841pln.75.2022.05.03.09.23.51; Tue, 03 May 2022 09:24:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LxgLUU7r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236360AbiECPn2 (ORCPT + 99 others); Tue, 3 May 2022 11:43:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233778AbiECPnX (ORCPT ); Tue, 3 May 2022 11:43:23 -0400 X-Greylist: delayed 88183 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 03 May 2022 08:39:49 PDT Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E795C30F6B; Tue, 3 May 2022 08:39:49 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 1D34F240006; Tue, 3 May 2022 15:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1651592387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xz1Onj7oTzb7D6aAvbG4r11OnN521cFiAkj6GER4WiE=; b=LxgLUU7r+6dNTNlLCt/mvNOBNzYV0wZpnTA5aEZnxmn43lh7u2e2fy0yGqmGJSTwCK0kGU TBszHcN6rHiu9l9LY2Loq7WXRWU50xR6XgdXPtZlZV22kJajQFKE0rXSHoAHnxUUrAt/Sx AMNemus8fnSqLQfRaZCtT4ZahNNyIaDq3944Pyhx0Ps9/4vgg/w8IXbWkZJsAqt2dt+Bb+ bEJnv41x2928cW9SrKenfh32Yvw32Wy66wQY/31QIBJiBGUdlEirVXcXePGvleupp0tcN5 uOcWXCbNQc50Kjh5yy3X1/8MkeIWNT7Nwukih1ocMlyqSBTJe6IO4w1CWr0uww== Date: Tue, 3 May 2022 17:38:29 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Rob Herring Cc: Frank Rowand , Pantelis Antoniou , Bjorn Helgaas , Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Alexandre Belloni , Mark Brown , Andy Shevchenko , Jakub Kicinski , Hans de Goede , Andrew Lunn , 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 Message-ID: <20220503173829.7ef7418d@fixe.home> In-Reply-To: References: <20220427094502.456111-1-clement.leger@bootlin.com> <20220427094502.456111-2-clement.leger@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le Tue, 3 May 2022 08:45:11 -0500, Rob Herring a =C3=A9crit : > On Wed, Apr 27, 2022 at 11:45:00AM +0200, Cl=C3=A9ment L=C3=A9ger 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. =20 >=20 > The existing unittest essentially does the same thing for running the=20 > tests on non-DT systems. It should be modified to use this support=20 > instead. Maybe that's just removing the unittest code that set of_root. Acked, I'll try the unit test on my system. >=20 > I expect Frank will have some comments. >=20 > > Co-developed-by: Rob Herring > > Signed-off-by: Rob Herring > > Signed-off-by: Cl=C3=A9ment L=C3=A9ger > > --- > > drivers/of/base.c | 16 ++++++++++++++-- > > 1 file changed, 14 insertions(+), 2 deletions(-) > >=20 > > 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 =3D 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 =3D "/"; > > + 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); > > =20 > > /* 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"); > > } > > =20 > > static struct property *__of_find_property(const struct device_node *n= p, > > --=20 > > 2.34.1 > >=20 > > =20 --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com