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: 13543346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64111C4828F for ; Fri, 2 Feb 2024 20:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8Whzeg27s9A2f6YyV6xzkboLgCldeDDiTQsEaSQX4C4=; b=pbUjqWEG5w6Dt5 KjYcRodKo3t69Z4cyxS/QlqnTLL+5X6QMG+CvE42u4zRxB9Bu40rOozcsTLVeBSx0D9G/+k6G51OW mxZru5wG8EQ6/nIY2I50UBbN/4zG1PM2iQmC/MadRH6ryky3HipRZdCgZgifkt6p3zyZ7SFh4fXz5 Yb8ijehQGhc2qoEAw+F8TvYX34N9hln6fjHnlqAmcUugS/KzG5dXiibQ5Ekz0ifVg1BOXxUwhS51S tHH95eJ6bLq0oZEu8sfZi6iG4VPu7yyUPMUxKXtds9mQrVIs/L+nFceTd1Pc5q6y8VQVKAZ6saJZF tn2rWFzlLCpu3IE4e8PA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVzhb-0000000DIJI-3zPj; Fri, 02 Feb 2024 19:59:56 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVzgx-0000000DI3E-1twa; Fri, 02 Feb 2024 19:59:18 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A5E646286F; Fri, 2 Feb 2024 19:59:14 +0000 (UTC) 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240202_115915_770560_F6B423A2 X-CRM114-Status: GOOD ( 13.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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