From patchwork Fri Feb 10 15:28:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1740520 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=C+EbVks5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PCyQS1mTpz23yH for ; Sat, 11 Feb 2023 02:32:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1123185FF8; Fri, 10 Feb 2023 16:31:33 +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="C+EbVks5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D288685FC2; Fri, 10 Feb 2023 16:29:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 F1D9985F9F for ; Fri, 10 Feb 2023 16:29:37 +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-x12f.google.com with SMTP id s9so1153161ilt.1 for ; Fri, 10 Feb 2023 07:29:37 -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=jLxzJ+gV1WHH9H3vP45iv9qDRDr4mJNIG2tVTj5iUT8=; b=C+EbVks5N4H3aKoJ2USaW8sN7/bNzMZt4U3mC0C5stHj7jQxCpYhtBxIwOQYBONFQb uSzs7+BObwT2T8gT0DoHe1TPH/IyUAZ9moIxqz8ibKqZ7cvBIcQOjb7IdO7xFg5NtjNQ GNq0BeP6NimYAqZzP0RiLzL/ecI+nkFDkDtjE= 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=jLxzJ+gV1WHH9H3vP45iv9qDRDr4mJNIG2tVTj5iUT8=; b=J5zBcCP2CRes38m9c17z9grd/6SXrbEWTKe5UfTqLI6AYgtiZtpURhJqFXgZXwbRl6 Dv6mqg0uMF5mzZrC6s94BP1g+kmvTp4FiL7yutSNqm/O3+IEv3sEFRUFaNUXz4Szh3SK JimjG2KWNczPtJTPWMYnNhGooOGSG6YA9FwoHeeo3s9zRvICQSSnP/Ob4WooSkaBjnr+ jM/CGr/7R80IOF2UnJIrb2AIlhWL2x7naXUt2ZBXRY0ehoqD3Wyp2U/m13uHnD5Jvser eypj6jRiZnte3beZM6fCygySjb5Sy+/xVOo+Mb0NzhSyyj21U5U2yr9eP//1kibw0wCG oMAg== X-Gm-Message-State: AO0yUKVyTK+2fLI1D8H6r60P94YmGihs4vA2oX9NLao4C62nSchqG7qi fWblqaHhSXJVRmGbMLCw0qBGaP6H/YrURW1s X-Google-Smtp-Source: AK7set+AVHcBDzSr3BvZ+jnV/aD/LTl9XqOoPxHgkvpyMGZCyUXDS12YL7As10ivs5Ggr8za0xjKyg== X-Received: by 2002:a05:6e02:1d1d:b0:314:22c0:49 with SMTP id i29-20020a056e021d1d00b0031422c00049mr696459ila.5.1676042969169; Fri, 10 Feb 2023 07:29:29 -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 i8-20020a02ca08000000b003aa9ddab101sm1004554jak.19.2023.02.10.07.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 07:29:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , U-Boot Custodians , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH v4 10/11] dm: Add support for handling old u-boot,dm- tags Date: Fri, 10 Feb 2023 08:28:56 -0700 Message-Id: <20230210152857.733648-11-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog In-Reply-To: <20230210152857.733648-1-sjg@chromium.org> References: <20230210152857.733648-1-sjg@chromium.org> MIME-Version: 1.0 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 Acked-by: Michal Simek --- 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 | 17 ++++++++++++++--- 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 3618acad437..38dc97003c3 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 3883f07812b..f49ee493d3c 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, "bootph-pre-sram")) 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 147344dd8af..3b7489f0f87 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 8f251831307..3256abad8fa 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -588,13 +588,23 @@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ # '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 bootph-all -b bootph-verify +fdtgrep_props := -b bootph-all -b bootph-verify $(migrate_vpl) else ifeq ($(CONFIG_TPL_BUILD),y) -fdtgrep_props := -b bootph-all -b bootph-pre-sram +fdtgrep_props := -b bootph-all -b bootph-pre-sram $(migrate_tpl) else -fdtgrep_props := -b bootph-all -b bootph-pre-ram +fdtgrep_props := -b bootph-all -b bootph-pre-ram $(migrate_spl) endif endif quiet_cmd_fdtgrep = FDTGREP $@ @@ -603,6 +613,7 @@ quiet_cmd_fdtgrep = FDTGREP $@ $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \ -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