All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/20] dm: Enhance of-platdata to support parent devices
@ 2020-10-03 17:31 Simon Glass
  2020-10-03 17:31 ` [PATCH 01/20] sandbox: Drop ad-hoc device declarations in SPL Simon Glass
                   ` (38 more replies)
  0 siblings, 39 replies; 43+ messages in thread
From: Simon Glass @ 2020-10-03 17:31 UTC (permalink / raw)
  To: u-boot

At present dev_get_parent() always returns the root device with
of-platdata. This means that it is not possible to find the I2C bus for an
I2C device easily. In many cases this does not cause problems as there is
only a single I2C bus, but it is still inconsistent with U-Boot proper.

Worse is that because devices are not bound to the correct parent, they
will not have parent_platdata allocated correctly. Manual fix-ups are
required in the code.

This series adds support for parent devices with of-platdata.

Recent improvements to of-platadata have provided a function to obtain a
device based on its driver_info struct. This requires in generated C code
in dm_populate_phandle_data() which writes the udevice pointer into each
phandle value, since this cannot be known at build time.

This works well and fixes a big hole in of-platdata. But the
implementation has a few drawbacks: the need for generated code adds (very
slightly) to code size and it means that the SPL must sit in writable
memory. The latter can be considered a security risk and is not actually
supported on Intel Apollo Lake.

Another point is that in future of-platadata may support instantiation of
devices at build time. Pointer fix-ups could become quite taxing.

So this series adjusts the approach, storing an index (idx) to the
driver_info struct in the linker list instead. That index can be figured
out in dtoc and the value placed directly in the phandle struct. For
64-bit machines it is also smaller than a pointer. It requires a new table
(driver_rt) to be set up at runtime.

This series adds more SPL tests written in C, using the infrastructure in
the previous series (u-boot-dm/tes-working). A few clean-ups and a bug fix
resulting from these are included.

Finally, x86 is updated to use the parent support. For now, parent support
is behind a Kconfig option, but I expect this will become the default,
assuming that no major problems are found.

SPL size impact is fairly neural, slightly positive on chromebook_jerry
(Thumb-2) and slightly negative on rock64-rk3328 (aarch64):

  aarch64: spl/u-boot-spl:all +39.0 spl/u-boot-spl:rodata -5.0
           spl/u-boot-spl:text +44.0
      arm: spl/u-boot-spl:all -49.0 spl/u-boot-spl:data -80.0
           spl/u-boot-spl:text +36.0 spl/u-boot-spl:rodata -5.0

The increase in code size is due to lists_bind_drivers() having to do
multiple passes to ensure that parents are processed before children. This
could possible be reduced with a more complex linker list ordering
mechanism, but it would be a bit messy and that idea is not explored in
this series.


