Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp135290rdb; Mon, 22 Jan 2024 14:48:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7VFpvgyGi+m27rBlL1DQx35zZe3rNleuJxCYjp3+V3xvU7kQV37Wd+H+fIJJSTVT7pZoI X-Received: by 2002:a17:90a:bd83:b0:290:19bc:2138 with SMTP id z3-20020a17090abd8300b0029019bc2138mr2173347pjr.89.1705963731363; Mon, 22 Jan 2024 14:48:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705963731; cv=pass; d=google.com; s=arc-20160816; b=LzxHf+JJ/tNOa4uh0HQtI+04/LthXgBzYbiUC64CHDo3euIu1lQZdNwazC9c/AjLyT WQiQx5dt5/p+UF3c68C6InypQkuisE4Lpd4hfdbDmWrwols856RAUYpQEHDcgn5mj/lx yOqOaYE5agKBBvhx7uTw1pCCli11Ozz/1AG+ADr8SwLWbtbVk0dAC2rkKtAOjienOd93 yeb5EUkogvWrpmHKWXNDDhqmlDUkiP8IELt521yY0QaKPt1HRi1KomRh5Vzw2QhsPZ3K D4vD2tm14Il8sOnSytcyOm2OfQSxkDcczoJRQxYY5tcVWTAwUrYAIgfP0BvyX1jIfCAi Zwhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:date:to:cc:from:subject:references:in-reply-to :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:dkim-signature; bh=qLrCVX24lVOfLJWuQgnlosNiXvjXp4qlzUK74n4Lv+k=; fh=XOw5ivyC3v4MI2BnJJAwQw0Gj6CnSFdfa5sB0hvOfIQ=; b=n2HVXM/q/Qw7oY/7cTv8j8Zx8Tot3H0sLigIADgXMCGlUoR0M+ljRc+uCSUlam8+jo xcd9d1K55IY38PlDiCV6f+ARqu78dpTnn4Wp+6x/IQp8K1Jr6bq4A4oFMcdNTw4OdCQF OrOdCllm8X7Ig0hlStNkatgUvd+zJmzOk8xmwrNzuiZFCcGIb6x0aQClNf90XUVXwT6z 4gvlNo1GHEAejmVkUYjexAnDYJdsAqenxaRNCQvnprsMh/utxj21hSc1PLeKczM+jTUM SnKgRVzQRBrvOKVwaCJNEJYUgHSoZLKgFOFrCTlvFEMOsmCZh55aobKfLUNCvYMVkEjS VpOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SIjjwsOE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-34259-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34259-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i9-20020a17090aee8900b0028de9342df4si8795131pjz.23.2024.01.22.14.48.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 14:48:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34259-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SIjjwsOE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-34259-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34259-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EDA7E289BB3 for ; Mon, 22 Jan 2024 22:48:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 621CD12B67; Mon, 22 Jan 2024 22:48:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SIjjwsOE" 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 7BA2410785; Mon, 22 Jan 2024 22:48:06 +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=1705963686; cv=none; b=GiDwDQe8GqSGZWbdBTmHy4rHPCnx19wJVXo8GpCIgNJrNlFfmZlsU3Yw2kU93dOYRI6YiLSJNdFMGQ7FBrOdIZtqsQfjV3mhtLxYRiiDdmGg9gcyjnEwM6DHaLn6KqGOHgX/bRcDdccB2B6rj666BVlxuneNFLWUqtxtCOuRVIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705963686; c=relaxed/simple; bh=aRO5rI2gBLdjP2Ow80R5wBiyllC8SGlBK8PAr36wVzM=; h=Message-ID:Content-Type:MIME-Version:In-Reply-To:References: Subject:From:Cc:To:Date; b=fXCtJ3tcsMedYrV6ABxVJ8KAfS1zpRGlQN/PK7xvZ+uW6bO7pZfUvuXdrA7OUjJIcZ31d/Zjov2+VxBCDC8yaRvLtWUsVQDn45TebrZF64q9B3WB8ZA/FMmms6itnHHYCBazkI4zs3L+3A5ERGXmvljaBjrr4Qie/+87fyNY1ZQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SIjjwsOE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEA8FC433C7; Mon, 22 Jan 2024 22:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705963686; bh=aRO5rI2gBLdjP2Ow80R5wBiyllC8SGlBK8PAr36wVzM=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=SIjjwsOE6XK+oLQbheaQg4QVbT9JVjy30vmiv3ORQOgq7S6FQv8k4XG1s+wW0x7pV rx0n35Uq4nT+ZfAzyV16EE9P7CUcDxdy4Icwo2SNAdM9eOEySqywBnNzQ7Q2hl9E6p Tgywv2wmPhDPHpupI2h6rmRx1SHz6teEPZdyv/hgNuoZeaFCxSSi3LMVS1B+ibfCbK vKIDGeQ4xW+0SRKkxmJ2tElQ/1pSXE32RtcqnyaHKQaD1NOYmigFdzJeoeZzVPXj3/ b1n491PKznHSazyiLrteCXRpQiM73c5yKwOCGbF6NbuFEgi04cxyKmCb29ES6WsT/2 KFWIaCNP3a57Q== Message-ID: <47062115ff518edf8c4b02e22f3058bc.sboyd@kernel.org> Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20240112200750.4062441-1-sboyd@kernel.org> <20240112200750.4062441-7-sboyd@kernel.org> Subject: Re: [PATCH 6/6] of: Add KUnit test to confirm DTB is loaded From: Stephen Boyd Cc: Rob Herring , 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, Frank Rowand , Brendan Higgins To: David Gow Date: Mon, 22 Jan 2024 14:48:03 -0800 User-Agent: alot/0.10 Quoting David Gow (2024-01-15 21:03:12) > On Sat, 13 Jan 2024 at 04:07, Stephen Boyd wrote: > > > > Add a KUnit test that confirms a DTB has been loaded, i.e. there is a > > root node, and that the of_have_populated_dt() API works properly. > > > > Cc: Rob Herring > > Cc: Frank Rowand > > Cc: David Gow > > Cc: Brendan Higgins > > Signed-off-by: Stephen Boyd > > --- >=20 > I won't pretend to be a devicetree expert, but this looks good to me > from a KUnit point of view, and passes comfortably here. >=20 > checkpatch seems to have one complaint about the kconfig help text. > Personally, I think the brief description is fine. >=20 > Reviewed-by: David Gow >=20 Thanks! I noticed that x86 has some devicetree init code. Did you happen to try on an x86 kvm instance? Or only run on UML? ----8<---- diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index afd09924094e..650752d112a6 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -283,22 +283,24 @@ void __init x86_flattree_get_config(void) u32 size, map_len; void *dt; =20 - if (!initial_dtb) - return; + if (initial_dtb) { + map_len =3D max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), (u64)128); =20 - map_len =3D max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), (u64)128); + dt =3D early_memremap(initial_dtb, map_len); + size =3D fdt_totalsize(dt); + if (map_len < size) { + early_memunmap(dt, map_len); + dt =3D early_memremap(initial_dtb, size); + map_len =3D size; + } =20 - dt =3D early_memremap(initial_dtb, map_len); - size =3D fdt_totalsize(dt); - if (map_len < size) { - early_memunmap(dt, map_len); - dt =3D early_memremap(initial_dtb, size); - map_len =3D size; + early_init_dt_verify(dt); } =20 - early_init_dt_verify(dt); unflatten_and_copy_device_tree(); - early_memunmap(dt, map_len); + + if (initial_dtb) + early_memunmap(dt, map_len); } #endif