Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1052487rdb; Fri, 2 Feb 2024 11:59:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFL+upqUOwvwQwCO81q/7XvJpyn3xotIoXphRmlLSi8DO9GOBp7P42SDL528WhGDD01ABeS X-Received: by 2002:a05:6214:1d27:b0:68c:43de:1915 with SMTP id f7-20020a0562141d2700b0068c43de1915mr3762596qvd.21.1706903974007; Fri, 02 Feb 2024 11:59:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706903973; cv=pass; d=google.com; s=arc-20160816; b=Y2qf43Rv1aj4ClZzTSAn8/puxv5puMq28Dvqd/oHeFipGH+QnOyHTqSYjwXfh3xt8L S4LfLZuGlCrUHrj1g+/wl8BA6u6XI65WPFzK0B/lbxs7Al8r7GIQg2veA1e5hTNYzX1M 6eDQMlQBaMRIHVWi1SPwzKI/ByeOlnoPymHvjHwCbeCBOe5njHTTubRAVXA9YpAlwkeT bI+R9bi+O7AJt0LiBWELkSySSE2yhXaBbDim5JCiimHrzbYI2zUztWOD5bH6SHURtKDY ucUZ1La9zVBd2CYcoix7Y9jo8LsGMY1nFnB/KyxKhd8SPEg7z/0G+GZ+gmKr0zSntIcu UBaw== 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=txjo7axD3IOMj2sG8qZ7bqcXfpbTutPS/3Sn6RhFLnE=; fh=nfE0Pi79A02WvSbYQ/Az64b4tEGywmWp5IV1HW7UeGc=; b=EuvxG6MYhF9NpL3vwHzrkWzjyZPipV/YGwieTdm/7Ibz+p5MnEzvGqsJ8Bq8ilqEDr pwc0ToaGCpUGhdwgTJ2sKlucTgZPR6GDlHlHLT20bTcQFoIiwGxTXKUhUGOvfQkWqhlO U8p0uW3ptmzKGdVOzU+FbHwGh9L2ZhOBcVp5eu32LJ9v9QLs8B79DvUliPL7u/W9CeYp v+xu4q9u3HPOvqYShidwY9TtOYcKE+tk+GgT4Iv1VpJ9pQ6Ql13LetrzdjsQidhuRMB5 mXgq9Iu6dm7QaPOckYh3/bj4d1S1OpAlU+t5PCVQLYhCjeMSwoyd3Dhxvc/UuforUWjc 3iTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lolArgXV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXYX0JSSZXkU31iRxTOm45YWQmo4y4sbH5qcTKZUjuuHM+7ARO+3NUfn8EjR/oqNxYyJWOYsi+YVS8WM/EgOXueA5Zakw8QihhJ6lWx3A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id mx9-20020a0562142e0900b0068c4477b3a5si2683753qvb.15.2024.02.02.11.59.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 11:59:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lolArgXV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-50510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50510-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C1DE71C249E3 for ; Fri, 2 Feb 2024 19:59:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F53A81738; Fri, 2 Feb 2024 19:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lolArgXV" 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 AFDA415E5D1; Fri, 2 Feb 2024 19:59:12 +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=1706903952; cv=none; b=pYwMq01Q80au2/KoeutfK0LycXDn+c0TiZ3rY/P88CI3IYa+bnWN9C4zXqa9Zjmr3K0J8ldEPPfSbMWoXaz3TAwSFwnQ/y+w7hKMrN/Wha9vFUT0xAQAyzjY7q6CkhYSewPyhxkZhIKyS1NwL5JwXtkg8VHEPcQmU5Z6ogvx1HQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706903952; c=relaxed/simple; bh=Qt8ricOYsTKcXJqQzKSKsHiM2MHdHGBlaBkQ7xeVb1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XFOrt6ZLOtlz7b9cZr4PxSmRlWLuusczuTSLAdkEh/bjKl4QTFmQH3G42rUq/sJWg/lH267HByjLqptev8tf2q58mmbZVEyPdOYqORfN2Ls+AjowZNcaeibRHaD4kcls7DvEEGi+J/Qy09qWYEyMM1uXdAbLutWgxUO3QHE2dRY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lolArgXV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5BC6C433A6; Fri, 2 Feb 2024 19:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706903952; bh=Qt8ricOYsTKcXJqQzKSKsHiM2MHdHGBlaBkQ7xeVb1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lolArgXVyTaONkcJ5g+Q0I74VOq82JrEMP+bi1sJfx15lGiKzZRLSxhR7HPZQO9o+ Vk7IRVNvNklfw0NMszumwTcFm9jgJBwhoUs6umQ55RBhjMrFu52cy4n/gJ4BbpE2HX lIg2PWCeBkrRkSrM123IFh1gZLL78hdg113f6j5P9rjYmbPOyEBq9F+7wne+BJLnAP 8ntDegcw+g3r3b7BJaeyLoqw7DvIKZXgU+luSg2rfc6tqGJZNT2rjuMRYmox0btctH Bx9iZO9QAEpH+NXjlocxZnEWB2f7RqplqHjGB7yVg/0KTomqx4izsjaFh3vB/qkVbN 8btpvM4BTB31w== 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 Subject: [PATCH v3 1/7] of: Always unflatten in unflatten_and_copy_device_tree() Date: Fri, 2 Feb 2024 11:59:02 -0800 Message-ID: <20240202195909.3458162-2-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 Content-Transfer-Encoding: 8bit We want to populate an empty DT whenever CONFIG_OF is enabled so that overlays can be applied and the DT unit tests can be run. Make unflatten_and_copy_device_tree() stop printing a warning if the 'initial_boot_params' pointer is NULL. Instead, simply copy the dtb if there is one and then unflatten it. If there isn't a DT to copy, then the call to unflatten_device_tree() is largely a no-op, so nothing really changes here. Cc: Rob Herring Cc: Frank Rowand Signed-off-by: Stephen Boyd --- drivers/of/fdt.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index bf502ba8da95..dfeba8b8ce94 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1318,6 +1318,21 @@ bool __init early_init_dt_scan(void *params) return true; } +static void *__init copy_device_tree(void *fdt) +{ + int size; + void *dt; + + size = fdt_totalsize(fdt); + dt = early_init_dt_alloc_memory_arch(size, + roundup_pow_of_two(FDT_V17_SIZE)); + + if (dt) + memcpy(dt, fdt, size); + + return dt; +} + /** * unflatten_device_tree - create tree of device_nodes from flat blob * @@ -1350,22 +1365,9 @@ void __init unflatten_device_tree(void) */ void __init unflatten_and_copy_device_tree(void) { - int size; - void *dt; + if (initial_boot_params) + initial_boot_params = copy_device_tree(initial_boot_params); - if (!initial_boot_params) { - pr_warn("No valid device tree found, continuing without\n"); - return; - } - - size = fdt_totalsize(initial_boot_params); - dt = early_init_dt_alloc_memory_arch(size, - roundup_pow_of_two(FDT_V17_SIZE)); - - if (dt) { - memcpy(dt, initial_boot_params, size); - initial_boot_params = dt; - } unflatten_device_tree(); } -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git