Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp344864iog; Fri, 24 Jun 2022 05:18:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vg8PG/ANDshy7xLuKTZETo10LJCwPPsWIdE/U++Tn6z6sTbw6snMSWj9lxTNjSVRbT+pDd X-Received: by 2002:a17:902:ef4c:b0:16a:1e2b:e96 with SMTP id e12-20020a170902ef4c00b0016a1e2b0e96mr27341626plx.27.1656073080328; Fri, 24 Jun 2022 05:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656073080; cv=none; d=google.com; s=arc-20160816; b=vGKDfKC4Q6BsJReBuwopHIpptQ/gNcUzYuimqyXf+tsRZF3C32GdsCj5tLRJ/Ah3aN PktACavJflV3elpgpaRw3b5OS9A7UyOmfmQv36rfmUGPR+wrNlN1AFas3OnZ7xcK7G24 Tzk7X7GFMWhSwr9T2rcpvy52i0ElIkC+dg1Z76WCOIFIwZsa6NXnazlk1eQGTkv13RiY rPRKtAo0sZKXjZpxfLavzydbh89C0M9mKXJzz2gGNViF/T6mmIOOqma4U6B00uUW7RXD FdT/ItGcDoO5ymBk6sCkQygCBMKoAb5stEUt5zi8BpuWXqTbxNdVvrw1UCDyCLvJhTkS 39pQ== 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=R8YHbVeqUO9nBhg4jGFDepGndFo7k3NShS8ZLBtA3Ps=; b=qGGNR3zJgGIbqs52jE40CPtAGv08FyfYIA9trSt4D6YNKDsNlbIkr767fsc8XTl6M8 x0cvZkxmyjvBz3XZgIVOTivYqsj1PMGCXybEZcDxLbqY6OIdqYjEMUxQwU6HtOiw2Jtu JqL0BRKh/lQHQu6TYriQGlTavpdx0dEQBAbMv3Hbq5TbIwIOSD2PqLg3e89FYO8Cckme gnP1ELlsalCAUnACLzBEyQlhxTSQFSUNIRxeQpwDdaD6+oXDGsOr1QKXX+ijsztxBaB9 B1nlr7dFydfM0ledNCD6aOrZElx9vU8ymm6p/ZAYiuwyjhTIsXkqvcKIxjlYQmf8bbYH 5jmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="RbjP6/Ye"; 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 t5-20020a634605000000b003c1ff3d56a4si492978pga.386.2022.06.24.05.17.24; Fri, 24 Jun 2022 05:18:00 -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="RbjP6/Ye"; 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 S231737AbiFXMQk (ORCPT + 99 others); Fri, 24 Jun 2022 08:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbiFXMP2 (ORCPT ); Fri, 24 Jun 2022 08:15:28 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AA7B6802F; Fri, 24 Jun 2022 05:14:14 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 1D836E0011; Fri, 24 Jun 2022 12:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1656072853; 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=R8YHbVeqUO9nBhg4jGFDepGndFo7k3NShS8ZLBtA3Ps=; b=RbjP6/YetP5HPhGNompMgF/70JE2/dj7etwQ6IkjkkDRXaK6GFBbNiKtG6lhkth3uyfVq9 6v8XGzs+S0FR7iouuzqsroXcwndPhXesox3rQtF7Kuoqjb5j98oKi3uN58w8y20W7FWeYq WOTpPXICYYDwGaUfmuypRHvwOGkUEHByGLoZcdXN93HIjpxcWcZciuooPmhT3TSikNT6PJ JDllECBzDE7Azp3i7k4VUAGv1tSke/iUbrGS6djjotq5xlgKwByvKr7BrPk0QR/8AlFAAL OFwXRcyqqiv0RXHBJIXLvQDCOCr0pwODIlArlVP7aDD7RzW4ZH8ecXLPmm6ceQ== Date: Fri, 24 Jun 2022 14:13:20 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: frowand.list@gmail.com Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lizhi Hou , Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni Subject: Re: [PATCH 1/2] of: create of_root if no dtb provided Message-ID: <20220624141320.3c473605@fixe.home> In-Reply-To: <20220624034327.2542112-2-frowand.list@gmail.com> References: <20220624034327.2542112-1-frowand.list@gmail.com> <20220624034327.2542112-2-frowand.list@gmail.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; 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 Thu, 23 Jun 2022 22:43:26 -0500, frowand.list@gmail.com a =C3=A9crit : > =20 > +/* > + * __dtb_empty_root_begin[] magically created by cmd_dt_S_dtb in > + * scripts/Makefile.lib > + */ > +extern void *__dtb_empty_root_begin; > + > /* > * of_fdt_limit_memory - limit the number of regions in the /memory node > * @limit: maximum entries > @@ -1332,8 +1338,13 @@ bool __init early_init_dt_scan(void *params) > */ > void __init unflatten_device_tree(void) > { Hi Frank, This function is only defined when CONFIG_OF_EARLY_FLATTREE is enabled. Which means that on platforms that do not select this, the default empty device-tree creation will not be done. This configuration option is selected by the platform and not by the user. On x86, only one config enables this (X86_INTEL_CE) which means this won't work on all the other platforms even if CONFIG_OF is selected. I would need this to work by only selected CONFIG_OF. That's why I decided to add the of_root creation in of_core_init() using a function (of_fdt_unflatten()) that is provided if CONFIG_OF is defined. > - __unflatten_device_tree(initial_boot_params, NULL, &of_root, > + if (!initial_boot_params) { > + initial_boot_params =3D (void *) __dtb_empty_root_begin; > + unflatten_and_copy_device_tree(); > + } else { > + __unflatten_device_tree(initial_boot_params, NULL, &of_root, > early_init_dt_alloc_memory_arch, false); > + } > =20 > /* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */ > of_alias_scan(early_init_dt_alloc_memory_arch); > @@ -1373,6 +1384,12 @@ void __init unflatten_and_copy_device_tree(void) > unflatten_device_tree(); > } > =20 > +void __init setup_of(void) > +{ > + if (!of_root) > + unflatten_device_tree(); > +} > + > #ifdef CONFIG_SYSFS > static ssize_t of_fdt_raw_read(struct file *filp, struct kobject *kobj, > struct bin_attribute *bin_attr, > diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h > index d69ad5bb1eb1..4566876db351 100644 > --- a/include/linux/of_fdt.h > +++ b/include/linux/of_fdt.h > @@ -81,6 +81,7 @@ extern const void *of_flat_dt_match_machine(const void = *default_match, > /* Other Prototypes */ > extern void unflatten_device_tree(void); > extern void unflatten_and_copy_device_tree(void); > +extern void setup_of(void); > extern void early_init_devtree(void *); > extern void early_get_first_memblock_info(void *, phys_addr_t *); > #else /* CONFIG_OF_EARLY_FLATTREE */ > @@ -91,6 +92,7 @@ static inline void early_init_fdt_reserve_self(void) {} > static inline const char *of_flat_dt_get_machine_name(void) { return NUL= L; } > static inline void unflatten_device_tree(void) {} > static inline void unflatten_and_copy_device_tree(void) {} > +static inline void of_setup(void) {} Shouldn't this be setup_of(void) ? --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com