[Qemu-devel] [PATCH v3 4/6] hw/riscv/virt: Connect a VGA PCIe device

Alistair Francis posted 6 patches 7 years, 2 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v3 4/6] hw/riscv/virt: Connect a VGA PCIe device
Posted by Alistair Francis 7 years, 2 months ago
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 default-configs/riscv32-softmmu.mak | 3 +++
 default-configs/riscv64-softmmu.mak | 3 +++
 hw/riscv/virt.c                     | 7 ++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/default-configs/riscv32-softmmu.mak b/default-configs/riscv32-softmmu.mak
index 2c943e2669..fcefa68f1e 100644
--- a/default-configs/riscv32-softmmu.mak
+++ b/default-configs/riscv32-softmmu.mak
@@ -8,3 +8,6 @@ CONFIG_CADENCE=y
 
 CONFIG_PCI=y
 CONFIG_PCI_GENERIC=y
+
+CONFIG_VGA=y
+CONFIG_VGA_PCI=y
diff --git a/default-configs/riscv64-softmmu.mak b/default-configs/riscv64-softmmu.mak
index 2c943e2669..fcefa68f1e 100644
--- a/default-configs/riscv64-softmmu.mak
+++ b/default-configs/riscv64-softmmu.mak
@@ -8,3 +8,6 @@ CONFIG_CADENCE=y
 
 CONFIG_PCI=y
 CONFIG_PCI_GENERIC=y
+
+CONFIG_VGA=y
+CONFIG_VGA_PCI=y
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 9bdeea38f2..02652e44ee 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -322,6 +322,8 @@ static void riscv_virt_board_init(MachineState *machine)
     MemoryRegion *system_memory = get_system_memory();
     MemoryRegion *main_mem = g_new(MemoryRegion, 1);
     MemoryRegion *mask_rom = g_new(MemoryRegion, 1);
+    PCIBus *pci_bus;
+    DeviceState *dev;
     char *plic_hart_config;
     size_t plic_hart_config_len;
     int i;
@@ -436,9 +438,12 @@ static void riscv_virt_board_init(MachineState *machine)
             qdev_get_gpio_in(DEVICE(s->plic), VIRTIO_IRQ + i));
     }
 
-    gpex_pcie_init(system_memory, 0, memmap[VIRT_PCIE].base,
+    dev = gpex_pcie_init(system_memory, 0, memmap[VIRT_PCIE].base,
                            memmap[VIRT_PCIE].size, 0x40000000, 0x20000000,
                            qdev_get_gpio_in(DEVICE(s->plic), PCIE_IRQ), true);
+    pci_bus = PCI_HOST_BRIDGE(dev)->bus;
+
+    pci_vga_init(pci_bus);
 
     serial_mm_init(system_memory, memmap[VIRT_UART0].base,
         0, qdev_get_gpio_in(DEVICE(s->plic), UART0_IRQ), 399193,
-- 
2.17.1


Re: [Qemu-devel] [PATCH v3 4/6] hw/riscv/virt: Connect a VGA PCIe device
Posted by Gerd Hoffmann 7 years, 2 months ago
  Hi,

> +    pci_bus = PCI_HOST_BRIDGE(dev)->bus;
> +
> +    pci_vga_init(pci_bus);

I'd suggest to use "-device bochs-display" instead, unless you need all
the legacy vga cruft (text mode, ...).  The bochs-drm kms driver can
handle this one just fine too, it is much smaller (in terms of code
lines and attack surface), and it has pcie support.

cheers,
  Gerd


Re: [Qemu-devel] [PATCH v3 4/6] hw/riscv/virt: Connect a VGA PCIe device
Posted by Alistair Francis 7 years, 2 months ago
On Thu, Aug 16, 2018 at 11:36 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
>> +    pci_bus = PCI_HOST_BRIDGE(dev)->bus;
>> +
>> +    pci_vga_init(pci_bus);
>
> I'd suggest to use "-device bochs-display" instead, unless you need all
> the legacy vga cruft (text mode, ...).  The bochs-drm kms driver can
> handle this one just fine too, it is much smaller (in terms of code
> lines and attack surface), and it has pcie support.

I gave this a quick try and the kernel didn't see the device with the
bochs-drm driver enabled.

I'll dig in a little more.

Alistair

>
> cheers,
>   Gerd
>