[U-Boot] [PATCH v3 0/3] fdt: Allow indicating a node is for U-Boot proper only

Hi,
I create this serie with:
1/ documentation update for previous patch [U-Boot,v2] dm: remove pre reloc properties in SPL and TPL device tree http://patchwork.ozlabs.org/patch/1081155/
PS: Code is already merged in commit commit c7a88dae997f ("dm: remove pre reloc properties in SPL and TPL device tree") but not the documentation.
2/ missing part for v1 serie (patch 1/2) http://patchwork.ozlabs.org/project/uboot/list/?series=89846 => http://patchwork.ozlabs.org/patch/1035797
3/ new tests for pre-reloc propertie in SPL as suggested by Simon (http://patchwork.ozlabs.org/patch/1081155/#2156621)
Regards Patrick
Changes in v3: - simplify test after Simon remarks by using fdtgrep on spl dtb - rebase on u-boot-dm/sandbox-working
Changes in v2: - rebase on master
Patrick Delaunay (3): test: check u-boot properties in SPL device tree fdt: Allow indicating a node is for U-Boot proper only dm: doc: add documentation for pre-reloc properties in SPL and TPL
arch/sandbox/dts/sandbox.dtsi | 18 ++++++++++++++++++ doc/README.SPL | 16 ++++++++++++++++ doc/README.TPL | 4 ++++ doc/driver-model/README.txt | 4 ++++ drivers/core/util.c | 2 ++ drivers/video/video-uclass.c | 4 +++- include/dm/ofnode.h | 6 ++++-- include/dm/util.h | 6 ++++-- test/py/tests/test_ofplatdata.py | 28 ++++++++++++++++++++++++++++ 9 files changed, 83 insertions(+), 5 deletions(-)

Add a test to check the management of the U-boot relocation properties for device tree SPL generation (fdtgrep result) and platdata: - 'dm-pre-proper' and 'dm-tpl' not included in SPL - 'dm-pre-reloc' and 'dm-spl' included in SPL
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com ---
Changes in v3: - simplify test after Simon remarks by using fdtgrep on spl dtb
Changes in v2: None
arch/sandbox/dts/sandbox.dtsi | 18 ++++++++++++++++++ test/py/tests/test_ofplatdata.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi index 2fb365d..c6d5650 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -192,6 +192,24 @@ compatible = "sandbox,spl-test.2"; };
+ spl-test5 { + u-boot,dm-tpl; + compatible = "sandbox,spl-test"; + stringarray = "tpl"; + }; + + spl-test6 { + u-boot,dm-pre-proper; + compatible = "sandbox,spl-test"; + stringarray = "pre-proper"; + }; + + spl-test7 { + u-boot,dm-spl; + compatible = "sandbox,spl-test"; + stringarray = "spl"; + }; + square { compatible = "demo-shape"; colour = "blue"; diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py index 98103ee..263334b 100644 --- a/test/py/tests/test_ofplatdata.py +++ b/test/py/tests/test_ofplatdata.py @@ -2,6 +2,7 @@ # Copyright (c) 2016 Google, Inc
import pytest +import u_boot_utils as util
OF_PLATDATA_OUTPUT = ''' of-platdata probe: @@ -31,6 +32,15 @@ intarray 0 0 0 0 longbytearray 00 00 00 00 00 00 00 00 00 string <NULL> stringarray "one" "" "" +of-platdata probe: +bool 0 +byte 00 +bytearray 00 00 00 +int 0 +intarray 0 0 0 0 +longbytearray 00 00 00 00 00 00 00 00 00 +string <NULL> +stringarray "spl" "" "" '''
@pytest.mark.buildconfigspec('spl_of_platdata') @@ -40,3 +50,21 @@ def test_ofplatdata(u_boot_console): cons.restart_uboot_with_flags(['--show_of_platdata']) output = cons.get_spawn_output().replace('\r', '') assert OF_PLATDATA_OUTPUT in output + +@pytest.mark.buildconfigspec('spl_of_platdata') +def test_spl_devicetree(u_boot_console): + """Test content of spl device-tree""" + cons = u_boot_console + dtb = cons.config.build_dir + '/spl/u-boot-spl.dtb' + fdtgrep = cons.config.build_dir + '/tools/fdtgrep' + output = util.run_and_log(cons, [fdtgrep, '-l', dtb]) + + assert "u-boot,dm-pre-reloc" not in output + assert "u-boot,dm-pre-proper" not in output + assert "u-boot,dm-spl" not in output + assert "u-boot,dm-tpl" not in output + + assert "spl-test4" in output + assert "spl-test5" not in output + assert "spl-test6" not in output + assert "spl-test7" in output

On Tue, 21 May 2019 at 11:19, Patrick Delaunay patrick.delaunay@st.com wrote:
Add a test to check the management of the U-boot relocation properties for device tree SPL generation (fdtgrep result) and platdata:
- 'dm-pre-proper' and 'dm-tpl' not included in SPL
- 'dm-pre-reloc' and 'dm-spl' included in SPL
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
Changes in v3:
- simplify test after Simon remarks by using fdtgrep on spl dtb
Changes in v2: None
arch/sandbox/dts/sandbox.dtsi | 18 ++++++++++++++++++ test/py/tests/test_ofplatdata.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Tue, 21 May 2019 at 18:53, Simon Glass sjg@chromium.org wrote:
On Tue, 21 May 2019 at 11:19, Patrick Delaunay patrick.delaunay@st.com wrote:
Add a test to check the management of the U-boot relocation properties for device tree SPL generation (fdtgrep result) and platdata:
- 'dm-pre-proper' and 'dm-tpl' not included in SPL
- 'dm-pre-reloc' and 'dm-spl' included in SPL
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
Changes in v3:
- simplify test after Simon remarks by using fdtgrep on spl dtb
Changes in v2: None
arch/sandbox/dts/sandbox.dtsi | 18 ++++++++++++++++++ test/py/tests/test_ofplatdata.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot-dm/next, thanks!

This add missing parts for previous commit 06f94461a9f4 ("fdt: Allow indicating a node is for U-Boot proper only")
At present it is not possible to specify that a node should be used before relocation (in U-Boot proper) without it also ending up in SPL and TPL device trees. Add a new "u-boot,dm-pre-proper" boolean property for this.
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v3: None Changes in v2: None
drivers/core/util.c | 2 ++ drivers/video/video-uclass.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/core/util.c b/drivers/core/util.c index 96e47dc..60b939a 100644 --- a/drivers/core/util.c +++ b/drivers/core/util.c @@ -42,6 +42,8 @@ bool dm_ofnode_pre_reloc(ofnode node) #else if (ofnode_read_bool(node, "u-boot,dm-pre-reloc")) return true; + if (ofnode_read_bool(node, "u-boot,dm-pre-proper")) + return true;
/* * In regular builds individual spl and tpl handling both diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 14aac88..d922e53 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -291,7 +291,9 @@ static int video_post_bind(struct udevice *dev) return 0; size = alloc_fb(dev, &addr); if (addr < gd->video_bottom) { - /* Device tree node may need the 'u-boot,dm-pre-reloc' tag */ + /* Device tree node may need the 'u-boot,dm-pre-reloc' or + * 'u-boot,dm-pre-proper' tag + */ printf("Video device '%s' cannot allocate frame buffer memory -ensure the device is set up before relocation\n", dev->name); return -ENOSPC;

Add documentation for the pre-reloc property in SPL and TPL device-tree: - u-boot,dm-pre-proper - u-boot,dm-pre-reloc - u-boot,dm-spl - u-boot,dm-tpl
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v3: - rebase on u-boot-dm/sandbox-working
Changes in v2: - rebase on master
doc/README.SPL | 16 ++++++++++++++++ doc/README.TPL | 4 ++++ doc/driver-model/README.txt | 4 ++++ include/dm/ofnode.h | 6 ++++-- include/dm/util.h | 6 ++++-- 5 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/doc/README.SPL b/doc/README.SPL index 7a30fef..6eed83f 100644 --- a/doc/README.SPL +++ b/doc/README.SPL @@ -66,6 +66,22 @@ CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o) CONFIG_SPL_RAM_DEVICE (common/spl/spl.c) CONFIG_SPL_WATCHDOG_SUPPORT (drivers/watchdog/libwatchdog.o)
+Device tree +----------- +The U-Boot device tree is filtered by the fdtgrep tools during the build +process to generate a much smaller device tree used in SPL (spl/u-boot-spl.dtb) +with: +- the mandatory nodes (/alias, /chosen, /config) +- the nodes with one pre-relocation property: + 'u-boot,dm-pre-reloc' or 'u-boot,dm-spl' + +ftgrep is also used to remove: +- the properties defined in CONFIG_OF_SPL_REMOVE_PROPS +- all the pre-relocation properties + ('u-boot,dm-pre-reloc', 'u-boot,dm-spl' and 'u-boot,dm-tpl') + +All the nodes remaining in the SPL devicetree are bound +(see driver-model/README.txt).
Debugging --------- diff --git a/doc/README.TPL b/doc/README.TPL index 980debe..c94129f 100644 --- a/doc/README.TPL +++ b/doc/README.TPL @@ -34,6 +34,10 @@ determine which SPL options to choose based on whether CONFIG_TPL_BUILD is set. Source files can be compiled for TPL with options choosed in the board config file.
+TPL use a small device tree (u-boot-tpl.dtb), containing only the nodes with +the pre-relocation properties: 'u-boot,dm-pre-reloc' and 'u-boot,dm-tpl' +(see README.SPL for details). + For example:
spl/Makefile: diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt index 07b120d..532a771 100644 --- a/doc/driver-model/README.txt +++ b/doc/driver-model/README.txt @@ -849,6 +849,10 @@ in the device tree node. For U-Boot proper you can use 'u-boot,dm-pre-proper' which means that it will be processed (and a driver bound) in U-Boot proper prior to relocation, but will not be available in SPL or TPL.
+To reduce the size of SPL and TPL, only the nodes with pre-relocation properties +('u-boot,dm-pre-reloc', 'u-boot,dm-spl' or 'u-boot,dm-tpl') are keept in their +device trees (see README.SPL for details); the remaining nodes are always bound. + Then post relocation we throw that away and re-init driver model again. For drivers which require some sort of continuity between pre- and post-relocation devices, we can provide access to the pre-relocation diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index d206ee2..b45da5e 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -662,12 +662,14 @@ int ofnode_read_simple_size_cells(ofnode node); * After relocation and jumping into the real U-Boot binary it is possible to * determine if a node was bound in one of SPL/TPL stages. * - * There are 3 settings currently in use - * - + * There are 4 settings currently in use + * - u-boot,dm-pre-proper: U-Boot proper pre-relocation only * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL * Existing platforms only use it to indicate nodes needed in * SPL. Should probably be replaced by u-boot,dm-spl for * new platforms. + * - u-boot,dm-spl: SPL and U-Boot pre-relocation + * - u-boot,dm-tpl: TPL and U-Boot pre-relocation * * @node: node to check * @return true if node is needed in SPL/TL, false otherwise diff --git a/include/dm/util.h b/include/dm/util.h index 60d3b93..348c2ac 100644 --- a/include/dm/util.h +++ b/include/dm/util.h @@ -52,12 +52,14 @@ static inline void dm_dump_devres(void) * it is possible to determine if a node was bound in one of * SPL/TPL stages. * - * There are 3 settings currently in use - * - + * There are 4 settings currently in use + * - u-boot,dm-pre-proper: U-Boot proper pre-relocation only * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL * Existing platforms only use it to indicate nodes needed in * SPL. Should probably be replaced by u-boot,dm-spl for * existing platforms. + * - u-boot,dm-spl: SPL and U-Boot pre-relocation + * - u-boot,dm-tpl: TPL and U-Boot pre-relocation * @node: of node * * Returns true if node is needed in SPL/TL, false otherwise.

