From patchwork Tue Jan 30 00:45:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 193757 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp920582dyb; Mon, 29 Jan 2024 16:46:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlFNp1AYz3r8hue5E2NHpKk+szpcaljETUE/y7f7URJBZIoXA2/U7786sqWaMf/PwU/QTM X-Received: by 2002:a25:810f:0:b0:dc2:4822:8a32 with SMTP id o15-20020a25810f000000b00dc248228a32mr3258284ybk.71.1706575610712; Mon, 29 Jan 2024 16:46:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706575610; cv=pass; d=google.com; s=arc-20160816; b=cCFMCu96QVP+oWrnsyk5sCWw9541iUqu7XvdcRPi2ydM6Gp+eLIwwKJm2QsAaY393e LaLUHaOqY5tRI35jmqK6YJ5s9RTkfD8bNke6x0yibJ9/ScU4jVKHzhmv0fpEHFTq89jy op1N88WO7oSTP+yHNtLGRwaVx0uyOqz0m9sWdRvlSkrgilMWXtQlyhTaUDgNrVMZ0m44 vsVZNCDnYtDy+/AQ2UiaCIvcLdi/ksSzcN5nYVdLCFIE8b9X9S+ZoC4R1p8FuxMRDCSW 5sXl/yo34WF6agXoZGGS8/coHrKZr7DtH8Fobjwc36ZmNWw5LtPI2VhisXre6NOmkyNn ovEg== 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=vpjgLxIwtNZ6dYdnrby39x6x+nBi40eSONvJZRhoq/8=; fh=sCGGrJtNHD0fFefXPDGWzK/Cz39OQ7Rn/T9JzC1H5zk=; b=sNu6VISIkXGko8LNaemT7nJ7J+CdkUgz78SR6eeY7RPQNd9v2DHLAqrj1izCfocJaa BfC2Uk8O3uVbGAZTv3084/a02l5Wr7aZrHUe10RuEyn90WyHLQquwrM0o1bYXfA9tnGp uyEn9Xq3091KVjxR+cnmc/Onxzr+JAtw+/VZrflbseUZXbxXP1Q0O7cXPCXFx8g3MXto f0OMvsrqfm5W8j7c1a5USZCEYGL7AbyM0z6Q99SjyGre95Znk80NUNCT8a/yZRYdyfG1 HYPvk+nb/evSPmsVwF/RIkGxcgnWULh8TNGx9B8yHG6Ffs8crf6J9qhts91IyCNsXQK0 IxKg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qAgYYRtb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43687-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43687-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i17-20020a05620a405100b00783f5a7d4d4si5095774qko.740.2024.01.29.16.46.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 16:46:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43687-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qAgYYRtb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43687-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43687-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7F5381C20FCF for ; Tue, 30 Jan 2024 00:46:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E28932E40E; Tue, 30 Jan 2024 00:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qAgYYRtb" 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 2391936114; Tue, 30 Jan 2024 00:45:13 +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=1706575513; cv=none; b=iUQR5ux9RJFJ/h8Q8CMxvb8aZzQ4+RMySJetha4oaIBPG8uEpqktxJ9eShkVa+kYZKYFkk+7mhPmlkRiie0Q3rcQVr96Ls3byhyf9l/YV+WklQ7tQTIwU6gHgPiKuHxvxJf75sk48vOyA5VC4dg0gEdBKqM+YPs9kDAGfQ/FtlI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706575513; c=relaxed/simple; bh=RoHfW0J4DhoHi6CIUbHFtKoJEfAKysJC1Fo3xRXVigg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D65D3EVIGKgalq+KrU0RXv9UUKLoNBrqm7IhhRns+xaILorxF9TArSpUSiIab3QiYa658HM39ClVaBtgU0XaoIAB4lMHSKzifk1SYY0v5EOeStaIMIIOjsfmtLDKdBcMnhF+VbJNzqZXsUUrkqlh6d9kkan9QGKJy+bgqUfkqyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qAgYYRtb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 430F2C4166C; Tue, 30 Jan 2024 00:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706575513; bh=RoHfW0J4DhoHi6CIUbHFtKoJEfAKysJC1Fo3xRXVigg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAgYYRtbWJ5viR41vOf0Q8IcMgBCtlOzDpcv/45U9U4fYJYMSujLD6JfR2osY9ATY 4bStYc/TK7bqQzxeqWCsW9bvUgnTTtJJ8FKM0Kme5fVfrFfuPG6NDEZ8G+M9fe+crH 9ByGZOm401zpjqEGrrIHWvkq3Y6jn2TnJD6D7vJtCKzLG5iUGLZNqtGPq5D9/aESld EK4qSV4IXVc7i2yKDT4qA/2Ji5egQXFQIAAjoVgxvqb3Gqfsyw5YbBpJn7iyNgtMCd qBIGYbb+stxyLQrNEHZ+Z413GV36NRwX4SrxjuMtQxugmXLfho8V3HuuGCNZNsblTL vBQ1Ri0YWWNSg== 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 v2 3/7] x86/of: Unconditionally call unflatten_and_copy_device_tree() Date: Mon, 29 Jan 2024 16:45:02 -0800 Message-ID: <20240130004508.1700335-4-sboyd@kernel.org> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog In-Reply-To: <20240130004508.1700335-1-sboyd@kernel.org> References: <20240130004508.1700335-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: 1789474227307703794 X-GMAIL-MSGID: 1789474227307703794 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. 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 Tested-by: Saurabh Sengar --- 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