Connect a PCIe host and graphics support to RISC-V
Subsystems (2)
v3 cover Connect a PCIe host and graphics support to RISC-V
V3:
- Remove Makefile config changes
- Connect a network adapter to the virt device
V2:
- Use the gpex PCIe host for virt
- Add support for SiFive U PCIe
Alistair Francis (6):
hw/riscv/virtio: Set the soc device tree node as a simple-bus hw/riscv/virt: Increase the number of interrupts hw/riscv/virt: Connect the gpex PCIe
hw/riscv/virt: Connect a VGA PCIe device hw/riscv/sifive_u: Connect the Xilinx PCIe hw/riscv/virt: Connect a VirtIO net PCIe device
default-configs/riscv32-softmmu.mak | 8 +++ default-configs/riscv64-softmmu.mak | 8 +++ hw/riscv/sifive_u.c | 64 ++++++++++++++++++++++++ hw/riscv/virt.c | 76 ++++++++++++++++++++++++++++- include/hw/riscv/sifive_u.h | 4 +- include/hw/riscv/virt.h | 6 ++- 6 files changed, 162 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/6 hw/riscv/virtio: Set the soc device tree node as a simple-bus
To allow Linux to ennumerate devices on the /soc/ node set it as a "simple-bus".
--- hw/riscv/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/virt.c +1 -1
@@ -121,7 +121,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,qemu_fdt_add_subnode (fdt,"/soc" );qemu_fdt_setprop (fdt,"/soc" ,"ranges" ,NULL ,0 ); -qemu_fdt_setprop_string (fdt,"/soc" ,"compatible" ,"riscv-virtio-soc" ); +qemu_fdt_setprop_string (fdt,"/soc" ,"compatible" ,"simple-bus" );qemu_fdt_setprop_cell (fdt,"/soc" ,"#size-cells" ,0x2 );qemu_fdt_setprop_cell (fdt,"/soc" ,"#address-cells" ,0x2 );
Signature · 1 line
2.17.1
PATCH v3 2/6 hw/riscv/virt: Increase the number of interrupts
In reply to Alistair FrancisIncrease the number of interrupts to match the HiFive Unleashed board.
--- include/hw/riscv/virt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/riscv/virt.h +1 -1
@@ -45,7 +45,7 @@ enum {UART0_IRQ =10 ,VIRTIO_IRQ =1 ,/* 1 to 8 */ VIRTIO_COUNT =8 , -VIRTIO_NDEV =10 +VIRTIO_NDEV =0x35 }; enum {
Signature · 1 line
2.17.1
PATCH v3 3/6 hw/riscv/virt: Connect the gpex PCIe
In reply to Alistair FrancisConnect the gpex PCIe device based on the device tree included in the HiFive Unleashed ROM.
--- default-configs/riscv32-softmmu.mak | 3 ++ default-configs/riscv64-softmmu.mak | 3 ++ hw/riscv/virt.c | 58 +++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 4 +- 4 files changed, 67 insertions(+), 1 deletion(-)
default-configs/riscv32-softmmu.mak +3 -0
@@ -5,3 +5,6 @@ CONFIG_VIRTIO_MMIO=y include virtio.mak CONFIG_CADENCE=y + +CONFIG_PCI=y +CONFIG_PCI_GENERIC=y
default-configs/riscv64-softmmu.mak +3 -0
@@ -5,3 +5,6 @@ CONFIG_VIRTIO_MMIO=y include virtio.mak CONFIG_CADENCE=y + +CONFIG_PCI=y +CONFIG_PCI_GENERIC=y
hw/riscv/virt.c +58 -0
88 lines not on this page · raw message
include/hw/riscv/virt.h +3 -1
@@ -38,13 +38,15 @@ enum {VIRT_PLIC ,VIRT_UART0 ,VIRT_VIRTIO , - VIRT_DRAM +VIRT_DRAM , + VIRT_PCIE };enum {UART0_IRQ =10 ,VIRTIO_IRQ =1 ,/* 1 to 8 */ VIRTIO_COUNT =8 , +PCIE_IRQ =0x20 ,VIRTIO_NDEV =0x35 };
Signature · 1 line
2.17.1
PATCH v3 4/6 hw/riscv/virt: Connect a VGA PCIe device
In reply to Alistair Francis--- default-configs/riscv32-softmmu.mak | 3 +++ default-configs/riscv64-softmmu.mak | 3 +++ hw/riscv/virt.c | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-)
default-configs/riscv32-softmmu.mak +3 -0
@@ -8,3 +8,6 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y + +CONFIG_VGA=y +CONFIG_VGA_PCI=y
default-configs/riscv64-softmmu.mak +3 -0
@@ -8,3 +8,6 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y + +CONFIG_VGA=y +CONFIG_VGA_PCI=y
hw/riscv/virt.c +6 -1
@@ -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,
Signature · 1 line
2.17.1
PATCH v3 5/6 hw/riscv/sifive_u: Connect the Xilinx PCIe
In reply to Alistair FrancisConnect the Xilinx PCIe device based on the information in the device tree stored in the ROM of the HiFish Unleashed board.
--- default-configs/riscv32-softmmu.mak | 1 + default-configs/riscv64-softmmu.mak | 1 + hw/riscv/sifive_u.c | 64 +++++++++++++++++++++++++++++ include/hw/riscv/sifive_u.h | 4 +- 4 files changed, 69 insertions(+), 1 deletion(-)
default-configs/riscv32-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y +CONFIG_PCI_XILINX=y CONFIG_VGA=y CONFIG_VGA_PCI=y
default-configs/riscv64-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y +CONFIG_PCI_XILINX=y CONFIG_VGA=y CONFIG_VGA_PCI=y
hw/riscv/sifive_u.c +64 -0
94 lines not on this page · raw message
include/hw/riscv/sifive_u.h +3 -1
@@ -53,12 +53,14 @@ enum {SIFIVE_U_UART0 ,SIFIVE_U_UART1 ,SIFIVE_U_DRAM , - SIFIVE_U_GEM +SIFIVE_U_GEM , + SIFIVE_U_PCIE };enum {SIFIVE_U_UART0_IRQ =3 ,SIFIVE_U_UART1_IRQ =4 , +SIFIVE_U_PCIE_IRQ =0x20 ,SIFIVE_U_GEM_IRQ =0x35 };
Signature · 1 line
2.17.1
PATCH v3 6/6 hw/riscv/virt: Connect a VirtIO net PCIe device
In reply to Alistair Francis--- default-configs/riscv32-softmmu.mak | 1 + default-configs/riscv64-softmmu.mak | 1 + hw/riscv/virt.c | 11 +++++++++++ 3 files changed, 13 insertions(+)
default-configs/riscv32-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y CONFIG_PCI_XILINX=y +CONFIG_VIRTIO_PCI=y CONFIG_VGA=y CONFIG_VGA_PCI=y
default-configs/riscv64-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y CONFIG_PCI_XILINX=y +CONFIG_VIRTIO_PCI=y CONFIG_VGA=y CONFIG_VGA_PCI=y
hw/riscv/virt.c +11 -0
@@ -36,6 +36,7 @@#include "hw/riscv/sifive_test.h" #include "hw/riscv/virt.h" #include "chardev/char.h" +#include "net/net.h" #include "sysemu/arch_init.h" #include "sysemu/device_tree.h" #include "exec/address-spaces.h"
@@ -445,6 +446,16 @@ static void riscv_virt_board_init(MachineState *machine)pci_vga_init (pci_bus); +for (i =0 ; i < nb_nics; i++) { +NICInfo *nd = &nd_table[i]; + +if (!nd->model) { + nd->model =g_strdup ("virtio" ); + } + +pci_nic_init_nofail (nd, pci_bus, nd->model,NULL ); + } +serial_mm_init (system_memory, memmap[VIRT_UART0 ].base,0 ,qdev_get_gpio_in (DEVICE (s->plic),UART0_IRQ ),399193 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN );
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 4/6] hw/riscv/virt: Connect a VGA PCIe device
In reply to Alistair FrancisHi,
hw/riscv/virt.c static void riscv_virt_board_init(MachineState *machine) · line 446
Quoted 3 lines
hw/riscv/virt.c +3
-0+ 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 1/6] hw/riscv/virtio: Set the soc device tree node as a simple-bus
In reply to Alistair FrancisHi Alistair,
Quoted 1 line · Alistair Francis
To allow Linux to ennumerate devices on the /soc/ node set it as a
enumerate
Quoted 12 lines
"simple-bus".
Signed-off-by Alistair Francis <[email protected]>--- hw/riscv/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/riscv/virt.c +0
-0
hw/riscv/virt.c static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, · line 124
Quoted 5 lines
hw/riscv/virt.c +1
-1@@ -121,7 +121,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,qemu_fdt_add_subnode (fdt,"/soc" );qemu_fdt_setprop (fdt,"/soc" ,"ranges" ,NULL ,0 ); -qemu_fdt_setprop_string (fdt,"/soc" ,"compatible" ,"riscv-virtio-soc" ); +qemu_fdt_setprop_string (fdt,"/soc" ,"compatible" ,"simple-bus" );
For consistency can you do the same patch for the Spike board?
hw/riscv/virt.c static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, · line 127
Quoted 3 lines
hw/riscv/virt.c +0
-0qemu_fdt_setprop_cell (fdt,"/soc" ,"#size-cells" ,0x2 );qemu_fdt_setprop_cell (fdt,"/soc" ,"#address-cells" ,0x2 );
Re: [Qemu-devel] [PATCH v3 4/6] hw/riscv/virt: Connect a VGA PCIe device
In reply to Gerd HoffmannQuoted 10 lines · Gerd Hoffmann
Hi,
hw/riscv/virt.c static void riscv_virt_board_init(MachineState *machine) · line 446
Quoted 3 lines
hw/riscv/virt.c +3
-0+ 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
Quoted 4 lines
cheers,
Gerd