Simon Glass (20):
  sandbox: Drop ad-hoc device declarations in SPL
  dtoc: Document the return value of scan_structs()
  dtoc: Order the structures internally by name
  dm: core: Allow dm_warn() to be used in SPL
  dtoc: Fix widening of int to bytes
  dm: Add a C test for of-platdata properties
  sandbox: Allow selection of SPL unit tests
  dm: test: Drop of-platdata pytest
  dm: test: Add a check that all devices have a dev value
  dm: test: Add a test for of-platdata phandles
  dm: Use an allocated array for run-time device info
  sandbox: Fix up building for of-platdata
  dm: Support parent devices with of-platdata
  dm: Add a test for of-platdata parent information
  dm: core: Convert #ifdef to if() in root.c
  x86: apl: Enable SPI flash in TPL with APL_SPI_FLASH_BOOT
  x86: apl: Take advantage of the of-platdata parent support
  dm: Use driver_info index instead of pointer
  dm: Don't allow U_BOOT_DEVICE() when of-platdata is used
  dm: doc: Update the of-platadata documentation

 arch/sandbox/cpu/spl.c              |  14 +-
 arch/sandbox/cpu/start.c            |  16 +--
 arch/sandbox/dts/sandbox.dts        |   1 +
 arch/sandbox/dts/sandbox.dtsi       |  27 ++++
 arch/sandbox/include/asm/state.h    |   2 +-
 arch/x86/cpu/apollolake/Kconfig     |   2 +
 arch/x86/cpu/apollolake/spl.c       |   3 +-
 board/sandbox/sandbox.c             |   2 +
 configs/sandbox_spl_defconfig       |   5 +-
 doc/driver-model/of-plat.rst        |  42 +++---
 drivers/clk/clk-uclass.c            |   3 +-
 drivers/clk/clk_fixed_rate.c        |   4 +-
 drivers/clk/clk_sandbox.c           |   4 +-
 drivers/core/Kconfig                |  18 ++-
 drivers/core/device.c               |  23 +++-
 drivers/core/lists.c                |  70 +++++++++-
 drivers/core/root.c                 |  29 ++--
 drivers/core/util.c                 |   2 +-
 drivers/i2c/Makefile                |   2 +-
 drivers/i2c/i2c-emul-uclass.c       |   2 +
 drivers/i2c/sandbox_i2c.c           |   4 +-
 drivers/misc/irq-uclass.c           |   2 +-
 drivers/misc/p2sb-uclass.c          |  27 ++--
 drivers/misc/spltest_sandbox.c      |  35 -----
 drivers/mmc/fsl_esdhc_imx.c         |   7 +-
 drivers/rtc/rtc-uclass.c            |   2 +
 drivers/rtc/sandbox_rtc.c           |   4 +-
 drivers/serial/sandbox.c            |   3 +
 drivers/spi/ich.c                   |   4 +-
 drivers/sysreset/sysreset_sandbox.c |   2 +
 dts/Kconfig                         |  18 +++
 include/asm-generic/global_data.h   |  13 ++
 include/config_uncmd_spl.h          |   1 -
 include/dm/device-internal.h        |   2 +-
 include/dm/device.h                 |  14 ++
 include/dm/platdata.h               |  32 ++++-
 include/dm/util.h                   |   2 +-
 include/dt-structs.h                |   6 +-
 test/dm/of_platdata.c               | 203 ++++++++++++++++++++++++++++
 test/dm/test-main.c                 |  24 +++-
 test/py/tests/test_ofplatdata.py    |  47 -------
 test/py/tests/test_spl.py           |   5 +-
 tools/dtoc/dtb_platdata.py          |  63 +++++----
 tools/dtoc/dtoc_test_simple.dts     |   1 +
 tools/dtoc/fdt.py                   |   9 ++
 tools/dtoc/test_dtoc.py             | 178 ++++++++++++++++--------
 tools/dtoc/test_fdt.py              |  10 ++
 47 files changed, 705 insertions(+), 284 deletions(-)