On Tue, 21 May 2019 at 11:19, Patrick Delaunay patrick.delaunay@st.com wrote:
Add documentation for the pre-reloc property in SPL and TPL device-tree:
- u-boot,dm-pre-proper
- u-boot,dm-pre-reloc
- u-boot,dm-spl
- u-boot,dm-tpl
Signed-off-by: Patrick Delaunay patrick.delaunay@st.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v3:
- rebase on u-boot-dm/sandbox-working
Changes in v2:
- rebase on master
doc/README.SPL | 16 ++++++++++++++++ doc/README.TPL | 4 ++++ doc/driver-model/README.txt | 4 ++++ include/dm/ofnode.h | 6 ++++-- include/dm/util.h | 6 ++++-- 5 files changed, 32 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next, thanks!

Hi Simon,
Hi,
I create this serie with:
1/ documentation update for previous patch [U-Boot,v2] dm: remove pre reloc properties in SPL and TPL device tree http://patchwork.ozlabs.org/patch/1081155/
PS: Code is already merged in commit commit c7a88dae997f ("dm: remove pre reloc properties in SPL and TPL device tree") but not the documentation.
2/ missing part for v1 serie (patch 1/2) http://patchwork.ozlabs.org/project/uboot/list/?series=89846 => http://patchwork.ozlabs.org/patch/1035797
3/ new tests for pre-reloc propertie in SPL as suggested by Simon (http://patchwork.ozlabs.org/patch/1081155/#2156621)
Regards Patrick
Changes in v3:
- simplify test after Simon remarks by using fdtgrep on spl dtb
- rebase on u-boot-dm/sandbox-working
Changes in v2:
- rebase on master
Patrick Delaunay (3): test: check u-boot properties in SPL device tree fdt: Allow indicating a node is for U-Boot proper only dm: doc: add documentation for pre-reloc properties in SPL and TPL
arch/sandbox/dts/sandbox.dtsi | 18 ++++++++++++++++++ doc/README.SPL | 16 ++++++++++++++++ doc/README.TPL | 4 ++++ doc/driver-model/README.txt | 4 ++++ drivers/core/util.c | 2 ++ drivers/video/video-uclass.c | 4 +++- include/dm/ofnode.h | 6 ++++-- include/dm/util.h | 6 ++++-- test/py/tests/test_ofplatdata.py | 28 ++++++++++++++++++++++++++++ 9 files changed, 83 insertions(+), 5 deletions(-)
-- 2.7.4
Gentle reminder
targeted for v2019.07 or for next release v2019.10 ?
Not blocking for my board (as display is not yet supported).
Patrick

Hi Patrick,
On Thu, 13 Jun 2019 at 09:12, Patrick DELAUNAY patrick.delaunay@st.com wrote:
Hi Simon,
Hi,
I create this serie with:
1/ documentation update for previous patch [U-Boot,v2] dm: remove pre reloc properties in SPL and TPL device tree http://patchwork.ozlabs.org/patch/1081155/
PS: Code is already merged in commit commit c7a88dae997f ("dm: remove pre reloc properties in SPL and TPL device tree") but not the documentation.
2/ missing part for v1 serie (patch 1/2) http://patchwork.ozlabs.org/project/uboot/list/?series=89846 => http://patchwork.ozlabs.org/patch/1035797
3/ new tests for pre-reloc propertie in SPL as suggested by Simon (http://patchwork.ozlabs.org/patch/1081155/#2156621)
Regards Patrick
Changes in v3:
- simplify test after Simon remarks by using fdtgrep on spl dtb
- rebase on u-boot-dm/sandbox-working
Changes in v2:
- rebase on master
Patrick Delaunay (3): test: check u-boot properties in SPL device tree fdt: Allow indicating a node is for U-Boot proper only dm: doc: add documentation for pre-reloc properties in SPL and TPL
arch/sandbox/dts/sandbox.dtsi | 18 ++++++++++++++++++ doc/README.SPL | 16 ++++++++++++++++ doc/README.TPL | 4 ++++ doc/driver-model/README.txt | 4 ++++ drivers/core/util.c | 2 ++ drivers/video/video-uclass.c | 4 +++- include/dm/ofnode.h | 6 ++++-- include/dm/util.h | 6 ++++-- test/py/tests/test_ofplatdata.py | 28 ++++++++++++++++++++++++++++ 9 files changed, 83 insertions(+), 5 deletions(-)
-- 2.7.4
Gentle reminder
targeted for v2019.07 or for next release v2019.10 ?
Not blocking for my board (as display is not yet supported).
I'm planning to pull this in for the next release, and expect to have more time in a week.
Regards, Simon

On Thu, 13 Jun 2019 at 10:33, Simon Glass sjg@chromium.org wrote:
Hi Patrick,
On Thu, 13 Jun 2019 at 09:12, Patrick DELAUNAY patrick.delaunay@st.com wrote:
Hi Simon,
Hi,
I create this serie with:
1/ documentation update for previous patch [U-Boot,v2] dm: remove pre reloc properties in SPL and TPL device tree http://patchwork.ozlabs.org/patch/1081155/
PS: Code is already merged in commit commit c7a88dae997f ("dm: remove pre reloc properties in SPL and TPL device tree") but not the documentation.
2/ missing part for v1 serie (patch 1/2) http://patchwork.ozlabs.org/project/uboot/list/?series=89846 => http://patchwork.ozlabs.org/patch/1035797
3/ new tests for pre-reloc propertie in SPL as suggested by Simon (http://patchwork.ozlabs.org/patch/1081155/#2156621)
Regards Patrick
Changes in v3:
- simplify test after Simon remarks by using fdtgrep on spl dtb
- rebase on u-boot-dm/sandbox-working
Changes in v2:
- rebase on master
Patrick Delaunay (3): test: check u-boot properties in SPL device tree fdt: Allow indicating a node is for U-Boot proper only dm: doc: add documentation for pre-reloc properties in SPL and TPL
arch/sandbox/dts/sandbox.dtsi | 18 ++++++++++++++++++ doc/README.SPL | 16 ++++++++++++++++ doc/README.TPL | 4 ++++ doc/driver-model/README.txt | 4 ++++ drivers/core/util.c | 2 ++ drivers/video/video-uclass.c | 4 +++- include/dm/ofnode.h | 6 ++++-- include/dm/util.h | 6 ++++-- test/py/tests/test_ofplatdata.py | 28 ++++++++++++++++++++++++++++ 9 files changed, 83 insertions(+), 5 deletions(-)
-- 2.7.4
Gentle reminder
targeted for v2019.07 or for next release v2019.10 ?
Not blocking for my board (as display is not yet supported).
I'm planning to pull this in for the next release, and expect to have more time in a week.
Applied to u-boot-dm/next, thanks!
participants (3)
-
Patrick DELAUNAY
-
Patrick Delaunay
-
Simon Glass