[PATCH 00/10] dm: Experiments for reducing SPL memory usage
Simon Glass
sjg at chromium.org
Sun Mar 27 22:26:12 CEST 2022
This series explores using the (not yet applied) tag support in driver
model to reduce memory usage in SPL.
This is particularly important on 64-bit machines, which use a
ridiculously large 8 bytes for each pointer into what what is sometimes
only 64KB of available memory.
The primary focus of this series is struct udevice, which can be shrunk
in various ways:
- Including devres_head only when DEVRES is enabled (i.e. not in SPL)
- Using tags instead of pointers for attached data like plat_, priv_ and
driver_data
- Using singly linked lists, currently not supported in U-Boot
- Using a table index for the driver pointer and uclass pointer
Together these bring the size of struct udevice down from 0xa0 (160) bytes
to 0x30 (48) bytes.
Another option is to drop the device name, although this is a pain for
debugging.
It would also be possible to implement doubly linked lists with a
16-bit index into malloc space, in SPL, thus reducing the overhead in each
node from 16 bytes to 2, or just using a fixed-size list for each data
structure, since the number of items is quite limited in SPL.
To implement the tag side of things, functions like dev_set_parent_priv()
need to be modified to call dev_tag_set_ptr(), and dev_get_parent_priv()
needs to call dev_tag_get_ptr().
Note there has been some previous work:
- tiny-dm analysis[1] which we decided was too disruptive
- build-time instantiation, to reduce SPL code size[2].
[1] https://patchwork.ozlabs.org/project/uboot/cover/20200702211004.1491489-1-sjg@chromium.org/
[2] https://u-boot.readthedocs.io/en/latest/develop/driver-model/of-plat.html#build-time-instantiation
AKASHI Takahiro (1):
RFC: dm: add tag support
Simon Glass (9):
Makefile: v2 Allow LTO to be disabled for a build
sandbox: Correct loss of early output in SPL
Makefile: Drop a stale comment about linking
Makefile: Avoid resetting link flags in config.mk
sandbox: Allow link flags to be given
sandbox: Align linker lists to a 32-byte boundary
dm: core: Allow devres to be disabled in SPL
dm: core: Deal with a wrinkle with linker lists
WIP: dm: core: Add a command to calculate memory usage
Makefile | 22 ++--
arch/arm/config.mk | 4 +-
arch/arm/include/asm/global_data.h | 2 +-
arch/sandbox/config.mk | 4 +-
arch/sandbox/cpu/os.c | 2 +-
arch/sandbox/cpu/u-boot-spl.lds | 2 +-
arch/sandbox/cpu/u-boot.lds | 2 +-
cmd/dm.c | 15 ++-
common/spl/spl.c | 9 ++
config.mk | 1 -
doc/build/gcc.rst | 17 +++
drivers/core/Makefile | 4 +-
drivers/core/device.c | 70 +++++++++++-
drivers/core/dump.c | 73 +++++++++++++
drivers/core/root.c | 63 ++++++++++-
drivers/core/tag.c | 168 +++++++++++++++++++++++++++++
include/asm-generic/global_data.h | 4 +
include/dm/device-internal.h | 6 +-
include/dm/device.h | 16 ++-
include/dm/devres.h | 4 +-
include/dm/root.h | 45 ++++++++
include/dm/tag.h | 126 ++++++++++++++++++++++
include/dm/util.h | 9 ++
scripts/Makefile.spl | 2 +-
test/dm/Makefile | 2 +-
25 files changed, 640 insertions(+), 32 deletions(-)
create mode 100644 drivers/core/tag.c
create mode 100644 include/dm/tag.h
--
2.35.1.1021.g381101b075-goog
More information about the U-Boot
mailing list