-- 
2.28.0.806.g8561365e88-goog

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2020-11-04 14:33 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03 17:31 [PATCH 00/20] dm: Enhance of-platdata to support parent devices Simon Glass
2020-10-03 17:31 ` [PATCH 01/20] sandbox: Drop ad-hoc device declarations in SPL Simon Glass
2020-10-03 17:31 ` [PATCH 02/20] dtoc: Document the return value of scan_structs() Simon Glass
2020-10-03 17:31 ` [PATCH 03/20] dtoc: Order the structures internally by name Simon Glass
2020-10-03 17:31 ` [PATCH 04/20] dm: core: Allow dm_warn() to be used in SPL Simon Glass
2020-10-03 17:31 ` [PATCH 05/20] dtoc: Fix widening of int to bytes Simon Glass
2020-10-03 17:31 ` [PATCH 06/20] dm: Add a C test for of-platdata properties Simon Glass
2020-10-03 17:31 ` [PATCH 07/20] sandbox: Allow selection of SPL unit tests Simon Glass
2020-10-03 17:31 ` [PATCH 08/20] dm: test: Drop of-platdata pytest Simon Glass
2020-10-03 17:31 ` [PATCH 09/20] dm: test: Add a check that all devices have a dev value Simon Glass
2020-10-03 17:31 ` [PATCH 10/20] dm: test: Add a test for of-platdata phandles Simon Glass
2020-10-03 17:31 ` [PATCH 11/20] dm: Use an allocated array for run-time device info Simon Glass
2020-10-03 17:31 ` [PATCH 12/20] sandbox: Fix up building for of-platdata Simon Glass
2020-10-03 17:31 ` [PATCH 13/20] dm: Support parent devices with of-platdata Simon Glass
2020-10-03 17:31 ` [PATCH 14/20] dm: Add a test for of-platdata parent information Simon Glass
2020-10-03 17:31 ` [PATCH 15/20] dm: core: Convert #ifdef to if() in root.c Simon Glass
2020-11-04 12:55   ` Michal Simek
2020-11-04 13:59     ` Tom Rini
2020-11-04 14:33       ` Michal Simek
2020-10-03 17:31 ` [PATCH 16/20] x86: apl: Enable SPI flash in TPL with APL_SPI_FLASH_BOOT Simon Glass
2020-10-03 17:31 ` [PATCH 17/20] x86: apl: Take advantage of the of-platdata parent support Simon Glass
2020-10-03 17:31 ` [PATCH 18/20] dm: Use driver_info index instead of pointer Simon Glass
2020-10-03 17:31 ` [PATCH 19/20] dm: Don't allow U_BOOT_DEVICE() when of-platdata is used Simon Glass
2020-10-03 17:31 ` [PATCH 20/20] dm: doc: Update the of-platadata documentation Simon Glass
2020-10-27  1:01 ` [PATCH 05/20] dtoc: Fix widening of int to bytes Simon Glass
2020-10-27  1:01 ` [PATCH 04/20] dm: core: Allow dm_warn() to be used in SPL Simon Glass
2020-10-27  1:01 ` [PATCH 03/20] dtoc: Order the structures internally by name Simon Glass
2020-10-27  1:01 ` [PATCH 02/20] dtoc: Document the return value of scan_structs() Simon Glass
2020-10-27  1:01 ` [PATCH 01/20] sandbox: Drop ad-hoc device declarations in SPL Simon Glass
2020-10-30  3:34 ` [PATCH 20/20] dm: doc: Update the of-platadata documentation Simon Glass
2020-10-30  3:34 ` [PATCH 19/20] dm: Don't allow U_BOOT_DEVICE() when of-platdata is used Simon Glass
2020-10-30  3:34 ` [PATCH 18/20] dm: Use driver_info index instead of pointer Simon Glass
2020-10-30  3:34 ` [PATCH 16/20] x86: apl: Enable SPI flash in TPL with APL_SPI_FLASH_BOOT Simon Glass
2020-10-30  3:34 ` [PATCH 17/20] x86: apl: Take advantage of the of-platdata parent support Simon Glass
2020-10-30  3:34 ` [PATCH 15/20] dm: core: Convert #ifdef to if() in root.c Simon Glass
2020-10-30  3:34 ` [PATCH 14/20] dm: Add a test for of-platdata parent information Simon Glass
2020-10-30  3:34 ` [PATCH 13/20] dm: Support parent devices with of-platdata Simon Glass
2020-10-30  3:34 ` [PATCH 12/20] sandbox: Fix up building for of-platdata Simon Glass
2020-10-30  3:34 ` [PATCH 11/20] dm: Use an allocated array for run-time device info Simon Glass
2020-10-30  3:34 ` [PATCH 10/20] dm: test: Add a test for of-platdata phandles Simon Glass
2020-10-30  3:34 ` [PATCH 07/20] sandbox: Allow selection of SPL unit tests Simon Glass
2020-10-30  3:34 ` [PATCH 09/20] dm: test: Add a check that all devices have a dev value Simon Glass
2020-10-30  3:34 ` [PATCH 06/20] dm: Add a C test for of-platdata properties Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.