Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2393922rdb; Wed, 21 Feb 2024 06:29:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXNtgGdU8UOaHgRlZXGiKZd92EQt1moxIBgDytXXOhlsq3QSAQ9ovGnJ8XqkCZ9bpEJkOEfL0FONP6GworTJ9p3uql2ti2Scz7yiUer9w== X-Google-Smtp-Source: AGHT+IE6N6IdfenTCJhy93LEnNMYQjIPuv9sImv/7mOvHqIQK+LkCs6bRyFEjJFCccPhFDWdWRtF X-Received: by 2002:a17:903:246:b0:1da:190c:3481 with SMTP id j6-20020a170903024600b001da190c3481mr20305546plh.34.1708525743346; Wed, 21 Feb 2024 06:29:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708525743; cv=pass; d=google.com; s=arc-20160816; b=YrhrIQJduI8UDn/hDy3Z0da5uFJfXf5MisDBqn7KhtIhhe9WhhIn2MsNXtsozaPqed 9XVgFWL3WbbzotNn3kum5ZQRhwPzr0S8OtdnzJn5XeNjFBGJNYwxCPokFogZC2xLJj4O D9UDkSaDwfeqpZOmaWNUhQQZCNVVnmw07RlrwKkNIAokou1uIdCWeG2Smdc66iQElo0r el7dh/foGpLH4MXhped9hhRo3MZdwJhl4O7AXdGEIK8w4aqfN4FFRjf9W1B6BiDCZcRu 1yMzyCE9lhvbVrvFV3HMBp+TORrb/az9hKHv5oWK2dePBih/hplAZOyN2Bc8XD7+slFQ Ch1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=4eR7fonfyW/igsEmEwEcQgIwxgmp52h31/GWeR15FLM=; fh=klGRNCNjBMm2jQgcoU5BKI3rIwginxr5tj0+mS7n1Z0=; b=fZdJk/sBxXMUbagTGO7+x39jADdI7QqcSGJ2kbnu4Tm1VP/tY/MS6ayoGydnriqeV6 b20pApC2vILNKvzKViVOfENCgM2J+VMwrZcUO2TqPKJy4liql2mZGGNAhmdEL/Fv9vZX tNt5cYVb27e1v7Jb+3QEJqi1kxyD9GSwm8y1FDpyGjFyWJ7iTALxfkf4eEFXXf4/67T5 UuFdkyn9hFmd3HqLFbd5OoUYX+Ws0omAE700HvTQgzYh9kr5kW/AFc0xD5PcuiaM/DHN uGMn22LG0dbRZSburWkNk4MRnfg+3skrgwsOb5/PEZSlLWGoyZ8fLahPsgz+0808/FVd u1BQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=quTqlShH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-74855-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74855-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w15-20020a1709026f0f00b001db7ef210fasi8153175plk.181.2024.02.21.06.29.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 06:29:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74855-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=quTqlShH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-74855-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74855-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 502ADB246E7 for ; Wed, 21 Feb 2024 14:08:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D961976C99; Wed, 21 Feb 2024 14:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="quTqlShH" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE6BA7E581; Wed, 21 Feb 2024 14:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708524383; cv=none; b=EaJ4BbdR6SWurSyTPYnQr8bwVTw02cs64FW+EQIs+O5Q6AV2U/oQAdw+8Pw+IkbzrU5/+MwEXg4HPmwIHvTSB2HWg6gAwDPjjuLFbY6PU06cA597mfjCZX4zlNBUOTMqInfyxGVb6E5vBt/fiMetD/kyZzLwc/mb4tp0tL7aGPA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708524383; c=relaxed/simple; bh=SpL2kvMci3BCJiem1BIyIcsSR8wgzqXdO4GroPnsjP4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CnejATfNpLeLnU9pyExQtycJBP0eIuFeLTIkoT/hNg0Jsi2PMdwwt0LoETBB+NHzMrm0yBJNEB6Rsl2IWpwDD8EwmbILYYqWjaS8ewC/X7PsTeHegki4n+toGSNSiSSP+UWqn8PnDy3srb1tKzxWmXhIMSQnOWl1uEkK6QGZ6Pc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=quTqlShH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B55D1C43330; Wed, 21 Feb 2024 14:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708524382; bh=SpL2kvMci3BCJiem1BIyIcsSR8wgzqXdO4GroPnsjP4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=quTqlShH4LWCaBTZCyQx62hLzRwZVLko6t4suir8Ot2AOcWbSVtaZdamqaM7w58fp DdbftVoCHsUCAtZrueBfz94C0QKag0ucP4UlPGWV03xB+JkTeRxT7Kq9hgc7NcsZXc jdVQs71Al076uLZgmoSahZ0U4RfJj5YkVku8IV4GGdbBtx+pGpMdhZ8eAyp0Z+GWNI ltQ8vrqQsV3IadYmjrgumJm2YIKXXDGjK7zP6SVgH1PoRvtuNWCUadyNVbSvnC7IKo CWUmyo8zmuq8zIcdMAr4cQxUEbW3qmbUZIszTl3aXJCaXPVHDRD5aTkpo7iJrjg6vx SyGzgnFgXWrrA== Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d23fab7708so25586461fa.0; Wed, 21 Feb 2024 06:06:22 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUgxI1aIhFiISdHKbOPv3LI+Ybb2MLVhOUAESW0tO5Mw3qDNmpV/j/MQLG+Ck5lReXFhjnR7vLp/s63VZ2iYYrpbbyQYYxPGnojwTqUJPfOvKbnvRKyTh+B3c2fYYlCrIObWSI8wLVNwzpqPRzQnHIB55XF50JuDi2wYNL5Phm0c8u6f2BCTMlVCw== X-Gm-Message-State: AOJu0YyGalt5axyKBgbkFRl7BVdfw5b1GzEplwn1bN0pFbqj5pBrChHM /wExKJ1Ar0QoxOG1PBNpqRbpU7h/lyB5Bu87RLernlPxJSpOnM0gYZojrS3gWaKzlX6enMmuHBE 67qgqFr7AC6P0UYpcInceKNBOxQ== X-Received: by 2002:a05:651c:220b:b0:2d2:42d7:7d88 with SMTP id y11-20020a05651c220b00b002d242d77d88mr3092656ljq.22.1708524380920; Wed, 21 Feb 2024 06:06:20 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240217060843.GA16460@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> In-Reply-To: <20240217060843.GA16460@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> From: Rob Herring Date: Wed, 21 Feb 2024 07:06:08 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/7] of: Create of_root if no dtb provided by firmware To: Saurabh Singh Sengar Cc: Frank Rowand , linux-kernel@vger.kernel.org, patches@lists.linux.dev, linux-um@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, devicetree@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 16, 2024 at 11:08=E2=80=AFPM Saurabh Singh Sengar 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 nod= e > > 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 b= y > > 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@kernel.org: Update of_have_populated_dt() to treat this empty dt= b > > as not populated. Drop setup_of() initcall] > > > > Signed-off-by: Frank Rowand > > Link: https://lore.kernel.org/r/20230317053415.2254616-2-frowand.list@g= mail.com > > Cc: Rob Herring > > Signed-off-by: Stephen Boyd > > --- > > @@ -1645,6 +1635,21 @@ static inline bool of_device_is_system_power_con= troller(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 i= sn'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