Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68A9AC636D4 for ; Mon, 13 Feb 2023 15:58:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D31FD8579E; Mon, 13 Feb 2023 16:58:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Q2W8Xixf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7815F8567B; Mon, 13 Feb 2023 16:57:44 +0100 (CET) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9F477857AA for ; Mon, 13 Feb 2023 16:57:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x136.google.com with SMTP id s9so4220821ilt.1 for ; Mon, 13 Feb 2023 07:57:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CbEYefgTsMLXkVn0sQc8xYFxmyDz83N1Nt/ftAXJpYw=; b=Q2W8XixfJ5Bua0GlASOFfEAkTMd90N2jv31+1uWzK7EsZ/6lf42ATXs7PhiFmcWZqz Q2i9o8szqUuh5pPXWcZfwdybOnps7/U9huA9+MoNyJuNgZ3w+449/JzqGsJY2TUmM91F 3SL2XW/SM8yX8OYPG2uaH2Lntuk4CBRudfA0A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CbEYefgTsMLXkVn0sQc8xYFxmyDz83N1Nt/ftAXJpYw=; b=Mxyq/fg6q7UBWeDI6hNIMrloce/RqKDYfyVIi59ua+7iIWsb2E8hhIhQiX88Uq2x4J gTgEZeQfermNcrCJm/DzSKoO4ctznoV10oyIZePhZ9tVmyj2btXZjlTcd7fevDW3dPAM l4Y8xO8M898fCHjVUA6JqREsUG4CPQDqUFEnQnM/PpsMxbnDPBwZkKRSyAtKO0K7Umze UMmg6yW1SDNoAfhYSCPx+BZPVz7Lwrj271MUQG45BCj+iPhJkOv5JLSczKScDmRn3gJw xdD94dp/vSnvZvdh91XJaWbZXRsCuCRKtcqYJny2b8TNnd24eQtLPe0QRzG1nKSOKjpX q8VA== X-Gm-Message-State: AO0yUKUbPdBdOVZaU89aPQoN1tcCNbNPECf1U/gUPXO8XQb6wo8Ga04r TbrKje5U15Kio1Y2T0dPR5xgolTIMUmNed7P X-Google-Smtp-Source: AK7set+hpbdJQ+AsIfQaYhH4j4fQ1vP8K3lGgzW6otrjgrZ8wdiuOCDWS6Spx1oFft/BJnWDMfTBQg== X-Received: by 2002:a05:6e02:170f:b0:314:20e6:133c with SMTP id u15-20020a056e02170f00b0031420e6133cmr12165688ill.3.1676303817421; Mon, 13 Feb 2023 07:56:57 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id b2-20020a923402000000b003154a4a039esm647463ila.5.2023.02.13.07.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 07:56:57 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , U-Boot Custodians , Simon Glass , Michal Simek , Marek Vasut , Pavel Herrmann Subject: [PATCH v5 02/11] dm: Add support for handling old u-boot,dm- tags Date: Mon, 13 Feb 2023 08:56:32 -0700 Message-Id: <20230213155641.1208774-3-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog In-Reply-To: <20230213155641.1208774-1-sjg@chromium.org> References: <20230213155641.1208774-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add a CONFIG option to deal with this automatically, printing a warning when U-Boot starts up. This can be useful if the device tree comes from another project. We will maintain this through the 2023.07 release, providing 6 months for people to notice. Signed-off-by: Simon Glass Version 4: Acked-by: Michal Simek --- Changes in v5: - Move this patch earlier in the series and make it additive Changes in v4: - Add a way to support handling old u-boot,dm- tags common/board_r.c | 7 +++++++ drivers/core/ofnode.c | 12 ++++++++++++ dts/Kconfig | 10 ++++++++++ include/asm-generic/global_data.h | 4 ++++ scripts/Makefile.lib | 23 +++++++++++++++++------ 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index e45003353f7..6b4180b3ecd 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -569,6 +569,13 @@ static int dm_announce(void) printf("Warning: Unexpected devicetree source (not from a prior stage)"); printf("Warning: U-Boot may not function properly\n"); } + if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE) && + (gd->flags & GD_FLG_OF_TAG_MIGRATE)) + /* + * U-Boot will silently fail to work after 2023.07 if + * there are old tags present + */ + printf("Warning: Device tree includes old 'u-boot,dm-' tags: please fix by 2023.07!\n"); } return 0; diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index d08578e9c4f..5fdac2b6638 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1330,6 +1330,18 @@ bool ofnode_pre_reloc(ofnode node) ofnode_read_bool(node, "u-boot,dm-tpl")) return true; + if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE)) { + /* detect and handle old tags */ + if (ofnode_read_bool(node, "u-boot,dm-pre-reloc") || + ofnode_read_bool(node, "u-boot,dm-pre-proper") || + ofnode_read_bool(node, "u-boot,dm-spl") || + ofnode_read_bool(node, "u-boot,dm-tpl") || + ofnode_read_bool(node, "u-boot,dm-vpl")) { + gd->flags |= GD_FLG_OF_TAG_MIGRATE; + return true; + } + } + return false; #endif } diff --git a/dts/Kconfig b/dts/Kconfig index 44cc6bf1f6f..deb865d4c28 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -342,6 +342,16 @@ config SPL_MULTI_DTB_FIT_USER_DEF_ADDR at compilation time. This is the address of this area. It must be aligned on 2-byte boundary. +config OF_TAG_MIGRATE + bool "Ease migration from old device trees with u-boot,dm- tags" + default y + help + U-Boot moved over to use new tags to mark device tree nodes which need + to be processed in SPL, before relocation, etc. Enable this option to + detect old tags and handle them. + + Note: This option will be removed after the 2023.07 release. + config OF_SPL_REMOVE_PROPS string "List of device tree properties to drop for SPL" depends on SPL_OF_CONTROL diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index da17ac8cbc8..987fb66c17a 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -650,6 +650,10 @@ enum gd_flags { * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests */ GD_FLG_FDT_CHANGED = 0x100000, + /** + * @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags + */ + GD_FLG_OF_TAG_MIGRATE = 0x200000, }; #endif /* __ASSEMBLY__ */ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index ac45a884785..7b27224b5d4 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -585,24 +585,35 @@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ # --------------------------------------------------------------------------- # Pass the original device tree file through fdtgrep twice. The first pass # removes any unwanted nodes (i.e. those which don't have the -# 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second +# 'bootph-all' property and thus are not needed by SPL. The second # pass removes various unused properties from the remaining nodes. # The output is typically a much smaller device tree file. + +ifdef CONFIG_OF_TAG_MIGRATE +# Support the old tags for a migration period +migrate_tpl := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl +migrate_vpl := -b u-boot,dm-pre-reloc -b u-boot,dm-vpl +migrate_spl := -b u-boot,dm-pre-reloc -b u-boot,dm-spl +migrate_all := -P u-boot,dm-pre-reloc \ + -P u-boot,dm-spl -P u-boot,dm-tpl -P u-boot,dm-vpl +endif + ifeq ($(CONFIG_VPL_BUILD),y) -fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-vpl +fdtgrep_props := -b bootph-all -b bootph-verify $(migrate_vpl) else ifeq ($(CONFIG_TPL_BUILD),y) -fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl +fdtgrep_props := -b bootph-all -b bootph-pre-sram $(migrate_tpl) else -fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl +fdtgrep_props := -b bootph-all -b bootph-pre-ram $(migrate_spl) endif endif quiet_cmd_fdtgrep = FDTGREP $@ cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \ -n /chosen -n /config -O dtb | \ $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \ - -P u-boot,dm-pre-reloc -P u-boot,dm-spl -P u-boot,dm-tpl \ - -P u-boot,dm-vpl \ + -P bootph-all -P bootph-pre-ram -P bootph-pre-sram \ + -P bootph-verify \ + $(migrate_all) \ $(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS))) # fdt_rm_props -- 2.39.1.581.gbfd45094c4-goog