diff mbox series

[v4,10/11] dm: Add support for handling old u-boot,dm- tags

Message ID 20230210152857.733648-11-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show
Series dm: Move to new driver model schema for device tree tags | expand

Commit Message

Simon Glass Feb. 10, 2023, 3:28 p.m. UTC
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 <sjg@chromium.org>
---

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(-)

Comments

Tom Rini Feb. 12, 2023, 5:44 p.m. UTC | #1
On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:

> 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 <sjg@chromium.org>

Adding Michal since he got lost by accident on this iteration. Does that
sound like enough time to get the tooling you know of updated?
Simon Glass Feb. 12, 2023, 11:15 p.m. UTC | #2
Hi Tom,

On Sun, 12 Feb 2023 at 10:44, Tom Rini <trini@konsulko.com> wrote:
>
> On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:
>
> > 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 <sjg@chromium.org>
>
> Adding Michal since he got lost by accident on this iteration. Does that
> sound like enough time to get the tooling you know of updated?

Thanks...BTW is the membership of u-boot-custodians listed somewhere?

Regards,
Simon
Tom Rini Feb. 13, 2023, 1:10 a.m. UTC | #3
On Sun, Feb 12, 2023 at 04:15:08PM -0700, Simon Glass wrote:
> Hi Tom,
> 
> On Sun, 12 Feb 2023 at 10:44, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:
> >
> > > 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 <sjg@chromium.org>
> >
> > Adding Michal since he got lost by accident on this iteration. Does that
> > sound like enough time to get the tooling you know of updated?
> 
> Thanks...BTW is the membership of u-boot-custodians listed somewhere?

Maybe via the normal mailman page once you've signed in?
Simon Glass Feb. 13, 2023, 4:27 a.m. UTC | #4
Hi Tom,

On Sun, 12 Feb 2023 at 18:10, Tom Rini <trini@konsulko.com> wrote:
>
> On Sun, Feb 12, 2023 at 04:15:08PM -0700, Simon Glass wrote:
> > Hi Tom,
> >
> > On Sun, 12 Feb 2023 at 10:44, Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:
> > >
> > > > 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 <sjg@chromium.org>
> > >
> > > Adding Michal since he got lost by accident on this iteration. Does that
> > > sound like enough time to get the tooling you know of updated?
> >
> > Thanks...BTW is the membership of u-boot-custodians listed somewhere?
>
> Maybe via the normal mailman page once you've signed in?

Not that I can see. Probably only the admin knows.

Regards,
Simon
Michal Simek Feb. 13, 2023, 7:53 a.m. UTC | #5
On 2/12/23 18:44, Tom Rini wrote:
> On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:
> 
>> 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 <sjg@chromium.org>
> 
> Adding Michal since he got lost by accident on this iteration. Does that
> sound like enough time to get the tooling you know of updated?
> 

This patch makes sense to me and provide good migration path. Thanks!

In connection to have tree working all the time for bisecting reasons I think 
the whole series should be a little bit rearranged and this shouldn't be the 
patch 10/11 but very early.
But I will let Tom to decide if this should be rearranged or not.

Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal
Simon Glass Feb. 13, 2023, 2:45 p.m. UTC | #6
Hi Michal,

On Mon, 13 Feb 2023 at 00:53, Michal Simek <michal.simek@amd.com> wrote:
>
>
>
> On 2/12/23 18:44, Tom Rini wrote:
> > On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:
> >
> >> 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 <sjg@chromium.org>
> >
> > Adding Michal since he got lost by accident on this iteration. Does that
> > sound like enough time to get the tooling you know of updated?
> >
>
> This patch makes sense to me and provide good migration path. Thanks!
>
> In connection to have tree working all the time for bisecting reasons I think
> the whole series should be a little bit rearranged and this shouldn't be the
> patch 10/11 but very early.
> But I will let Tom to decide if this should be rearranged or not.
>
> Acked-by: Michal Simek <michal.simek@amd.com>

With a bit of fiddling I think that is possible. I will send a v5.

Regards,
Simon
diff mbox series

Patch

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