Skip to contentSkip to conversation

Connect a PCIe host and graphics support to RISC-V

PATCH Superseded Alistair Francis 3 participants 10 messages Jul 10, 2018 – Jul 11, 2018

Subsystems (2)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover Connect a PCIe host and graphics support to RISC-V

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 riscv64-softmmu.mak: Build Virtio Block support

 default-configs/riscv32-softmmu.mak |  7 ++++
 default-configs/riscv64-softmmu.mak |  9 ++++
 hw/riscv/sifive_u.c                 | 64 ++++++++++++++++++++++++++++
 hw/riscv/virt.c                     | 65 ++++++++++++++++++++++++++++-
 include/hw/riscv/sifive_u.h         |  4 +-
 include/hw/riscv/virt.h             |  6 ++-
 6 files changed, 151 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 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
index aeada2498d..5336166f6d 100644
@@ -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
#2 lore raw

PATCH v2 2/6 hw/riscv/virt: Increase the number of interrupts

In reply to Alistair Francis

Increase 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
index 91163d6cbf..7cb2742070 100644
@@ -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
#3 lore raw

PATCH v2 3/6 hw/riscv/virt: Connect the gpex PCIe

In reply to Alistair Francis

Connect 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
index 7937c69e22..2c943e2669 100644
@@ -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
index 7937c69e22..2c943e2669 100644
@@ -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
index 7cb2742070..d0129c2ca5 100644
@@ -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
#4 lore raw

PATCH v2 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
index 2c943e2669..fcefa68f1e 100644
@@ -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
index 2c943e2669..fcefa68f1e 100644
@@ -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
index 0c3800fd64..f973c43c70 100644
@@ -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;
@@ -437,9 +439,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
#5 lore raw

PATCH v2 5/6 hw/riscv/sifive_u: Connect the Xilinx PCIe

In reply to Alistair Francis

Connect 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
index fcefa68f1e..35e74bebe9 100644
@@ -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
index fcefa68f1e..35e74bebe9 100644
@@ -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
index e8b4d9ffa3..e7292ea83b 100644
@@ -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
#6 lore raw

PATCH v2 6/6 riscv64-softmmu.mak: Build Virtio Block support

In reply to Alistair Francis

Add build time support for the VirtIO block device. This allows us to attach a drive using the virtio-blk-device.

---
 default-configs/riscv64-softmmu.mak | 2 ++
 1 file changed, 2 insertions(+)
default-configs/riscv64-softmmu.mak +2 -0
index 35e74bebe9..8790f3b115 100644
@@ -12,3 +12,5 @@ CONFIG_PCI_XILINX=y
 
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
+
+CONFIG_VIRTIO_BLK=y
Signature · 1 line
2.17.1
#7 lore raw

Re: [Qemu-devel] [PATCH v2 6/6] riscv64-softmmu.mak: Build Virtio Block support

Quoted 2 lines · Alistair Francis

Add build time support for the VirtIO block device. This allows us to attach a drive using the virtio-blk-device.

I’m not sure what has changed in master, but VirtIO block and net for both softmmu-riscv32 and softmmu-riscv64 were previously building by default and working. Perhaps i’ve missed some patches that split up VirtIO support into more granular config options.

In any case, we should enable both CONFIG_VIRTIO_NET and CONFIG_VIRTIO_BLK for both riscv32 and riscv64 as these were working in QEMU 2.12. There are folk using the “virt” machine for riscv32 Linux.

Thanks, at least I know what to expect when I rebase my patch queue against master and of course make a PR for the reviewed patches...

I’m not sure of the soft-freeze date but the bulk of the patches are the same ones that were posted about a month ago... I also have several patches that are not yet on the list...

Vectored interrupts. Trap tracing. More spec wording clarifications regarding load reservations and interrupts:

-
https://github.com/riscv/riscv-qemu/commits/qemu-2.13-for-upstream

Michael

Quoted 19 lines
---
 default-configs/riscv64-softmmu.mak | 2 ++
 1 file changed, 2 insertions(+)
