[Concept,v2,03/30] sandbox: Add --quiet_vidconsole option to speed up output

Message ID 20260102005112.552256-4-sjg@u-boot.org
State New
Headers
Series ext4l: Add write support (part L) |

Commit Message

Simon Glass Jan. 2, 2026, 12:50 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

When running sandbox with lots of console output, the vidconsole slows
things down significantly since it renders truetype fonts to the
internal framebuffer. Add a -Q/--quiet_vidconsole command-line option
that removes vidconsole from stdout and stderr, using only the serial
console.

This can provide a ~300x speedup for output-heavy operations.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

(no changes since v1)

 arch/sandbox/cpu/start.c         | 10 ++++++++++
 arch/sandbox/include/asm/state.h |  1 +
 board/sandbox/sandbox.c          | 16 ++++++++++++++++
 doc/arch/sandbox/sandbox.rst     |  7 +++++++
 test/py/tests/test_event_dump.py |  1 +
 5 files changed, 35 insertions(+)
  

Patch

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 30d4f83b6ee..1a5ca97e15e 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -476,6 +476,16 @@  static int sandbox_cmdline_cb_no_term_present(struct sandbox_state *state,
 SANDBOX_CMDLINE_OPT_SHORT(no_term_present, 'A', 0,
 			  "Assume no terminal present (for pager testing)");
 
+static int sandbox_cmdline_cb_quiet_vidconsole(struct sandbox_state *state,
+					       const char *arg)
+{
+	state->quiet_vidconsole = true;
+
+	return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(quiet_vidconsole, 'Q', 0,
+			  "Don't use vidconsole for stdout/stderr");
+
 static int sandbox_cmdline_cb_upl(struct sandbox_state *state, const char *arg)
 {
 	state->upl = true;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 6a89f0ca5ef..ff7493ec5d6 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -177,6 +177,7 @@  struct sandbox_state {
 	bool soft_fail;			/* Continue on failure */
 	bool pager_bypass;		/* Enable pager-bypass mode */
 	bool no_term_present;		/* Assume no terminal present */
+	bool quiet_vidconsole;		/* Don't use vidconsole for stdout */
 	int video_test;			/* ms to wait before next assert */
 	const char *video_frames_dir;	/* Directory to write video frames */
 	int video_frame_count;		/* Number of frames written */
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index d97945e58fc..78b2b7b1f47 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -10,7 +10,9 @@ 
 #include <dm.h>
 #include <efi.h>
 #include <efi_loader.h>
+#include <env.h>
 #include <env_internal.h>
+#include <event.h>
 #include <extension_board.h>
 #include <init.h>
 #include <led.h>
@@ -19,6 +21,7 @@ 
 #include <os.h>
 #include <acpi/acpi_table.h>
 #include <asm/global_data.h>
+#include <asm/state.h>
 #include <asm/test.h>
 #include <asm/u-boot-sandbox.h>
 #include <linux/kernel.h>
@@ -185,3 +188,16 @@  void fwu_plat_get_bootidx(uint *boot_idx)
 	*boot_idx = 0;
 }
 #endif
+
+static int sandbox_settings(void)
+{
+	struct sandbox_state *state = state_get_current();
+
+	if (state->quiet_vidconsole) {
+		env_set("stdout", "serial");
+		env_set("stderr", "serial");
+	}
+
+	return 0;
+}
+EVENT_SPY_SIMPLE(EVT_SETTINGS_R, sandbox_settings);
diff --git a/doc/arch/sandbox/sandbox.rst b/doc/arch/sandbox/sandbox.rst
index b2f4d8913d2..90c3dfa837e 100644
--- a/doc/arch/sandbox/sandbox.rst
+++ b/doc/arch/sandbox/sandbox.rst
@@ -208,6 +208,13 @@  available options. Some of these are described below:
 -P, --pager_bypass
   Enable pager bypass mode for testing.
 
+-Q, --quiet_vidconsole
+  Don't use vidconsole for stdout/stderr. By default, sandbox outputs to both
+  serial and vidconsole. This can be slow when there is a lot of output, due to
+  truetype font rendering to the internal framebuffer. Use this option to use
+  only serial output, which can provide a significant speedup for output-heavy
+  operations.
+
 -r, --read
   Read driver state from a dtb file. In conjunction with `-w`, this allows
   sandbox to save and restore emulated hardware state (such as a TPM) across
diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py
index 3ddd60198fe..ff0da82196b 100644
--- a/test/py/tests/test_event_dump.py
+++ b/test/py/tests/test_event_dump.py
@@ -22,5 +22,6 @@  EVT_LAST_STAGE_INIT   efi_block_device_create         .*lib/efi_driver/efi_block
 EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_LAST_STAGE_INIT   last_stage_init                 .*arch/sandbox/cpu/start.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
+EVT_SETTINGS_R        sandbox_settings                .*board/sandbox/sandbox.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
     assert re.match(expect, out, re.MULTILINE) is not None