[PATCH v2 7/7] x86: qemu: Enable ramfb by default

Alper Nebi Yasak alpernebiyasak at gmail.com
Tue Aug 22 14:10:25 CEST 2023


Now that we have everything in place to support ramfb, let's wire it up
by default in the x86 QEMU targets. That way, we can use ramfb graphical
console instead of the default by passing -vga none -device ramfb to the
QEMU command line.

Also increase SYS_MALLOC_F_LEN for QEMU x86_64 to be the same as its SPL
counterpart, because we're running out of alloc space in pre-reloc stage
with ramfb enabled.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak at gmail.com>
---
This also suffers from the same issue with distros as the Bochs display
driver [1], where it results in a hang after GRUB menu selection before
the kernel can display anything. Couldn't reproduce on arm*/riscv*.

But just having it enabled doesn't seem to cause problems unless you run
QEMU with -device ramfb, so this (unlike the Bochs video driver) can
actually be co-enabled with VIDEO_VESA.

[1] https://lore.kernel.org/u-boot/20230724145210.304917-4-sjg@chromium.org/

Changes in v2:
- Add patch "x86: qemu: Enable ramfb by default"

 arch/x86/cpu/qemu/Kconfig           |  4 +++
 board/emulation/qemu-x86/qemu-x86.c | 47 +++++++++++++++++++++++++++++
 configs/qemu-x86_64_defconfig       |  4 +--
 configs/qemu-x86_defconfig          |  1 -
 4 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/arch/x86/cpu/qemu/Kconfig b/arch/x86/cpu/qemu/Kconfig
index f8f2f6473088..e0a57ac2d687 100644
--- a/arch/x86/cpu/qemu/Kconfig
+++ b/arch/x86/cpu/qemu/Kconfig
@@ -13,6 +13,10 @@ config QEMU
 	imply USB
 	imply USB_EHCI_HCD
 	imply VIDEO_VESA
+	imply VIDEO_RAMFB
+	imply BOARD_EARLY_INIT_F
+	imply BOARD_EARLY_INIT_R
+	imply CMD_QFW
 
 if QEMU
 
diff --git a/board/emulation/qemu-x86/qemu-x86.c b/board/emulation/qemu-x86/qemu-x86.c
index e69de29bb2d1..3a8a580cc591 100644
--- a/board/emulation/qemu-x86/qemu-x86.c
+++ b/board/emulation/qemu-x86/qemu-x86.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include <dm.h>
+#include <init.h>
+#include <log.h>
+#include <qfw.h>
+
+int board_early_init_f(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	/*
+	 * Make sure we enumerate the QEMU Firmware device to bind ramfb
+	 * so video_reserve() can reserve memory for it.
+	 */
+	if (IS_ENABLED(CONFIG_QFW)) {
+		ret = qfw_get_dev(&dev);
+		if (ret) {
+			log_err("Failed to get QEMU FW device: %d\n", ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+int board_early_init_r(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	/*
+	 * Make sure we enumerate the QEMU Firmware device to find ramfb
+	 * before console_init.
+	 */
+	if (IS_ENABLED(CONFIG_QFW)) {
+		ret = qfw_get_dev(&dev);
+		if (ret) {
+			log_err("Failed to get QEMU FW device: %d\n", ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}
diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig
index c6f30674a8fc..c9ad6eebd35c 100644
--- a/configs/qemu-x86_64_defconfig
+++ b/configs/qemu-x86_64_defconfig
@@ -1,13 +1,12 @@
 CONFIG_X86=y
 CONFIG_TEXT_BASE=0x1110000
-CONFIG_SYS_MALLOC_F_LEN=0x1000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_NR_DRAM_BANKS=8
 CONFIG_ENV_SIZE=0x40000
 CONFIG_MAX_CPUS=2
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx"
 CONFIG_SPL_TEXT_BASE=0xfffd8000
-CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEBUG_UART_BASE=0x3f8
 CONFIG_DEBUG_UART_CLOCK=1843200
 CONFIG_X86_RUN_64BIT=y
@@ -59,7 +58,6 @@ CONFIG_CMD_USB=y
 CONFIG_BOOTP_BOOTFILESIZE=y
 CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
-CONFIG_CMD_QFW=y
 CONFIG_CMD_BOOTSTAGE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_ENV_OVERWRITE=y
diff --git a/configs/qemu-x86_defconfig b/configs/qemu-x86_defconfig
index 24682a5387df..8a2311720f02 100644
--- a/configs/qemu-x86_defconfig
+++ b/configs/qemu-x86_defconfig
@@ -37,7 +37,6 @@ CONFIG_CMD_USB=y
 CONFIG_BOOTP_BOOTFILESIZE=y
 CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
-CONFIG_CMD_QFW=y
 CONFIG_CMD_BOOTSTAGE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MAC_PARTITION=y
-- 
2.40.1



More information about the U-Boot mailing list