diff mbox series

[9/9] dm: spl: Allow SPL to show memory usage

Message ID 20220508103927.912854-10-sjg@chromium.org
State Accepted
Commit 4f6500aa1a62a80e8df2ffdf16fe4c3eabd99f1c
Delegated to: Simon Glass
Headers show
Series dm: core: Support collecting and reporting stats | expand

Commit Message

Simon Glass May 8, 2022, 10:39 a.m. UTC
Add an option to tell SPL to show memory usage for driver model just
before it boots into the next phase.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/spl/spl.c     |  9 +++++++++
 drivers/core/Kconfig | 10 ++++++++++
 2 files changed, 19 insertions(+)

Comments

Simon Glass June 28, 2022, 1:37 p.m. UTC | #1
Add an option to tell SPL to show memory usage for driver model just
before it boots into the next phase.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/spl/spl.c     |  9 +++++++++
 drivers/core/Kconfig | 10 ++++++++++
 2 files changed, 19 insertions(+)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/common/spl/spl.c b/common/spl/spl.c
index c8c463f80bd..540e1925577 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -33,6 +33,7 @@ 
 #include <malloc.h>
 #include <mapmem.h>
 #include <dm/root.h>
+#include <dm/util.h>
 #include <linux/compiler.h>
 #include <fdt_support.h>
 #include <bootcount.h>
@@ -780,6 +781,14 @@  void board_init_r(gd_t *dummy1, ulong dummy2)
 
 	bootcount_inc();
 
+	/* Dump driver model states to aid analysis */
+	if (CONFIG_IS_ENABLED(DM_STATS)) {
+		struct dm_stats mem;
+
+		dm_get_mem(&mem);
+		dm_dump_mem(&mem);
+	}
+
 	memset(&spl_image, '\0', sizeof(spl_image));
 #ifdef CONFIG_SYS_SPL_ARGS_ADDR
 	spl_image.arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR;
diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index fa2811af83c..5c35914d30b 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -86,6 +86,16 @@  config DM_STATS
 
 	  To display the memory stats, use the 'dm mem' command.
 
+config SPL_DM_STATS
+	bool "Collect and show driver model stats in SPL"
+	depends on DM_SPL
+	help
+	  Enable this to collect and display memory statistics about driver
+	  model. This can help to figure out where all the memory is going and
+	  to find optimisations.
+
+	  The stats are displayed just before SPL boots to the next phase.
+
 config DM_DEVICE_REMOVE
 	bool "Support device removal"
 	depends on DM