All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] dm: Experiments for reducing SPL memory usage
@ 2022-03-27 20:26 Simon Glass
  2022-03-27 20:26 ` [PATCH 01/10] Makefile: v2 Allow LTO to be disabled for a build Simon Glass
                   ` (9 more replies)
  0 siblings, 10 replies; 23+ messages in thread
From: Simon Glass @ 2022-03-27 20:26 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Heinrich Schuchardt, Sean Anderson, Marek Behún,
	U-Boot Custodians, Tom Rini, Simon Glass, AKASHI Takahiro,
	Alexandru Gagniuc, Bin Meng, Dario Binacchi, Ilias Apalodimas,
	Joel Peshkin, Marek Vasut, Masahiro Yamada, Pali Rohár,
	Patrick Delaunay, Pavel Herrmann, Rasmus Villemoes,
	Ricardo Salveti, Stefan Roese, Ye Li

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


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

end of thread, other threads:[~2022-05-15 18:53 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-27 20:26 [PATCH 00/10] dm: Experiments for reducing SPL memory usage Simon Glass
2022-03-27 20:26 ` [PATCH 01/10] Makefile: v2 Allow LTO to be disabled for a build Simon Glass
2022-03-31 10:29   ` Andrew Scull
2022-04-11 21:46     ` Simon Glass
2022-04-11 21:53       ` Tom Rini
2022-05-15 18:52       ` Andrew Scull
2022-03-27 20:26 ` [PATCH 02/10] sandbox: Correct loss of early output in SPL Simon Glass
2022-04-19 12:49   ` Tom Rini
2022-03-27 20:26 ` [PATCH 03/10] Makefile: Drop a stale comment about linking Simon Glass
2022-04-19 12:49   ` Tom Rini
2022-03-27 20:26 ` [PATCH 04/10] Makefile: Avoid resetting link flags in config.mk Simon Glass
2022-04-19 12:49   ` Tom Rini
2022-03-27 20:26 ` [PATCH 05/10] sandbox: Allow link flags to be given Simon Glass
2022-04-19 12:49   ` Tom Rini
2022-03-27 20:26 ` [PATCH 06/10] sandbox: Align linker lists to a 32-byte boundary Simon Glass
2022-04-19 12:49   ` Tom Rini
2022-03-27 20:26 ` [PATCH 07/10] dm: core: Allow devres to be disabled in SPL Simon Glass
2022-04-12 19:07   ` Angus Ainslie
2022-04-19 12:49   ` Tom Rini
2022-03-27 20:26 ` [PATCH 08/10] dm: core: Deal with a wrinkle with linker lists Simon Glass
2022-04-19 12:50   ` Tom Rini
2022-03-27 20:26 ` [PATCH 09/10] RFC: dm: add tag support Simon Glass
2022-03-27 20:26 ` [PATCH 10/10] WIP: dm: core: Add a command to calculate memory usage 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.