default-configs/riscv64-softmmu.mak +2 -1
index 35e74bebe9..8790f3b115 100644
@@ -12,3 +12,5 @@ CONFIG_PCI_XILINX=y
 
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
+
+CONFIG_VIRTIO_BLK=y
--

2.17.1

#8 lore raw

Re: [Qemu-devel] [PATCH v2 6/6] riscv64-softmmu.mak: Build Virtio Block support

Quoted 5 lines · Michael Clark
Quoted 1 line · Alistair Francis
Quoted 8 lines
Quoted 2 lines

Add build time support for the VirtIO block device. This allows us to attach a drive using the virtio-blk-device.

I’m not sure what has changed in master, but VirtIO block and net for both softmmu-riscv32 and softmmu-riscv64 were previously building by default and working. Perhaps i’ve missed some patches that split up VirtIO support into more granular config options.

It just occurred to me that this patch might not be required. Someone my last patch series had a conflict that results in removing the virt include in the default configs. I suspect this patch can be dropped.

Alistair

Quoted 40 lines

In any case, we should enable both CONFIG_VIRTIO_NET and CONFIG_VIRTIO_BLK for both riscv32 and riscv64 as these were working in QEMU 2.12. There are folk using the “virt” machine for riscv32 Linux.

Thanks, at least I know what to expect when I rebase my patch queue against master and of course make a PR for the reviewed patches...

I’m not sure of the soft-freeze date but the bulk of the patches are the same ones that were posted about a month ago... I also have several patches that are not yet on the list...

Vectored interrupts. Trap tracing. More spec wording clarifications regarding load reservations and interrupts:

-
https://github.com/riscv/riscv-qemu/commits/qemu-2.13-for-upstream

Michael

Quoted 19 lines
---
 default-configs/riscv64-softmmu.mak | 2 ++
 1 file changed, 2 insertions(+)
default-configs/riscv64-softmmu.mak +2 -1
index 35e74bebe9..8790f3b115 100644
@@ -12,3 +12,5 @@ CONFIG_PCI_XILINX=y
 
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
+
+CONFIG_VIRTIO_BLK=y
--

2.17.1

#9 lore raw

Re: [Qemu-devel] [PATCH v2 6/6] riscv64-softmmu.mak: Build Virtio Block support

Quoted 10 lines · Alistair Francis
Quoted 9 lines · Michael Clark
Quoted 3 lines · Alistair Francis

Add build time support for the VirtIO block device. This allows us to attach a drive using the virtio-blk-device.

Quoted 8 lines
Quoted 4 lines

I’m not sure what has changed in master, but VirtIO block and net for both softmmu-riscv32 and softmmu-riscv64 were previously building by default and working. Perhaps i’ve missed some patches that split up VirtIO support into more granular config options.

It just occurred to me that this patch might not be required. Someone my last patch series had a conflict that results in removing the virt include in the default configs. I suspect this patch can be dropped.

Yep, no longer required.

Alistair

Quoted 43 lines

Alistair

Quoted 40 lines

In any case, we should enable both CONFIG_VIRTIO_NET and CONFIG_VIRTIO_BLK for both riscv32 and riscv64 as these were working in QEMU 2.12. There are folk using the “virt” machine for riscv32 Linux.

Thanks, at least I know what to expect when I rebase my patch queue against master and of course make a PR for the reviewed patches...

I’m not sure of the soft-freeze date but the bulk of the patches are the same ones that were posted about a month ago... I also have several patches that are not yet on the list...

Vectored interrupts. Trap tracing. More spec wording clarifications regarding load reservations and interrupts:

-
https://github.com/riscv/riscv-qemu/commits/qemu-2.13-for-upstream

Michael

Quoted 19 lines
---
 default-configs/riscv64-softmmu.mak | 2 ++
 1 file changed, 2 insertions(+)
default-configs/riscv64-softmmu.mak +2 -1
index 35e74bebe9..8790f3b115 100644
@@ -12,3 +12,5 @@ CONFIG_PCI_XILINX=y
 
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
+
+CONFIG_VIRTIO_BLK=y
--

2.17.1