Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1449280rdb; Fri, 16 Feb 2024 17:17:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVtsf8b5txjjjXhYgHSOKl1lEeZiHPIGUWLX6AfuaVnHmxpTQ0YAw4tJJXtp4e3z4cT7JacBmE+4gX29LVJUSOPQcp4at0o9tvbQZecJw== X-Google-Smtp-Source: AGHT+IGTFcMyF/9ncm3zplpx2IEtoqtM51D5WHU5A0p1e0OHOpLNCTb9vUJ1273oC7CnEJPpfICj X-Received: by 2002:aa7:8754:0:b0:6e1:15:ac41 with SMTP id g20-20020aa78754000000b006e10015ac41mr5549395pfo.8.1708132626260; Fri, 16 Feb 2024 17:17:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708132626; cv=pass; d=google.com; s=arc-20160816; b=KeZbRqK+EANCwEZZFqirwe0T3+4z7xVbiWR6PHi//t/ozGrUIYL7NICngRImEioHuJ TpLWnnpar8e4B64QIyIpLl7FRuJ/nTI6etTm0r5Me2ujYjoYT+ho6p5DmET8n3r6lxJ3 x0r7A4EH/Ig+KJw6EqGczsjneEF/JxKTLV0aTG8aWZJwSPNQQIR+UqmSfyzVcm3UaJbN 1mAPRpRw2+FYNODyjAhna1BJ3Zshuy7aNfq01d7LMuzD8y0/qx4xbfxOu/8Hgtvsxwp3 UZ+/feYhNm3MKjoimBlEOsmzyMoICSK0wkHhiOPb0ilA8ZCItd1o+8uCB2DLiHhckr2m LdtQ== 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=YL2CKQtR3hKwH4rwW9T0JOOnxDya8ZhtjXoYp3XFWPw=; b=hJ+EBXgvvx/xVLCTfkBaVTLav9zPT/vTwclKZdNUp7UjHG65zhwEVSZh6KR5hxtBQ0 raKVCFhLPKkkdHzJPXJsBctb4Ky88J8mibk5LDwMFg0OfXtPN+nF6Ax2d9FwvmCaEPQP 2jZ+SMBeWpgaEF91sznMYEVDn8uwrP0e0vc1Hsoxz6E3WVsARpejcZJafWk5tANxS1EA c3YaLH1GsvvsUaZxyZ2P/6GXbUsKG+VMI2Tb1t/WskGilBEiOz3UvZ2AMfb+rSc//y68 RiywEPcwvNO0HE6NXCNoP0ukFx8FA0Ub3q/aMNNW4h4nhw0e018L3fUZXqNqTtYsrIKl lGYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L8xIBjCa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id bo7-20020a056a02038700b005dcc075d5ecsi724000pgb.855.2024.02.16.17.17.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 17:17:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69626-linux.lists.archive=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=L8xIBjCa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69626-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 23B84B233E8 for ; Sat, 17 Feb 2024 01:08:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F65F1F5F0; Sat, 17 Feb 2024 01:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L8xIBjCa" 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 678711E889; Sat, 17 Feb 2024 01:05:59 +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=1708131959; cv=none; b=H5YK78yQfdI1eUIfNWR2Fow0gMX622f4DVKDD2kJzL6oE5cgmvRX+fXy8+46bSxiF+1geLeaRIYGlAF0cpI2i32oxcyiM9Ay+vvKmUGkkz6osXNtqRdgjVdVAuhrmBMRIDiBDdkkwygOfMtqAdM4HYpJ8CYHol5m/6JH/fv5h0Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708131959; c=relaxed/simple; bh=Qt8ricOYsTKcXJqQzKSKsHiM2MHdHGBlaBkQ7xeVb1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K6q51ue4tCkcrRvh14h4jf2lq5DVsG3FlTLLJWklsUHUUeDnFF6WSSbZrj7gC7E3VrVgh087GB/7UbsJjTsH1rxtHBaSmQ+YCc4RUookdTDqvO/dKCIGGjLzlU6iOYtn9QQEYjv9b832buVbAw/JKC8GgKZo+KuuBT1cs8CmtYc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L8xIBjCa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85202C43390; Sat, 17 Feb 2024 01:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708131959; bh=Qt8ricOYsTKcXJqQzKSKsHiM2MHdHGBlaBkQ7xeVb1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8xIBjCa+dP4TX6pBp3oF6oHj02qDWwzqY5w06pu4FHMPm4oM9+4GnK7hf5lo+VW6 2PhfKNRoQPgxXisBnnsAXZ5oj4v4uKt3qaRh2dMgYSzp74qIOTG36ECnrrKJWd6Gxp +ecvRyAQwM3x1JuJba6WXapmpAKCdm8eSRGiU9p8mkN1XxFjmPHIhoWKTiFzdiJQs4 9ZK2Gchk2QqCFqUS7c9+oZoeDjD7SyQ+xcnDPpBDiWeZtpaXTNx0xGVkdlYOzqvP4t ESOs5SV9vbgJoDEkCAm5iVKsa9Qt6LOu34Dp8u1jevaN5YhRuDc5pe+VVlc7noE4gq tJba78OWDOnEQ== 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 v4 1/7] of: Always unflatten in unflatten_and_copy_device_tree() Date: Fri, 16 Feb 2024 17:05:50 -0800 Message-ID: <20240217010557.2381548-2-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 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