Skip to contentSkip to conversation

Add support for QEMU's ramfb display

PATCH In review Alper Nebi Yasak 4 participants 25 messages Aug 22, 2023 – Aug 28, 2023

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover Add support for QEMU's ramfb display

This is a rebase of Alexander Graf's QEMU ramfb support series with some changes of mine, in part to address reviews and to accommodate other changes enabling Bochs video driver. The original cover letter is as follows:

Quoted 8 lines

QEMU implements multiple ways to expose graphics output to the virt machine, but most of them are incompatible with hardware virtualization.

The one that does work reliably is ramfb. It's a very simple mechanism in which the guest reserves a memory region for the frame buffer and then notifies the host about its location and properties. The host then just displays the contents of the frame buffer on screen.

Quoted 7 lines

This patch set adds support to drive the ramfb device in our QEMU arm targets. Theoretically, it should work as is with any of the other architectures as well though.

With this driver, we have a very simple, KVM compatible way to expose GOP via UEFI to payloads and thus enable development and testing of graphical OS functionality with QEMU's -M virt.

Inspired by the "video: bochs: Remove the x86 limitation" series [1] that was recently merged, I have also sent a series adding Bochs video device support for ARM [2], and assuming that would get merged before this I've rebased this on that to avoid conflicts.

[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://lore.kernel.org/u-boot/[email protected]/

Changes in v2:
- Remove extra "depends on DM_VIDEO" already in "if VIDEO"
- Drop drivers/video/MAINTAINERS file
- Decouple framebuffer allocation from EFI_LOADER
- Add .bind() method for ramfb driver
- Make resolution configurable with kconfig
- Move struct to qfw.h and add comments for members
- Use RAMFB_* definitions instead of DEFAULT_*
- Use if (IS_ENABLED(CONFIG_VIDEO_RAMFB)) instead of #ifdef
- Add patch "qfw: Add flag to allow probing before relocation"
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU
- Drop imply VIDEO, env changes from RISC-V patch (in u-boot/next)
- Drop imply SYS_CONSOLE_IS_IN_ENV from RISC-V patch (def. y if VIDEO)
- Probe QFW in RISC-V QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to RISC-V QEMU
- Add patch "x86: qemu: Enable ramfb by default"

v1: https://lore.kernel.org/u-boot/[email protected]/

Alexander Graf (5):
qfw: Add WRITE definition
ramfb: Add driver for ramfb display
qfw: Spawn ramfb device if its file is present
arm: qemu: Enable ramfb by default
riscv: qemu: Enable ramfb by default

Alper Nebi Yasak (2):
qfw: Add flag to allow probing before relocation
x86: qemu: Enable ramfb by default

 arch/arm/Kconfig                        |  3 +
 arch/x86/cpu/qemu/Kconfig               |  4 +
 board/emulation/qemu-arm/qemu-arm.c     | 41 +++++++++++
 board/emulation/qemu-riscv/Kconfig      |  5 ++
 board/emulation/qemu-riscv/qemu-riscv.c | 41 +++++++++++
 board/emulation/qemu-x86/qemu-x86.c     | 47 ++++++++++++
 configs/qemu-x86_64_defconfig           |  4 +-
 configs/qemu-x86_defconfig              |  1 -
 drivers/misc/qfw.c                      | 25 +++++++
 drivers/misc/qfw_mmio.c                 |  1 +
 drivers/misc/qfw_pio.c                  |  1 +
 drivers/misc/qfw_sandbox.c              |  1 +
 drivers/video/Kconfig                   | 30 ++++++++
 drivers/video/Makefile                  |  1 +
 drivers/video/ramfb.c                   | 97 +++++++++++++++++++++++++
 include/qfw.h                           | 11 +++
 16 files changed, 309 insertions(+), 4 deletions(-)
 create mode 100644 drivers/video/ramfb.c

base-commit: 832148f675e427060be074c276956962fa9b5cb6
prerequisite-patch-id: 2c8662d18f6f1e2d4e014bcd5d468e0396064f4f
prerequisite-patch-id: 5f3e5e1d814187841ce299df0da16df16d0121c3
prerequisite-patch-id: adbd0fb953e726ea5ea0b248e00092dfc318fd46
prerequisite-patch-id: 7470d3af5e9ded16eb5a4de7c7264062dcb3ef7f

Signature · 1 line
2.40.1
#1 lore raw

PATCH v2 1/7 qfw: Add WRITE definition

From: Alexander Graf <[email protected]>

The QEMU fw_cfg device supports writing entries as well. Add the constant define for it so that we can leverage write functionality later.

---

(no changes since v1)

 include/qfw.h | 1 +
 1 file changed, 1 insertion(+)
include/qfw.h +1 -0
index 42798fea7db4..d3aaa4d54efc 100644
@@ -70,6 +70,7 @@ enum {
 #define FW_CFG_DMA_READ	(1 << 1)
 #define FW_CFG_DMA_SKIP	(1 << 2)
 #define FW_CFG_DMA_SELECT	(1 << 3)
+#define FW_CFG_DMA_WRITE	(1 << 4)
 
 /* Bit set in FW_CFG_ID response to indicate DMA interface availability. */
 #define FW_CFG_DMA_ENABLED	(1 << 1)
Signature · 1 line
2.40.1
#2 lore raw

PATCH v2 2/7 ramfb: Add driver for ramfb display

In reply to Alper Nebi Yasak

From: Alexander Graf <[email protected]>

QEMU implements multiple ways to expose graphics output to the virt machine, but most of them are incompatible with hardware virtualization.

The one that does work reliably is ramfb. It's a very simple mechanism in which the guest reserves a memory region for the frame buffer and then notifies the host about its location and properties. The host then just displays the contents of the frame buffer on screen.

This patch implements a trivial version of a ramfb driver - hard coded to a single resolution set in Kconfig.

[Alper: Deduplicate depends on DM_VIDEO, drop MAINTAINERS, decouple from
EFI_LOADER, add .bind(), kconfigurable resolution, struct in .h]

---

Changes in v2:
- Remove extra "depends on DM_VIDEO" already in "if VIDEO"
- Drop drivers/video/MAINTAINERS file
- Decouple framebuffer allocation from EFI_LOADER
- Add .bind() method for ramfb driver
- Make resolution configurable with kconfig
- Move struct to qfw.h and add comments for members
- Use RAMFB_* definitions instead of DEFAULT_*

 drivers/video/Kconfig  | 30 +++++++++++++
 drivers/video/Makefile |  1 +
 drivers/video/ramfb.c  | 97 ++++++++++++++++++++++++++++++++++++++++++
 include/qfw.h          | 10 +++++
 4 files changed, 138 insertions(+)
 create mode 100644 drivers/video/ramfb.c
drivers/video/Kconfig +30 -0
index 69f4809cf4a6..6ab46107483e 100644
@@ -849,6 +849,36 @@ config VIDEO_MCDE_SIMPLE
 	  before u-boot starts, and u-boot will simply render to the pre-
 	  allocated frame buffer surface.
 
+config VIDEO_RAMFB
+	bool "QEMU ramfb display driver for in-RAM display"
+	depends on QFW
+	help
+	  Enables a RAM based simple frame buffer driver which uses qfw to
+	  notify the hypervisor about the location of a Frame Buffer allocated
+	  in guest RAM as well as its properties.
+
+if VIDEO_RAMFB
+
+config VIDEO_RAMFB_SIZE_X
+	int "Width of ramfb display (X resolution)"
+	default 1280
+	help
+	  Sets the width of the ramfb display.
+
+	  These two options control the size of the display set up by QEMU.
+	  Typical sizes are 1024 x 768 or 1280 x 1024.
+
+config VIDEO_RAMFB_SIZE_Y
+	int "Height of ramfb display (Y resolution)"
+	default 1024
+	help
+	  Sets the height of the ramfb display.
+
+	  These two options control the size of the display set up by QEMU.
+	  Typical sizes are 1024 x 768 or 1280 x 1024.
+
+endif
+
 config OSD
 	bool "Enable OSD support"
 	depends on DM
drivers/video/Makefile +1 -0
index d13af9f3b19b..775b4e46e600 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_VIDEO_SANDBOX_SDL) += sandbox_sdl.o
 obj-$(CONFIG_VIDEO_SIMPLE) += simplefb.o
 obj-$(CONFIG_VIDEO_VESA) += vesa.o
 obj-$(CONFIG_VIDEO_SEPS525) += seps525.o
+obj-$(CONFIG_VIDEO_RAMFB) += ramfb.o
 obj-$(CONFIG_VIDEO_ZYNQMP_DPSUB) += zynqmp/
 
 obj-y += bridge/
drivers/video/ramfb.c new file +97 -0

97 lines not on this page · raw message

include/qfw.h +10 -0
index d3aaa4d54efc..811abac6fd27 100644
@@ -142,6 +142,16 @@ struct bios_linker_entry {
 	};
 } __packed;
 
