From patchwork Fri Feb 2 19:59:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 196023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp682183dyc; Fri, 2 Feb 2024 12:28:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjj7z3iJa+QzVvAdklyla/EPliDUJtV1artnpK2wDyyaNcMY0ZbIoCODoYrsCxom02QNSd X-Received: by 2002:a17:902:784a:b0:1d7:67ed:f359 with SMTP id e10-20020a170902784a00b001d767edf359mr6636532pln.4.1706905707379; Fri, 02 Feb 2024 12:28:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706905707; cv=pass; d=google.com; s=arc-20160816; b=sQOPPbEB1N6SUTWDBhnAv1bnPOpL8stCLLXm9bY4KkwlTwENTjq4EvOs0U9kcPwLYv xj6KOfzb1i9L3bsGXo07I6iiq5y4aQuJO7lkSC3kM23np+lLfIKR1yE0b6giKv0zxqG6 blg7WrGNon08kJh4tDhEYpbM2yOWShEL7avHXd17vz3wjYKrYQzU5e7DG9X8E+0TdE1h obVS5sH4SmCMkpYJ5cqUNybiTs8chmAySYO4fb7M6Rg0wgfo1PZA54Efw/PHOmAUsT0g e0y+73O7IIKOsXgg7d2i93u4OzW6HM3hrU/3HzwYIY7lfT+tBrVHxJVIzdNAek81UfxL JNkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lN+ZxRXMPbv6Q4AYpHtIShePhFIex51fo0wm/eE8eLA=; fh=2L9rVPzC3a1sZX+bD7uhYmUL+/HiPe/P2tB866jiyUU=; b=EWLWtt4R3PfIS0QDtFrAbwuNWpaQzXueTfUxyYK3uaW849uraC3n/IFV21m1KP5q1D OOakBocx9TG90XTgThPaWdcBGggbtms63yI8XooEaOhYEpSMqrunpJ+6r17QrIPvGJVm LedVh7SeHpJ8GgRJ7cu7NuUzhnmlvAsiPJIZ1Mv1KqHYxAZG4IdIoghKD/11+7sZsANJ vx3AEIoy/7T1MaqgGSHbBWxOYOpBX6E6nBFzRsdcUZksdFvbVFN7Ed2OM5JWzQrzWjB4 +kKn43Njq/uhE9MJwslmr1RWb7ckQtLf+8GqdCxWH/gTQl0jQgqlTr1bTbNqyoHR1/wc qBvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jS3LgOUj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50513-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50513-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCX3Y8kPJJ/3qA5nc0C6PyPDt1OKXo4zGhKgtEdlIeY4h5UthUuaeH/dm3JrajsZyQRz7cbTmRmtRsDGyQCKMwUDJJs17g== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p2-20020a170902e34200b001d76ec124d9si2111628plc.320.2024.02.02.12.28.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 12:28:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50513-ouuuleilei=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=jS3LgOUj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50513-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50513-ouuuleilei=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 1C2AAB29146 for ; Fri, 2 Feb 2024 20:01:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2946126F2C; Fri, 2 Feb 2024 19:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jS3LgOUj" 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 EDF78839F5; Fri, 2 Feb 2024 19:59:14 +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=1706903955; cv=none; b=Gc7PwZiu3rmjRuZoG9e9CBM0TawHibkCWelNLh1NBmClqPXp5wGmb73xx1K3arZCRolgr1J3zpM7xXd3Adi3oNcEfVXch8p9srfmCcM7RwxRvpkBK6UTRVsmTh4KWIcn40tWFEGtTsdpwuT45OfpG5KZq2f2fuPQhWT2mOocddU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706903955; c=relaxed/simple; bh=7MNLMqC60PFypfikGUyizgcmoz6K4dXFYuG0uw1c2t8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iHcRtcN9gENRAxh2zy02hjmQMvDCuPQa/PqHPMrruPqt1aJKLCl9iELanC2REGNIsDuoDzZbYR4FlJG46+xUrniVHbcYeqy/nZ2tylqFkz+XeYRu/nKJoJvxOxmBDoSCc2Q5vT09Sb3x8BQpWkFt9dFEmnm9hzH/7CFN35hLlfg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jS3LgOUj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF0DDC43399; Fri, 2 Feb 2024 19:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706903954; bh=7MNLMqC60PFypfikGUyizgcmoz6K4dXFYuG0uw1c2t8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jS3LgOUje0AaKkELyp5yo7o5rXijBOH/s1SqcpneNP1bmifPs+GO78P9aJ4YubATC 8sKniHp9zGS1eDFh8lXedC38t2er4z9+fcgEtzZ+Cfa/CiwuSxbYvk9XGQ/faguy/b HzYgwsTF7FeWgJsUPKxKL3ZTRrW5jMd3ZYR+JCgciTsP3A0ktn9GMKrB+0xiJF1mJN 1KEkX2f0kRgxfTpsBQlCJ5USqFnwAUaVfGm3HXryx7e+RTuFgXu/Ff8NqhQVoXyj+L aR6bimdFvj35OMLhKthnfc8oRpd1WjEefi61aEyghyRTtvCCi3tZrb8vgBrqcp8ejY Dyrq2kwDoiwpw== From: Stephen Boyd To: Rob Herring Cc: 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 , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Saurabh Sengar Subject: [PATCH v3 4/7] x86/of: Unconditionally call unflatten_and_copy_device_tree() Date: Fri, 2 Feb 2024 11:59:05 -0800 Message-ID: <20240202195909.3458162-5-sboyd@kernel.org> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog In-Reply-To: <20240202195909.3458162-1-sboyd@kernel.org> References: <20240202195909.3458162-1-sboyd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789820358644578889 X-GMAIL-MSGID: 1789820358644578889 Call this function unconditionally so that we can populate an empty DTB on platforms that don't boot with a firmware provided or builtin DTB. There's no harm in calling unflatten_device_tree() unconditionally here. If there isn't a non-NULL 'initial_boot_params' pointer then unflatten_device_tree() returns early. Cc: Rob Herring Cc: Frank Rowand Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: Cc: "H. Peter Anvin" Cc: Saurabh Sengar Signed-off-by: Stephen Boyd --- arch/x86/kernel/devicetree.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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; - if (!initial_dtb) - return; + if (initial_dtb) { + map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), (u64)128); - map_len = max(PAGE_SIZE - (initial_dtb & ~PAGE_MASK), (u64)128); + dt = early_memremap(initial_dtb, map_len); + size = fdt_totalsize(dt); + if (map_len < size) { + early_memunmap(dt, map_len); + dt = early_memremap(initial_dtb, size); + map_len = size; + } - dt = early_memremap(initial_dtb, map_len); - size = fdt_totalsize(dt); - if (map_len < size) { - early_memunmap(dt, map_len); - dt = early_memremap(initial_dtb, size); - map_len = size; + early_init_dt_verify(dt); } - early_init_dt_verify(dt); unflatten_and_copy_device_tree(); - early_memunmap(dt, map_len); + + if (initial_dtb) + early_memunmap(dt, map_len); } #endif