From patchwork Sat Feb 17 01:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 202548 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp92126dyc; Fri, 16 Feb 2024 17:23:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWYsJgjqHcyJUEPBu//q/3iKhbvMcBSnPomPxohU58DmhnNUXL2uj607OlylagQjcOKr7V6f7uKcuR7AZ7toCBFcZg+OA== X-Google-Smtp-Source: AGHT+IFJXgmPQP8D07Cm/zs5MBRbl2XAgaD51HrCl6T9xAQHmphnRFXaDytSc7syrzxPM1+YwG+5 X-Received: by 2002:a17:902:c085:b0:1d9:657c:2769 with SMTP id j5-20020a170902c08500b001d9657c2769mr6356153pld.19.1708133010767; Fri, 16 Feb 2024 17:23:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708133010; cv=pass; d=google.com; s=arc-20160816; b=yEZTb+tn15Zq5BLzkSl8jnr1wvpsgpIHJdxA+spJIkUy6fBTfuA9lZ2tEXnhjwKH6n iQWiSOChGaVbo/5XHsWViaK1oh1UaAn3SSyUKOTM0ZtljvbVr99TErbBBOpHgx2gMcx6 be/bAv3p+kFkkRNpAHvJmf8TNxVFokFqM05XRJOhvdslZnBRChcI6Iq8k032Pa4XB/+Z Raf/4AQOARKVlE/+LEHRgxk5fNJ4gYCVT9iT1avuwqEwp1PahgoqTA1Uoo5rnRIRD3OO 7SKUqupQby3TR3c56PQoxhGlJqk77bCFhixiocBtH8J9G99n0zdC04WNvGpsAmiDPdz9 VXWg== 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=YWxi4pmLeontrS8EkVTzHt4J8Of/kxPfQuPQpS8fPKQ=; fh=sCGGrJtNHD0fFefXPDGWzK/Cz39OQ7Rn/T9JzC1H5zk=; b=0GKFOaFLBnCAIyn79xvSz0vKbwYnf4J+dHQYct3Qvul/IHLBu73b6ffpeUKQMmR0/j gPKRtfU9LlvhQd9aqnvprrLUS4iOzJ+14ZqcibF6OGT42UPj47sSRJAOL6GXjh8AGpbW zr2kRDJGE/BZlVLCiWjzwPM321P3mVkgwvUUEAXS7Lei7sKrz86kKkj4094zQVSi4cO8 cB1KelMo4s41gACkB/jWih6mu0f1N94oKRHU0C7lRHoxFVV9kOllgPBNguGeM1z9Gjhl +nkIbC9QSqnybi9k7OEdfH0QxEEaXjwQHJHzX0api6gfYLjgY8sIrFyZdF5pH/C7CN6r T6Vw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OLeOAuh9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69629-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69629-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i16-20020a170902cf1000b001db4210203fsi710807plg.122.2024.02.16.17.23.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 17:23:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69629-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=OLeOAuh9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69629-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69629-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 B1FFAB22550 for ; Sat, 17 Feb 2024 01:10:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E7AD224CA; Sat, 17 Feb 2024 01:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OLeOAuh9" 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 BBE0C2032C; Sat, 17 Feb 2024 01:06:01 +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=1708131961; cv=none; b=mvrC1NehippbRrF7VFHsY/a/fyhWPCC3SZUo6SdshYr0rBqMYrF2bwHL7iLFWoETjZRnZkIbegDD1QMdIv38O17udZRhI4sDVR7uky43FdAtGAcMuWuZ9nLfwgo3tK91o7GQLxyBF/aRS8KPB4pT2omKshqsa02aI1K4RlA8wCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708131961; c=relaxed/simple; bh=cR6lBuTsNe2p1GQlv5k9m41XDe+JPSu/qcoX4YFfeKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QIef8BijBt+j81klcq42PA4IhK1boAlOiAXb1kwVFvtnORPO9KCj01mMVHFSUGvnaS6xJKfW2gq0MX7hQeMgfp3zCtz18NzQoTFqvQtPV07yLr3YxbfV8pQyCFie1QNRLK/afpK/IgFVSbYpc0Wt/L5b+PghWUOw8GnGk6ibWCw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OLeOAuh9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F5C5C433C7; Sat, 17 Feb 2024 01:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708131961; bh=cR6lBuTsNe2p1GQlv5k9m41XDe+JPSu/qcoX4YFfeKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OLeOAuh9JcnWjMkP28AX6Wosr7CaT8IJDTe++OAPlHmV45oUdqI2baYVKvuONQLRM REHahxweGolZgJoq4cIcJM609d280RUEZ6QOylnu7b84K0JrmRW4grtFnLrDKr7DHm od2AR/PNbdj2WdEHoiw6v8AipspdwQHYwREzjurg2ModO/udqB4MN4PvqStRsntvhO wln6USBTGOZIWd5lhk/LBgFW7h/6nkbg9ak53wpgvk1GtkpGxA34gf8jlkqNrtppj+ JGioc/KE+Kekqcl6YX6Z2urk1MRDsmJJzTSr56lOvTWTsRk1loY1rrmLedb/9jx56h wnp6VBWh8/MAQ== 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 v4 4/7] x86/of: Unconditionally call unflatten_and_copy_device_tree() Date: Fri, 16 Feb 2024 17:05:53 -0800 Message-ID: <20240217010557.2381548-5-sboyd@kernel.org> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240217010557.2381548-1-sboyd@kernel.org> References: <20240217010557.2381548-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: 1791107280029222501 X-GMAIL-MSGID: 1791107280029222501 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" Tested-by: 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