+/* ramfb configuration details to read into etc/ramfb fw_cfg file */
+struct ramfb_cfg {
+	__be64 addr;	/* Address of an allocated framebuffer */
+	__be32 fourcc;	/* Pixel format in Linux DRM fourcc code */
+	__be32 flags;	/* Unknown, appears unused */
+	__be32 width;	/* Width of the requested ramfb display */
+	__be32 height;	/* Height of the requested ramfb display */
+	__be32 stride;	/* Number of bytes per line? */
+} __packed;
+
 /* DMA transfer control data between UCLASS_QFW and QEMU. */
 struct qfw_dma {
 	__be32 control;
Signature · 1 line
2.40.1
Reviewed-by on v2 2/7
#3 lore raw

Re: [PATCH v2 2/7] ramfb: Add driver for ramfb display

Quoted 30 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

QEMU implements multiple ways to expose graphics output to the virt machine, but most of them are incompatible with hardware virtualization.

The one that does work reliably is ramfb. It's a very simple mechanism in which the guest reserves a memory region for the frame buffer and then notifies the host about its location and properties. The host then just displays the contents of the frame buffer on screen.

This patch implements a trivial version of a ramfb driver - hard coded to a single resolution set in Kconfig.

[Alper: Deduplicate depends on DM_VIDEO, drop MAINTAINERS, decouple from
EFI_LOADER, add .bind(), kconfigurable resolution, struct in .h]

---

Changes in v2:
- Remove extra "depends on DM_VIDEO" already in "if VIDEO"
- Drop drivers/video/MAINTAINERS file
- Decouple framebuffer allocation from EFI_LOADER
- Add .bind() method for ramfb driver
- Make resolution configurable with kconfig
- Move struct to qfw.h and add comments for members
- Use RAMFB_* definitions instead of DEFAULT_*

Quoted 6 lines
 drivers/video/Kconfig  | 30 +++++++++++++
 drivers/video/Makefile |  1 +
 drivers/video/ramfb.c  | 97 ++++++++++++++++++++++++++++++++++++++++++
 include/qfw.h          | 10 +++++
 4 files changed, 138 insertions(+)
 create mode 100644 drivers/video/ramfb.c
#4 lore raw

PATCH v2 3/7 qfw: Spawn ramfb device if its file is present

In reply to Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have a ramfb device driver, let's add the necessary glueing magic to also spawn it when we find its qfw file node.

[Alper: Use if IS_ENABLED() instead of #ifdef]

---

Changes in v2:
- Use if (IS_ENABLED(CONFIG_VIDEO_RAMFB)) instead of #ifdef

 drivers/misc/qfw.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/misc/qfw.c +24 -0
index 7c01bf23d53b..4e4260982cce 100644
@@ -16,6 +16,7 @@
 #include <malloc.h>
 #include <qfw.h>
 #include <dm.h>
+#include <dm/lists.h>
 #include <misc.h>
 #include <tables_csum.h>
 #include <asm/acpi_table.h>
@@ -307,6 +308,27 @@ void qfw_read_entry(struct udevice *dev, u16 entry, u32 size, void *address)
 		qfw_read_entry_io(qdev, entry, size, address);
 }
 
+static void qfw_bind_ramfb(struct udevice *dev)
+{
+	struct fw_file *file;
+	int ret;
+
+	if (!IS_ENABLED(CONFIG_VIDEO_RAMFB))
+		return;
+
+	ret = qfw_read_firmware_list(dev);
+	if (ret)
+		return;
+
+	file = qfw_find_file(dev, "etc/ramfb");
+	if (!file) {
+		/* No ramfb available. */
+		return;
+	}
+
+	device_bind_driver(dev, "ramfb", "qfw-ramfb", NULL);
+}
+
 int qfw_register(struct udevice *dev)
 {
 	struct qfw_dev *qdev = dev_get_uclass_priv(dev);
@@ -323,6 +345,8 @@ int qfw_register(struct udevice *dev)
 	if (dma_enabled & FW_CFG_DMA_ENABLED)
 		qdev->dma_present = true;
 
+	qfw_bind_ramfb(dev);
+
 	return 0;
 }
 
Signature · 1 line
2.40.1
#5 lore raw

Re: [PATCH v2 3/7] qfw: Spawn ramfb device if its file is present

Hi Alper,

Quoted 5 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have a ramfb device driver, let's add the necessary glueing magic to also spawn it when we find its qfw file node.

So then how do we select which video driver is used? I think we should have this in the DT so there is some control.

Quoted 25 lines
[Alper: Use if IS_ENABLED() instead of #ifdef]

---

Changes in v2:
- Use if (IS_ENABLED(CONFIG_VIDEO_RAMFB)) instead of #ifdef

 drivers/misc/qfw.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/misc/qfw.c +1 -0
index 7c01bf23d53b..4e4260982cce 100644
@@ -16,6 +16,7 @@
 #include <malloc.h>
 #include <qfw.h>
 #include <dm.h>
+#include <dm/lists.h>
 #include <misc.h>
 #include <tables_csum.h>
 #include <asm/acpi_table.h>

drivers/misc/qfw.c void qfw_read_entry(struct udevice *dev, u16 entry, u32 size, void *address) · line 317

Quoted 10 lines
drivers/misc/qfw.c +7 -0
@@ -307,6 +308,27 @@ void qfw_read_entry(struct udevice *dev, u16 entry, u32 size, void *address)
                qfw_read_entry_io(qdev, entry, size, address);
 }
 
+static void qfw_bind_ramfb(struct udevice *dev)
+{
+       struct fw_file *file;
+       int ret;
+
+       if (!IS_ENABLED(CONFIG_VIDEO_RAMFB))
+               return;

Needs an error-code return

drivers/misc/qfw.c void qfw_read_entry(struct udevice *dev, u16 entry, u32 size, void *address) · line 329

Quoted 12 lines
drivers/misc/qfw.c +12 -0
+
+       ret = qfw_read_firmware_list(dev);
+       if (ret)
+               return;
+
+       file = qfw_find_file(dev, "etc/ramfb");
+       if (!file) {
+               /* No ramfb available. */
+               return;
+       }
+
+       device_bind_driver(dev, "ramfb", "qfw-ramfb", NULL);

check error

Quoted 15 lines
drivers/misc/qfw.c +4 -1
+}
+
 int qfw_register(struct udevice *dev)
 {
        struct qfw_dev *qdev = dev_get_uclass_priv(dev);
@@ -323,6 +345,8 @@ int qfw_register(struct udevice *dev)
        if (dma_enabled & FW_CFG_DMA_ENABLED)
                qdev->dma_present = true;
 
+       qfw_bind_ramfb(dev);
+
        return 0;
 }
 
--
Quoted 2 lines

2.40.1

Regards,
Simon

#6 lore raw

Re: [PATCH v2 3/7] qfw: Spawn ramfb device if its file is present

Quoted 11 lines · Simon Glass

Hi Alper,

Quoted 5 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have a ramfb device driver, let's add the necessary glueing magic to also spawn it when we find its qfw file node.

So then how do we select which video driver is used? I think we should have this in the DT so there is some control.

I think you mean choosing between multiple potential video devices for a video console, but just in case: AFAIK only the ramfb driver can be used with -device ramfb, unlike how either vesa or bochs can be used for -device VGA.

This series is less about being able to use multiple video devices, but more about supporting by default different configurations in which QEMU can be launched: with "-device VGA" or "-vga none -device ramfb".

That being said, I had some success with multiple video console attempts. For "-device VGA -device ramfb", we need to make *addrp -= CONFIG_VAL(VIDEO_PCI_DEFAULT_FB_SIZE); unconditional in video_reserve()
to correctly allocate for both vesa and ramfb. Then we can run `env set
serial,vidconsole,vidconsole1` which sets up both video/vidconsole devices with same text content.

Regardless of this series, with VIDEO_PCI_DEFAULT_FB_SIZE=0x3000000 and "-device VGA -device VGA -device VGA" we get two broken and one empty display, and env set serial,vidconsole,vidconsole1,vidconsole2 puts a console to the third display. I think it's a bug the first two are broken, and it's initially using the first broken display as vidconsole.

Anyway, my opinion is: if stdout/stderr has "vidconsole", we should enable a vidconsole on all consoles, but if it has "vidconsole#" we should only enable the one on that video# device. Then device-tree could have /aliases { video0 = "..."; video1 = &...; } or something to have a stable order?

Or, you might mean adding a ramfb node to the device-tree, in which case that's going to reopen a can of OF_BOARD worms... (Same as what applies to putting bootph,* into qfw device-tree node, so I'll reply there.)

