Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2524936rdd; Fri, 12 Jan 2024 12:08:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9evJiDlP99ZbSeSiPJEH8dTolssEtpJyNgJ5M/Rja9F9/4ymgHCG3yzAx/n7ViUD9Mr0f X-Received: by 2002:a17:906:b196:b0:a29:eb1:dc48 with SMTP id w22-20020a170906b19600b00a290eb1dc48mr915344ejy.19.1705090117075; Fri, 12 Jan 2024 12:08:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705090117; cv=none; d=google.com; s=arc-20160816; b=gn1hIa95BODCREi1KdRq0mk2L45ggjX4/OFh8lMxzdRslEld0R03RrPo2n6m+PGW+d 08tx4oKhuSpvimelU/0I5x82FzWBWUUHCjKVs05jImaTqHMmLo1hVWynnvsEd0W4BUQC ZFwxEqk2MvXv2Kavdq7+Q6LZPqimAu1h8u9tNJRfmBjH5mEB0pK2pn+nR/EAVJQrAXge 53HlIHVmqJqHTjyXn/oVeUsgH6K0tg/fz9hEUVY8/Wh3J/Dg13sPIwCkXyteGxQlkpFD xoT+Ug87kE5G0OA2Sec+/vuMFkoyY19G66mGgT0a4Dtt4q17jrsa2kXgud/JP178inVa W3lw== ARC-Message-Signature: i=1; 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=4c9mWF8YgLblEXtBZS6u3l9ZtMToZFmO6GDr8hlYfo8=; fh=YL2CKQtR3hKwH4rwW9T0JOOnxDya8ZhtjXoYp3XFWPw=; b=GpF/m45H+yzOPf1cUHPs0PRp92hiM2bbg19t8/4utHSXPpPKKf1YjNwza4PL2J5jLR 7tAoaPe+XbdBjFlB+ZlSLut5Me2oiBGYCrRWwYfYSXv6tHLANcs1D1dkqDTdma4lqn9s RUnDd6NfPwj3N13SL3p4SR1QzzVzcZhjjZdNy2S6T/K5YBiPf8+09h8ARGSWvposBEyw ot2OhNl9ArdD6NMZnPeHJ1fAn4DjUKPQ2sc4wsnxnRioYAUaRltcK5fcMyNrc4HD6Rzb ynkVlY0VEeQjqplsGFqdWJJuYs217b0UB17nimlPCfIL99IwQBxr8GQTCN4NZj4BXLTG yLTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OYIwB3Kd; spf=pass (google.com: domain of linux-kernel+bounces-25016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p18-20020a1709066a9200b00a27eddc5e40si1673251ejr.532.2024.01.12.12.08.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 12:08:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OYIwB3Kd; spf=pass (google.com: domain of linux-kernel+bounces-25016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25016-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C54B21F254E0 for ; Fri, 12 Jan 2024 20:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49E7B171A5; Fri, 12 Jan 2024 20:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OYIwB3Kd" 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 6FDBF168B8; Fri, 12 Jan 2024 20:07:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA086C43394; Fri, 12 Jan 2024 20:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705090074; bh=1E4tLOV0ALY1Bfj9SzYihrCA2jRIId2N3gEBgK6iS+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OYIwB3Kd1lvLubS58Ch++gSwaNSb/vqhoixvSQvAvgqJG87S3gmJYw5VUSlzDs3f5 csFg+vxWUSoiXPtNVuFSumlD4MkFRIRWVQQvyJHKayKu/EFkQOrj++jZToUtobBNP0 +a6lIT2voVAlju/kYLtDzryGwEZQ1405vmmM1W72JkVpv11hygoOYl+3eaBb67Uo8Z fgWZ5l39gqdPbykAVXITXpN2i2VUar5SMcArxxcXvSr7KPRGwOQkaOsf0FcM7oOit/ erSbIKrTVskKhMLrpWa6vgs3lAwIGQT3eFSn4oFjYtkdg8+ls0eBLzSmYOMruWNCnu TwQLUeGiY9tGQ== 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 3/6] of: Always unflatten in unflatten_and_copy_device_tree() Date: Fri, 12 Jan 2024 12:07:46 -0800 Message-ID: <20240112200750.4062441-4-sboyd@kernel.org> X-Mailer: git-send-email 2.43.0.275.g3460e3d667-goog In-Reply-To: <20240112200750.4062441-1-sboyd@kernel.org> References: <20240112200750.4062441-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..b488ad86d456 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) +{ + int size; + void *dt; + + 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 - 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) + copy_device_tree(); - 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