Quoted 12 lines

drivers/misc/qfw.c void qfw_read_entry(struct udevice *dev, u16 entry, u32 size, void *address) · line 317

Quoted 9 lines

[...]

drivers/misc/qfw.c +7 -0
+static void qfw_bind_ramfb(struct udevice *dev)
+{
+       struct fw_file *file;
+       int ret;
+
+       if (!IS_ENABLED(CONFIG_VIDEO_RAMFB))
+               return;

Needs an error-code return

Quoted 15 lines

drivers/misc/qfw.c void qfw_read_entry(struct udevice *dev, u16 entry, u32 size, void *address) · line 329

Quoted 12 lines
drivers/misc/qfw.c +12 -0
+
+       ret = qfw_read_firmware_list(dev);
+       if (ret)
+               return;
+
+       file = qfw_find_file(dev, "etc/ramfb");
+       if (!file) {
+               /* No ramfb available. */
+               return;
+       }
+
+       device_bind_driver(dev, "ramfb", "qfw-ramfb", NULL);

check error

Will try to fix both, thanks.

#7 lore raw

PATCH v2 4/7 qfw: Add flag to allow probing before relocation

In reply to Alper Nebi Yasak

QEMU firmware config drivers need to be probed to bind the ramfb device. The ramfb driver needs to be bound before relocation to properly reserve video memory for it, otherwise it cannot be probed after relocation. Add the flag to probe QEMU firmware config drivers before relocation so that ramfb can work as an initial vidconsole.

---
Alternatively, I guess I could default VIDEO_PCI_DEFAULT_FB_SIZE to a higher size with "if VIDEO_RAMFB". But it exists because "PCI drivers cannot be bound before relocation unless they are mentioned in the devicetree" and qfw is in the QEMU-generated devicetree unlike those, so I assumed this would be the preferred way.

Changes in v2:
- Add patch "qfw: Add flag to allow probing before relocation"

 drivers/misc/qfw.c         | 1 +
 drivers/misc/qfw_mmio.c    | 1 +
 drivers/misc/qfw_pio.c     | 1 +
 drivers/misc/qfw_sandbox.c | 1 +
 4 files changed, 4 insertions(+)
drivers/misc/qfw.c +1 -0
index 4e4260982cce..265f45290011 100644
@@ -414,6 +414,7 @@ UCLASS_DRIVER(qfw) = {
 	.name		= "qfw",
 	.post_bind	= qfw_post_bind,
 	.per_device_auto	= sizeof(struct qfw_dev),
+	.flags = DM_FLAG_PRE_RELOC,
 };
 
 struct bootdev_ops qfw_bootdev_ops = {
drivers/misc/qfw_mmio.c +1 -0
index f397384054a6..a5274982711c 100644
@@ -116,4 +116,5 @@ U_BOOT_DRIVER(qfw_mmio) = {
 	.of_to_plat	= qfw_mmio_of_to_plat,
 	.probe	= qfw_mmio_probe,
 	.ops	= &qfw_mmio_ops,
+	.flags = DM_FLAG_PRE_RELOC,
 };
drivers/misc/qfw_pio.c +1 -0
index e2f628d33830..dae809bd3fea 100644
@@ -66,4 +66,5 @@ U_BOOT_DRIVER(qfw_pio) = {
 	.id	= UCLASS_QFW,
 	.probe	= qfw_pio_probe,
 	.ops	= &qfw_pio_ops,
+	.flags = DM_FLAG_PRE_RELOC,
 };
drivers/misc/qfw_sandbox.c +1 -0
index 1002df75339e..0bd36acd1a09 100644
@@ -120,6 +120,7 @@ U_BOOT_DRIVER(qfw_sandbox) = {
 	.plat_auto	= sizeof(struct qfw_sandbox_plat),
 	.probe	= qfw_sandbox_probe,
 	.ops	= &qfw_sandbox_ops,
+	.flags = DM_FLAG_PRE_RELOC,
 };
 
 U_BOOT_DRVINFO(qfw_sandbox) = {
Signature · 1 line
2.40.1
#8 lore raw

Re: [PATCH v2 4/7] qfw: Add flag to allow probing before relocation

Hi Alper,

Quoted 29 lines · Alper Nebi Yasak

QEMU firmware config drivers need to be probed to bind the ramfb device. The ramfb driver needs to be bound before relocation to properly reserve video memory for it, otherwise it cannot be probed after relocation. Add the flag to probe QEMU firmware config drivers before relocation so that ramfb can work as an initial vidconsole.

---
Alternatively, I guess I could default VIDEO_PCI_DEFAULT_FB_SIZE to a higher size with "if VIDEO_RAMFB". But it exists because "PCI drivers cannot be bound before relocation unless they are mentioned in the devicetree" and qfw is in the QEMU-generated devicetree unlike those, so I assumed this would be the preferred way.

Changes in v2:
- Add patch "qfw: Add flag to allow probing before relocation"

 drivers/misc/qfw.c         | 1 +
 drivers/misc/qfw_mmio.c    | 1 +
 drivers/misc/qfw_pio.c     | 1 +
 drivers/misc/qfw_sandbox.c | 1 +
 4 files changed, 4 insertions(+)
drivers/misc/qfw.c +0 -0
index 4e4260982cce..265f45290011 100644

drivers/misc/qfw.c UCLASS_DRIVER(qfw) = { · line 418

Quoted 5 lines
drivers/misc/qfw.c +1 -0
@@ -414,6 +414,7 @@ UCLASS_DRIVER(qfw) = {
        .name           = "qfw",
        .post_bind      = qfw_post_bind,
        .per_device_auto        = sizeof(struct qfw_dev),
+       .flags = DM_FLAG_PRE_RELOC,
 };

Should we add this to the DT instead?

In the case where it isn't present it can return -EPERM.

Regards,
Simon

#9 lore raw

Re: [PATCH v2 4/7] qfw: Add flag to allow probing before relocation

Quoted 27 lines · Simon Glass

Hi Alper,

Quoted 24 lines · Alper Nebi Yasak

QEMU firmware config drivers need to be probed to bind the ramfb device. The ramfb driver needs to be bound before relocation to properly reserve video memory for it, otherwise it cannot be probed after relocation. Add the flag to probe QEMU firmware config drivers before relocation so that ramfb can work as an initial vidconsole.

---
Alternatively, I guess I could default VIDEO_PCI_DEFAULT_FB_SIZE to a higher size with "if VIDEO_RAMFB". But it exists because "PCI drivers cannot be bound before relocation unless they are mentioned in the devicetree" and qfw is in the QEMU-generated devicetree unlike those, so I assumed this would be the preferred way.

Changes in v2:
- Add patch "qfw: Add flag to allow probing before relocation"

 drivers/misc/qfw.c         | 1 +
 drivers/misc/qfw_mmio.c    | 1 +
 drivers/misc/qfw_pio.c     | 1 +
 drivers/misc/qfw_sandbox.c | 1 +
 4 files changed, 4 insertions(+)
Quoted 12 lines

drivers/misc/qfw.c UCLASS_DRIVER(qfw) = { · line 418

Quoted 10 lines
drivers/misc/qfw.c +1 -0
index 4e4260982cce..265f45290011 100644
@@ -414,6 +414,7 @@ UCLASS_DRIVER(qfw) = {
        .name           = "qfw",
        .post_bind      = qfw_post_bind,
        .per_device_auto        = sizeof(struct qfw_dev),
+       .flags = DM_FLAG_PRE_RELOC,
 };

Should we add this to the DT instead?

I've experimented a bit, and got something that works nice on x86 because we have the device-trees in-tree. So I can add something to arch/x86/dts/qemu-*.dts like:

    / {
        fw-cfg {
            compatible = "qemu,fw-cfg-pio";
            bootph-some-ram;

            qfw-ramfb {
                compatible = "qemu,qfw-ramfb";
                bootph-some-ram;
            };
        };
    };

Then add the compatibles as .of_match to qfw_pio and ramfb drivers, call dm_scan_fdt_dev(dev) in qfw_post_bind(), merge qfw_bind_ramfb() into the ramfb driver probe, and it will work without the board_early_init_[fr] hooks or these flags. That all seems to be fine.

The problem is other arches where QEMU generates a device-tree at runtime and passes it to U-Boot with OF_BOARD. It has, on arm64 (and with @10100000 instead on riscv64):

    fw-cfg@9020000 {
        dma-coherent;
        reg = <0x00 0x9020000 0x00 0x18>;
        compatible = "qemu,fw-cfg-mmio";
    };

As a proof of concept, I used qemu-system-* -M dumpdtb=file.dtb and dtc -I dtb -O dts to replace the empty qemu dts files, then set OF_BOARD=n and OF_OMIT_DTB=n, and added similar modifications to qemu-*-u-boot.dtsi. And everything seems fine like that as well.

I think it can be automated in Makefile, but I don't think disabling OF_BOARD is right here. I see there's OF_BOARD_FIXUP, so I guess I'll try finding the fw-cfg node there and adding the bootph props and ramfb nodes... Is this going the right way?

(And the pio/ramfb compatibles don't exist, do we have to use u-boot,*?)

Quoted 4 lines

In the case where it isn't present it can return -EPERM.

Regards,
Simon

#10 lore raw

Re: [PATCH v2 4/7] qfw: Add flag to allow probing before relocation

Quoted 77 lines · Alper Nebi Yasak
Quoted 27 lines · Simon Glass

Hi Alper,

Quoted 24 lines · Alper Nebi Yasak

QEMU firmware config drivers need to be probed to bind the ramfb device. The ramfb driver needs to be bound before relocation to properly reserve video memory for it, otherwise it cannot be probed after relocation. Add the flag to probe QEMU firmware config drivers before relocation so that ramfb can work as an initial vidconsole.

---
Alternatively, I guess I could default VIDEO_PCI_DEFAULT_FB_SIZE to a higher size with "if VIDEO_RAMFB". But it exists because "PCI drivers cannot be bound before relocation unless they are mentioned in the devicetree" and qfw is in the QEMU-generated devicetree unlike those, so I assumed this would be the preferred way.

Changes in v2:
- Add patch "qfw: Add flag to allow probing before relocation"

 drivers/misc/qfw.c         | 1 +
 drivers/misc/qfw_mmio.c    | 1 +
 drivers/misc/qfw_pio.c     | 1 +
 drivers/misc/qfw_sandbox.c | 1 +
 4 files changed, 4 insertions(+)
Quoted 12 lines

drivers/misc/qfw.c UCLASS_DRIVER(qfw) = { · line 418

Quoted 10 lines
drivers/misc/qfw.c +1 -0
index 4e4260982cce..265f45290011 100644
@@ -414,6 +414,7 @@ UCLASS_DRIVER(qfw) = {
        .name           = "qfw",
        .post_bind      = qfw_post_bind,
        .per_device_auto        = sizeof(struct qfw_dev),
+       .flags = DM_FLAG_PRE_RELOC,
 };

Should we add this to the DT instead?

I've experimented a bit, and got something that works nice on x86 because we have the device-trees in-tree. So I can add something to arch/x86/dts/qemu-*.dts like:

    / {
        fw-cfg {
            compatible = "qemu,fw-cfg-pio";
            bootph-some-ram;

            qfw-ramfb {
                compatible = "qemu,qfw-ramfb";
                bootph-some-ram;
            };
        };
    };

Then add the compatibles as .of_match to qfw_pio and ramfb drivers, call dm_scan_fdt_dev(dev) in qfw_post_bind(), merge qfw_bind_ramfb() into the ramfb driver probe, and it will work without the board_early_init_[fr] hooks or these flags. That all seems to be fine.

The problem is other arches where QEMU generates a device-tree at runtime and passes it to U-Boot with OF_BOARD. It has, on arm64 (and with @10100000 instead on riscv64):

    fw-cfg@9020000 {
        dma-coherent;
        reg = <0x00 0x9020000 0x00 0x18>;
        compatible = "qemu,fw-cfg-mmio";
    };

As a proof of concept, I used qemu-system-* -M dumpdtb=file.dtb and dtc -I dtb -O dts to replace the empty qemu dts files, then set OF_BOARD=n and OF_OMIT_DTB=n, and added similar modifications to qemu-*-u-boot.dtsi. And everything seems fine like that as well.

Quoted 6 lines

I think it can be automated in Makefile, but I don't think disabling OF_BOARD is right here. I see there's OF_BOARD_FIXUP, so I guess I'll try finding the fw-cfg node there and adding the bootph props and ramfb nodes... Is this going the right way?

(And the pio/ramfb compatibles don't exist, do we have to use u-boot,*?)

This seems like a whole lot of work to avoid using the flags mechanism that we have, intentionally.

Signature · 1 line
Tom
#11 lore raw

PATCH v2 5/7 arm: qemu: Enable ramfb by default

In reply to Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the ARM QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init, error handling]

---

Changes in v2:
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU

 arch/arm/Kconfig                    |  3 +++
 board/emulation/qemu-arm/qemu-arm.c | 41 +++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
arch/arm/Kconfig +3 -0
index 1fd3ccd1607f..7afe26ac804f 100644
@@ -1046,6 +1046,9 @@ config ARCH_QEMU
 	imply USB_XHCI_PCI
 	imply USB_KEYBOARD
 	imply CMD_USB
+	imply VIDEO_RAMFB
+	imply BOARD_EARLY_INIT_F
+	imply BOARD_EARLY_INIT_R
 
 config ARCH_RMOBILE
 	bool "Renesas ARM SoCs"
board/emulation/qemu-arm/qemu-arm.c +41 -0

53 lines not on this page · raw message

Signature · 1 line
2.40.1
#12 lore raw

Re: [PATCH v2 5/7] arm: qemu: Enable ramfb by default

Hi Alper,

Quoted 57 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the ARM QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init, error handling]

---

Changes in v2:
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU

 arch/arm/Kconfig                    |  3 +++
 board/emulation/qemu-arm/qemu-arm.c | 41 +++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
arch/arm/Kconfig +3 -0
index 1fd3ccd1607f..7afe26ac804f 100644
@@ -1046,6 +1046,9 @@ config ARCH_QEMU
        imply USB_XHCI_PCI
        imply USB_KEYBOARD
        imply CMD_USB
+       imply VIDEO_RAMFB
+       imply BOARD_EARLY_INIT_F
+       imply BOARD_EARLY_INIT_R
 
 config ARCH_RMOBILE
        bool "Renesas ARM SoCs"
board/emulation/qemu-arm/qemu-arm.c +4 -0
index 942f1fff5717..23ef31cb7feb 100644
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <init.h>
 #include <log.h>
+#include <qfw.h>
 #include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
@@ -102,6 +103,46 @@ static struct mm_region qemu_arm64_mem_map[] = {
 struct mm_region *mem_map = qemu_arm64_mem_map;
 #endif
 
+int board_early_init_f(void)
+{
+       struct udevice *dev;

board/emulation/qemu-arm/qemu-arm.c static struct mm_region qemu_arm64_mem_map[] = { · line 118

Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10 -0
+       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);

We should only present an error if the device is present but failed...so if the user doesn't provide the flag, all should be well.

Quoted 31 lines
board/emulation/qemu-arm/qemu-arm.c +27 -1
+                       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;
+}
+
 int board_init(void)
 {
        return 0;
--
Quoted 2 lines

2.40.1

The glue here feels like a bit of a hack...we should rely on normal DT mechanisms here.

Regards,
Simon

#13 lore raw

Re: [PATCH v2 5/7] arm: qemu: Enable ramfb by default

Quoted 57 lines · Simon Glass

Hi Alper,

Quoted 54 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the ARM QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init, error handling]

---

Changes in v2:
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU

 arch/arm/Kconfig                    |  3 +++
 board/emulation/qemu-arm/qemu-arm.c | 41 +++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
arch/arm/Kconfig +3 -0
index 1fd3ccd1607f..7afe26ac804f 100644
@@ -1046,6 +1046,9 @@ config ARCH_QEMU
        imply USB_XHCI_PCI
        imply USB_KEYBOARD
        imply CMD_USB
+       imply VIDEO_RAMFB
+       imply BOARD_EARLY_INIT_F
+       imply BOARD_EARLY_INIT_R
 
 config ARCH_RMOBILE
        bool "Renesas ARM SoCs"
board/emulation/qemu-arm/qemu-arm.c +1 -0
index 942f1fff5717..23ef31cb7feb 100644
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <init.h>
 #include <log.h>
+#include <qfw.h>
 #include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
@@ -102,6 +103,46 @@ static struct mm_region qemu_arm64_mem_map[] = {
 struct mm_region *mem_map = qemu_arm64_mem_map;
 #endif
 
Quoted 16 lines

board/emulation/qemu-arm/qemu-arm.c static struct mm_region qemu_arm64_mem_map[] = { · line 118

Quoted 13 lines
board/emulation/qemu-arm/qemu-arm.c +13 -0
+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);

We should only present an error if the device is present but failed...so if the user doesn't provide the flag, all should be well.

I don't understand what you mean by "user doesn't provide the flag". But I assume this should ignore the error (unless what?) so that we can continue to boot. Would that apply for board_early_init_r below as well?

Quoted 39 lines
Quoted 31 lines
board/emulation/qemu-arm/qemu-arm.c +27 -1
+                       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;
+}
+
 int board_init(void)
 {
        return 0;
--
Quoted 2 lines

2.40.1

The glue here feels like a bit of a hack...we should rely on normal DT mechanisms here.

Regards,
Simon

#14 lore raw

Re: [PATCH v2 5/7] arm: qemu: Enable ramfb by default

Hi Alper,

Quoted 76 lines · Alper Nebi Yasak
Quoted 57 lines · Simon Glass

Hi Alper,

Quoted 54 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the ARM QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init, error handling]

---

Changes in v2:
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU

 arch/arm/Kconfig                    |  3 +++
 board/emulation/qemu-arm/qemu-arm.c | 41 +++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
arch/arm/Kconfig +3 -0
index 1fd3ccd1607f..7afe26ac804f 100644
@@ -1046,6 +1046,9 @@ config ARCH_QEMU
        imply USB_XHCI_PCI
        imply USB_KEYBOARD
        imply CMD_USB
+       imply VIDEO_RAMFB
+       imply BOARD_EARLY_INIT_F
+       imply BOARD_EARLY_INIT_R
 
 config ARCH_RMOBILE
        bool "Renesas ARM SoCs"
board/emulation/qemu-arm/qemu-arm.c +1 -0
index 942f1fff5717..23ef31cb7feb 100644
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <init.h>
 #include <log.h>
+#include <qfw.h>
 #include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
@@ -102,6 +103,46 @@ static struct mm_region qemu_arm64_mem_map[] = {
 struct mm_region *mem_map = qemu_arm64_mem_map;
 #endif
 
Quoted 16 lines

board/emulation/qemu-arm/qemu-arm.c static struct mm_region qemu_arm64_mem_map[] = { · line 118

Quoted 13 lines
board/emulation/qemu-arm/qemu-arm.c +13 -0
+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);

We should only present an error if the device is present but failed...so if the user doesn't provide the flag, all should be well.

Quoted 3 lines

I don't understand what you mean by "user doesn't provide the flag". But I assume this should ignore the error (unless what?) so that we can continue to boot. Would that apply for board_early_init_r below as well?

I thought you said there was a qemu flag to enable ramfb? So add it to the DT and then the device can (in its bind routine) decide not to be bound by returning -ENODEV

Quoted 38 lines
Quoted 38 lines
Quoted 32 lines
board/emulation/qemu-arm/qemu-arm.c +27 -1
+                       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;
+}
+
 int board_init(void)
 {
        return 0;
--
Quoted 2 lines

2.40.1

The glue here feels like a bit of a hack...we should rely on normal DT mechanisms here.

Quoted 2 lines
Quoted 2 lines

Regards,
Simon

Regards.

Simon

#15 lore raw

Re: [PATCH v2 5/7] arm: qemu: Enable ramfb by default

Quoted 78 lines · Simon Glass

Hi Alper,

Quoted 76 lines · Alper Nebi Yasak
Quoted 73 lines · Simon Glass

Hi Alper,

Quoted 57 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the ARM QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init, error handling]

---

Changes in v2:
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU

 arch/arm/Kconfig                    |  3 +++
 board/emulation/qemu-arm/qemu-arm.c | 41 +++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
arch/arm/Kconfig +3 -0
index 1fd3ccd1607f..7afe26ac804f 100644
@@ -1046,6 +1046,9 @@ config ARCH_QEMU
        imply USB_XHCI_PCI
        imply USB_KEYBOARD
        imply CMD_USB
+       imply VIDEO_RAMFB
+       imply BOARD_EARLY_INIT_F
+       imply BOARD_EARLY_INIT_R
 
 config ARCH_RMOBILE
        bool "Renesas ARM SoCs"
board/emulation/qemu-arm/qemu-arm.c +4 -0
index 942f1fff5717..23ef31cb7feb 100644
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <init.h>
 #include <log.h>
+#include <qfw.h>
 #include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
@@ -102,6 +103,46 @@ static struct mm_region qemu_arm64_mem_map[] = {
 struct mm_region *mem_map = qemu_arm64_mem_map;
 #endif
 
+int board_early_init_f(void)
+{
+       struct udevice *dev;

board/emulation/qemu-arm/qemu-arm.c static struct mm_region qemu_arm64_mem_map[] = { · line 118

Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10 -0
+       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);

We should only present an error if the device is present but failed...so if the user doesn't provide the flag, all should be well.

Quoted 7 lines
Quoted 3 lines

I don't understand what you mean by "user doesn't provide the flag". But I assume this should ignore the error (unless what?) so that we can continue to boot. Would that apply for board_early_init_r below as well?

I thought you said there was a qemu flag to enable ramfb? So add it to the DT and then the device can (in its bind routine) decide not to be bound by returning -ENODEV

Ah. I'm not used to calling them flags, especially those that have values as in "-device ramfb". My mind jumped to DM_FLAG_PRE_RELOC / bootph-some-ram.

But note that what this code tries to probe here is not the ramfb device, it's the bus/parent of that. If this fails, we can't know if the user specified "-device ramfb" or not.

Is the parent node's device probed by the time .bind() is called? Or, can I have it probed by calling qfw_get_dev() (which is just uclass_first_device_err(UCLASS_QFW, ...))?

#16 lore raw

Re: [PATCH v2 5/7] arm: qemu: Enable ramfb by default

Quoted 81 lines · Alper Nebi Yasak
Quoted 74 lines · Simon Glass

Hi Alper,

Quoted 72 lines · Alper Nebi Yasak
Quoted 71 lines · Simon Glass

Hi Alper,

Quoted 56 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the ARM QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init, error handling]

---

Changes in v2:
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU

  arch/arm/Kconfig                    |  3 +++
  board/emulation/qemu-arm/qemu-arm.c | 41 +++++++++++++++++++++++++++++
  2 files changed, 44 insertions(+)
arch/arm/Kconfig +3 -0
index 1fd3ccd1607f..7afe26ac804f 100644
@@ -1046,6 +1046,9 @@ config ARCH_QEMU
         imply USB_XHCI_PCI
         imply USB_KEYBOARD
         imply CMD_USB
+       imply VIDEO_RAMFB
+       imply BOARD_EARLY_INIT_F
+       imply BOARD_EARLY_INIT_R
 
  config ARCH_RMOBILE
         bool "Renesas ARM SoCs"
board/emulation/qemu-arm/qemu-arm.c +4 -0
index 942f1fff5717..23ef31cb7feb 100644
@@ -11,6 +11,7 @@
  #include <fdtdec.h>
  #include <init.h>
  #include <log.h>
+#include <qfw.h>
  #include <usb.h>
  #include <virtio_types.h>
  #include <virtio.h>
@@ -102,6 +103,46 @@ static struct mm_region qemu_arm64_mem_map[] = {
  struct mm_region *mem_map = qemu_arm64_mem_map;
  #endif
 
+int board_early_init_f(void)
+{
+       struct udevice *dev;

board/emulation/qemu-arm/qemu-arm.c static struct mm_region qemu_arm64_mem_map[] = { · line 118

Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10 -0
+       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);

We should only present an error if the device is present but failed...so if the user doesn't provide the flag, all should be well.

Quoted 6 lines
Quoted 3 lines

I don't understand what you mean by "user doesn't provide the flag". But I assume this should ignore the error (unless what?) so that we can continue to boot. Would that apply for board_early_init_r below as well?

I thought you said there was a qemu flag to enable ramfb? So add it to the DT and then the device can (in its bind routine) decide not to be bound by returning -ENODEV

Quoted 7 lines

Ah. I'm not used to calling them flags, especially those that have values as in "-device ramfb". My mind jumped to DM_FLAG_PRE_RELOC / bootph-some-ram.

But note that what this code tries to probe here is not the ramfb device, it's the bus/parent of that. If this fails, we can't know if the user specified "-device ramfb" or not.

You bring up a great point here. I don't think we should model the actual ramfb device as device tree (platform) device. It's 100% enumerable from QFW which means we should treat it as a dynamic entity that gets created by QFW instead of from device tree, just like USB or PCI devices.

And when you do that, everything should fall into place nicely: You don't need to dynamically modify device trees on boot, the DT you get from QEMU is sufficient to enumerate everything, etc etc.

Alex

#17 lore raw

Re: [PATCH v2 5/7] arm: qemu: Enable ramfb by default

In reply to Alper Nebi Yasak

Hi Alper,

Quoted 92 lines · Alper Nebi Yasak
Quoted 78 lines · Simon Glass

Hi Alper,

Quoted 76 lines · Alper Nebi Yasak
Quoted 73 lines · Simon Glass

Hi Alper,

Quoted 57 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the ARM QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init, error handling]

---

Changes in v2:
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU

 arch/arm/Kconfig                    |  3 +++
 board/emulation/qemu-arm/qemu-arm.c | 41 +++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
arch/arm/Kconfig +3 -0
index 1fd3ccd1607f..7afe26ac804f 100644
@@ -1046,6 +1046,9 @@ config ARCH_QEMU
        imply USB_XHCI_PCI
        imply USB_KEYBOARD
        imply CMD_USB
+       imply VIDEO_RAMFB
+       imply BOARD_EARLY_INIT_F
+       imply BOARD_EARLY_INIT_R
 
 config ARCH_RMOBILE
        bool "Renesas ARM SoCs"
board/emulation/qemu-arm/qemu-arm.c +4 -0
index 942f1fff5717..23ef31cb7feb 100644
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <init.h>
 #include <log.h>
+#include <qfw.h>
 #include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
@@ -102,6 +103,46 @@ static struct mm_region qemu_arm64_mem_map[] = {
 struct mm_region *mem_map = qemu_arm64_mem_map;
 #endif
 
+int board_early_init_f(void)
+{
+       struct udevice *dev;

board/emulation/qemu-arm/qemu-arm.c static struct mm_region qemu_arm64_mem_map[] = { · line 118

Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10 -0
+       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);

We should only present an error if the device is present but failed...so if the user doesn't provide the flag, all should be well.

Quoted 7 lines
Quoted 3 lines

I don't understand what you mean by "user doesn't provide the flag". But I assume this should ignore the error (unless what?) so that we can continue to boot. Would that apply for board_early_init_r below as well?

I thought you said there was a qemu flag to enable ramfb? So add it to the DT and then the device can (in its bind routine) decide not to be bound by returning -ENODEV

Ah. I'm not used to calling them flags, especially those that have values as in "-device ramfb". My mind jumped to DM_FLAG_PRE_RELOC / bootph-some-ram.

Quoted 7 lines

But note that what this code tries to probe here is not the ramfb device, it's the bus/parent of that. If this fails, we can't know if the user specified "-device ramfb" or not.

Is the parent node's device probed by the time .bind() is called? Or, can I have it probed by calling qfw_get_dev() (which is just uclass_first_device_err(UCLASS_QFW, ...))?

I suppose your problem might be that there are up to three possible video devices (vesa, bochs, ramfb) and one of them needs to return 0 from bind() and the others need to return -ENODEV?

Perhaps another way would be to update the logic in stdio_init_tables() to find them all (which I believe it already does?) and then select one?

Regards,
Simon

#18 lore raw

Re: [PATCH v2 5/7] arm: qemu: Enable ramfb by default

Quoted 92 lines · Simon Glass

Hi Alper,

Quoted 89 lines · Alper Nebi Yasak
Quoted 74 lines · Simon Glass

Hi Alper,

Quoted 72 lines · Alper Nebi Yasak
Quoted 71 lines · Simon Glass

Hi Alper,

Quoted 56 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the ARM QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init, error handling]

---

Changes in v2:
- Rebase on "qemu: arm: Enable Bochs, console buffering, USB keyboard"
- Drop env changes from ARM (necessary but in prerequisite series)
- Drop imply VIDEO, SYS_CONSOLE_IN_ENV changes from ARM (in prereq.)
- Probe QFW in ARM QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to ARM QEMU

  arch/arm/Kconfig                    |  3 +++
  board/emulation/qemu-arm/qemu-arm.c | 41 +++++++++++++++++++++++++++++
  2 files changed, 44 insertions(+)
arch/arm/Kconfig +3 -0
index 1fd3ccd1607f..7afe26ac804f 100644
@@ -1046,6 +1046,9 @@ config ARCH_QEMU
         imply USB_XHCI_PCI
         imply USB_KEYBOARD
         imply CMD_USB
+       imply VIDEO_RAMFB
+       imply BOARD_EARLY_INIT_F
+       imply BOARD_EARLY_INIT_R
 
  config ARCH_RMOBILE
         bool "Renesas ARM SoCs"
board/emulation/qemu-arm/qemu-arm.c +4 -0
index 942f1fff5717..23ef31cb7feb 100644
@@ -11,6 +11,7 @@
  #include <fdtdec.h>
  #include <init.h>
  #include <log.h>
+#include <qfw.h>
  #include <usb.h>
  #include <virtio_types.h>
  #include <virtio.h>
@@ -102,6 +103,46 @@ static struct mm_region qemu_arm64_mem_map[] = {
  struct mm_region *mem_map = qemu_arm64_mem_map;
  #endif
 
+int board_early_init_f(void)
+{
+       struct udevice *dev;

board/emulation/qemu-arm/qemu-arm.c static struct mm_region qemu_arm64_mem_map[] = { · line 118

Quoted 10 lines
board/emulation/qemu-arm/qemu-arm.c +10 -0
+       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);

We should only present an error if the device is present but failed...so if the user doesn't provide the flag, all should be well.

Quoted 6 lines
Quoted 3 lines

I don't understand what you mean by "user doesn't provide the flag". But I assume this should ignore the error (unless what?) so that we can continue to boot. Would that apply for board_early_init_r below as well?

I thought you said there was a qemu flag to enable ramfb? So add it to the DT and then the device can (in its bind routine) decide not to be bound by returning -ENODEV

Ah. I'm not used to calling them flags, especially those that have values as in "-device ramfb". My mind jumped to DM_FLAG_PRE_RELOC / bootph-some-ram.

But note that what this code tries to probe here is not the ramfb device, it's the bus/parent of that. If this fails, we can't know if the user specified "-device ramfb" or not.

Quoted 6 lines
Quoted 3 lines

Is the parent node's device probed by the time .bind() is called? Or, can I have it probed by calling qfw_get_dev() (which is just uclass_first_device_err(UCLASS_QFW, ...))?

I suppose your problem might be that there are up to three possible video devices (vesa, bochs, ramfb) and one of them needs to return 0 from bind() and the others need to return -ENODEV?

How do multiple Legacy VGA devices work in parallel in the first place? Do we access the legacy VGA PIO ports or memory ranges? If so, which of the VGA devices owns it at which point in time?

IIRC the only way you can actually multiplex real VGA is by putting a VGA arbiter[1] in between that literally maps the BARs in and out or enables/disables device mapping dynamically, no?

It probably makes most sense to make multiple video outputs work smoothly with at most 1 VGA device at a time for now to resolve any U-Boot internal infrastructure problems, then maybe later try multiple VGAs.

Alex

[1] https://docs.kernel.org/gpu/vgaarbiter.html

#19 lore raw

PATCH v2 6/7 riscv: qemu: Enable ramfb by default

In reply to Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the RISC-V QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init and error handling]

---

Changes in v2:
- Drop imply VIDEO, env changes from RISC-V patch (in u-boot/next)
- Drop imply SYS_CONSOLE_IS_IN_ENV from RISC-V patch (def. y if VIDEO)
- Probe QFW in RISC-V QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to RISC-V QEMU

 board/emulation/qemu-riscv/Kconfig      |  5 +++
 board/emulation/qemu-riscv/qemu-riscv.c | 41 +++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
board/emulation/qemu-riscv/Kconfig +5 -0
index d56b4b5bc1ed..b5c72982e565 100644
@@ -82,5 +82,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply USB_XHCI_PCI
 	imply USB_KEYBOARD
 	imply CMD_USB
+	imply BOARD_EARLY_INIT_F
+	imply BOARD_EARLY_INIT_R
+	imply VIDEO_RAMFB
+	imply CMD_QFW
+	imply QFW_MMIO
 
 endif
board/emulation/qemu-riscv/qemu-riscv.c +41 -0

53 lines not on this page · raw message

Signature · 1 line
2.40.1
#20 lore raw

Re: [PATCH v2 6/7] riscv: qemu: Enable ramfb by default

Hi Alper,

Quoted 19 lines · Alper Nebi Yasak

From: Alexander Graf <[email protected]>

Now that we have everything in place to support ramfb, let's wire it up by default in the RISC-V QEMU targets. That way, you can easily use a graphical console by just passing -device ramfb to the QEMU command line.

[Alper: Rebase on bochs changes, add pre-reloc init and error handling]

---

Changes in v2:
- Drop imply VIDEO, env changes from RISC-V patch (in u-boot/next)
- Drop imply SYS_CONSOLE_IS_IN_ENV from RISC-V patch (def. y if VIDEO)
- Probe QFW in RISC-V QEMU board_early_init_f to bind ramfb pre-reloc
- Add IS_ENABLED(CONFIG_QFW) check and error handling to RISC-V QEMU

Quoted 3 lines
 board/emulation/qemu-riscv/Kconfig      |  5 +++
 board/emulation/qemu-riscv/qemu-riscv.c | 41 +++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

Again, please investigate DT mechanism which will work for all archs.

Regards,
Simon

#21 lore raw

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

In reply to Alper Nebi Yasak

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.

---
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/[email protected]/

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(-)
arch/x86/cpu/qemu/Kconfig +4 -0
index f8f2f6473088..e0a57ac2d687 100644
@@ -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
 
board/emulation/qemu-x86/qemu-x86.c +47 -0

47 lines not on this page · raw message

configs/qemu-x86_64_defconfig +1 -3
index c6f30674a8fc..c9ad6eebd35c 100644
@@ -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
configs/qemu-x86_defconfig +0 -1
index 24682a5387df..8a2311720f02 100644
@@ -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
Signature · 1 line
2.40.1
#22 lore raw

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

Hi Alper,

Quoted 10 lines · Alper Nebi Yasak

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.

Quoted 5 lines

---
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*.

Yes I see that problem too. I wonder how we can debug it?

Quoted 4 lines

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.

Indeed...which makes me wonder if we can do something similar with Bochs, so that (from the cmdline) it is possible to chose ramfb, bochs or vesa?

Quoted 48 lines

[1] https://lore.kernel.org/u-boot/[email protected]/

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(-)
arch/x86/cpu/qemu/Kconfig +4 -0
index f8f2f6473088..e0a57ac2d687 100644
@@ -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
 
board/emulation/qemu-x86/qemu-x86.c +16 -0
index e69de29bb2d1..3a8a580cc591 100644
@@ -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.

board/emulation/qemu-x86/qemu-x86.c line 26

Quoted 10 lines
board/emulation/qemu-x86/qemu-x86.c +10 -0
+        */
+       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;

Same point about DT here.

Quoted 41 lines
board/emulation/qemu-x86/qemu-x86.c +21 -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;
+}
configs/qemu-x86_64_defconfig +1 -2
index c6f30674a8fc..c9ad6eebd35c 100644
@@ -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

configs/qemu-x86_64_defconfig CONFIG_CMD_USB=y · line 62

Quoted 4 lines
configs/qemu-x86_64_defconfig +0 -1
@@ -59,7 +58,6 @@ CONFIG_CMD_USB=y
 CONFIG_BOOTP_BOOTFILESIZE=y
 CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
-CONFIG_CMD_QFW=y

What is happening here? Why disable it?

Quoted 16 lines
configs/qemu-x86_64_defconfig +0 -0
 CONFIG_CMD_BOOTSTAGE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_ENV_OVERWRITE=y
configs/qemu-x86_defconfig +0 -2
index 24682a5387df..8a2311720f02 100644
@@ -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
--
Quoted 2 lines

2.40.1

Regards,
Simon

#23 lore raw

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

Quoted 13 lines · Simon Glass

Hi Alper,

Quoted 10 lines · Alper Nebi Yasak

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.

Quoted 7 lines
Quoted 5 lines

---
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*.

Yes I see that problem too. I wonder how we can debug it?

No idea, and I couldn't find a good commit to bisect from, tried as far back as v2021.10.

Quoted 7 lines
Quoted 3 lines

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.

Indeed...which makes me wonder if we can do something similar with Bochs, so that (from the cmdline) it is possible to chose ramfb, bochs or vesa?

(Tried to answer video choice and DT concerns in another mail)

Quoted 28 lines
Quoted 28 lines

[1] https://lore.kernel.org/u-boot/[email protected]/

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(-)
arch/x86/cpu/qemu/Kconfig +4 -0
index f8f2f6473088..e0a57ac2d687 100644
@@ -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
 
[...]
Quoted 7 lines

arch/x86/cpu/qemu/Kconfig CONFIG_CMD_USB=y · line 62

Quoted 5 lines
arch/x86/cpu/qemu/Kconfig +0 -1
@@ -59,7 +58,6 @@ CONFIG_CMD_USB=y
 CONFIG_BOOTP_BOOTFILESIZE=y
 CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
-CONFIG_CMD_QFW=y

What is happening here? Why disable it?

I used imply CMD_QFW above to be consistent with previous patches, so it's no longer necessary in defconfigs. Should I drop the imply and keep these in defconfig?

#24 lore raw

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

Quoted 71 lines · Alper Nebi Yasak
Quoted 13 lines · Simon Glass

Hi Alper,

Quoted 10 lines · Alper Nebi Yasak

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.

Quoted 7 lines
Quoted 5 lines

---
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*.

Yes I see that problem too. I wonder how we can debug it?

No idea, and I couldn't find a good commit to bisect from, tried as far back as v2021.10.

Quoted 7 lines
Quoted 3 lines

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.

Indeed...which makes me wonder if we can do something similar with Bochs, so that (from the cmdline) it is possible to chose ramfb, bochs or vesa?

(Tried to answer video choice and DT concerns in another mail)

Quoted 28 lines
Quoted 28 lines

[1] https://lore.kernel.org/u-boot/[email protected]/

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(-)
arch/x86/cpu/qemu/Kconfig +4 -0
index f8f2f6473088..e0a57ac2d687 100644
@@ -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
 
[...]
Quoted 7 lines

arch/x86/cpu/qemu/Kconfig CONFIG_CMD_USB=y · line 62

Quoted 5 lines
arch/x86/cpu/qemu/Kconfig +0 -1
@@ -59,7 +58,6 @@ CONFIG_CMD_USB=y
 CONFIG_BOOTP_BOOTFILESIZE=y
 CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
-CONFIG_CMD_QFW=y

What is happening here? Why disable it?

Quoted 3 lines

I used imply CMD_QFW above to be consistent with previous patches, so it's no longer necessary in defconfigs. Should I drop the imply and keep these in defconfig?

I think our Kconfig logic around the QFW options is a bit backwards, given that it's universal to the "qemu" boards and not used on qemu-emulates-known-hardware platforms. The qemu boards should be select'ing QFW, and CMD_QFW should be depends on QFW and default y, rather than selects.

Signature · 1 line
Tom