Skip to contentSkip to conversation

Connect a PCIe host and graphics support to RISC-V

PATCH Superseded Alistair Francis 5 participants 10 messages Jun 22, 2018 – Aug 2, 2018 RISC-V

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

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

Alistair Francis (5):
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 Xilinx PCIe hw/riscv/virt: Connect a VGA PCIe device riscv64-softmmu.mak: Build Virtio Block support

 default-configs/riscv32-softmmu.mak |  6 +++
 default-configs/riscv64-softmmu.mak |  8 ++++
 hw/riscv/virt.c                     | 73 ++++++++++++++++++++++++++++-
 include/hw/riscv/virt.h             |  6 ++-
 4 files changed, 90 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/5 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 bdd75722eb..a95ccb2825 100644
@@ -120,7 +120,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 2/5 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 3/5 hw/riscv/virt: Connect the Xilinx PCIe

In reply to Alistair Francis

Connect the Xilinx 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                     | 65 +++++++++++++++++++++++++++++
 include/hw/riscv/virt.h             |  4 +-
 4 files changed, 74 insertions(+), 1 deletion(-)
default-configs/riscv32-softmmu.mak +3 -0
index 7a003eb5e2..b8cac7a49f 100644
@@ -4,3 +4,6 @@ CONFIG_SERIAL=y
 CONFIG_VIRTIO_MMIO=y
 CONFIG_VIRTIO=y
 CONFIG_CADENCE=y
+
+CONFIG_PCI=y
+CONFIG_PCI_XILINX=y
default-configs/riscv64-softmmu.mak +3 -0
index 7a003eb5e2..b8cac7a49f 100644
@@ -4,3 +4,6 @@ CONFIG_SERIAL=y
 CONFIG_VIRTIO_MMIO=y
 CONFIG_VIRTIO=y
 CONFIG_CADENCE=y
+
+CONFIG_PCI=y
+CONFIG_PCI_XILINX=y
hw/riscv/virt.c +65 -0

95 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

Re: [Qemu-devel] [PATCH v1 3/5] hw/riscv/virt: Connect the Xilinx PCIe

Quoted 2 lines · Alistair Francis

Connect the Xilinx PCIe device based on the device tree included in the HiFive Unleashed ROM.

Did you consider using the 'gpex' generic PCIe controller here?

thanks
-- PMM

#5 lore raw

Re: [Qemu-devel] [PATCH v1 3/5] hw/riscv/virt: Connect the Xilinx PCIe

Quoted 9 lines · Peter Maydell
Quoted 2 lines · Alistair Francis

Connect the Xilinx PCIe device based on the device tree included in the HiFive Unleashed ROM.

Did you consider using the 'gpex' generic PCIe controller here?

Yes. Alastair and I talked about this yesterday and we agreed in principle to using ‘gpex’ on the virt machine and the Xilinx PCIe on the SiFive U (’sifive_u’) machine, as this reflects one of the IP configurations of SiFive’s Coreplex U series when run on FPGA.

By changing this patch to add Xilinx PCIe to ‘sifive_u’, we can plug IO devices into the U series machine, and instead add gpex to RISC-V virt. i.e. vendor agnostic generic PCIe controller for virt. We would like ‘virt’ to be a potential vendor agnostic hardware target when we have kvm, so using gpex fits with this strategy (speaking from a RISC-V perspective not a SiFive perspective).

#6 lore raw

PATCH 4/5 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                     | 12 +++++++++---
 3 files changed, 15 insertions(+), 3 deletions(-)
default-configs/riscv32-softmmu.mak +3 -0
index b8cac7a49f..73a421d3de 100644
@@ -7,3 +7,6 @@ CONFIG_CADENCE=y
 
 CONFIG_PCI=y
 CONFIG_PCI_XILINX=y
+
+CONFIG_VGA=y
+CONFIG_VGA_PCI=y
default-configs/riscv64-softmmu.mak +3 -0
index b8cac7a49f..73a421d3de 100644
@@ -7,3 +7,6 @@ CONFIG_CADENCE=y
 
 CONFIG_PCI=y
 CONFIG_PCI_XILINX=y
+
+CONFIG_VGA=y
+CONFIG_VGA_PCI=y
hw/riscv/virt.c +9 -3
index 7c1ed3aee5..11f6f96a47 100644
@@ -328,6 +328,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;
@@ -443,9 +445,12 @@ static void riscv_virt_board_init(MachineState *machine)
             qdev_get_gpio_in(DEVICE(s->plic), VIRTIO_IRQ + i));
     }
 
-    xilinx_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);
+    dev = xilinx_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_BRIDGE(&XILINX_PCIE_HOST(dev)->root)->sec_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,
@@ -457,6 +462,7 @@ static void riscv_virt_board_machine_init(MachineClass *mc)
     mc->desc = "RISC-V VirtIO Board (Privileged ISA v1.10)";
     mc->init = riscv_virt_board_init;
     mc->max_cpus = 8; /* hardcoded limit in BBL */
+    mc->default_display = "std";
 }
 
 DEFINE_MACHINE("virt", riscv_virt_board_machine_init)
Signature · 1 line
2.17.1
#7 lore raw

PATCH 5/5 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 73a421d3de..0be2cce269 100644
@@ -10,3 +10,5 @@ CONFIG_PCI_XILINX=y
 
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
+
+CONFIG_VIRTIO_BLK=y
Signature · 1 line
2.17.1
#8 lore raw
In reply to Alistair Francis
Quoted 7 lines · On Fri, 22 Jun 2018 12:28:14 PDT (-0700), [email protected] wrote:

Alistair Francis (5):
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 Xilinx PCIe hw/riscv/virt: Connect a VGA PCIe device riscv64-softmmu.mak: Build Virtio Block support

Quoted 5 lines
 default-configs/riscv32-softmmu.mak |  6 +++
 default-configs/riscv64-softmmu.mak |  8 ++++
 hw/riscv/virt.c                     | 73 ++++++++++++++++++++++++++++-
 include/hw/riscv/virt.h             |  6 ++-
 4 files changed, 90 insertions(+), 3 deletions(-)

Sorry I'm so slow here, I'm still chewing through my patch backlog. It looks like this hasn't made it upstream yet. I rebased it on top of master but have yet to figure out how to make it work, though I think that's on the Linux side.

I haven't yet looked at the code, but I like the functionality so I don't want to lose this. Can you submit a v2 that applies cleanly to master, or do you want me to deal with it?

#9 lore raw

Re: [Qemu-devel] [PATCH v1 0/5] Connect a PCIe host and graphics support toRISC-V

Hey,

Sorry for the top post. I’m on holidays at the moment and will be back next week.

I have sent a V2 to the list, I don’t think I CCed you as I know your busy. Once the 3.1 merge window opens I’ll send a new version with all the comments I have received.

Alistair

From: Palmer Dabbelt
Sent: Thursday, 2 August 2018 10:44 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Michael Clark
Subject: Re: [PATCH v1 0/5] Connect a PCIe host and graphics support toRISC-V

Quoted 7 lines · On Fri, 22 Jun 2018 12:28:14 PDT (-0700), [email protected] wrote:

Alistair Francis (5):
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 Xilinx PCIe hw/riscv/virt: Connect a VGA PCIe device riscv64-softmmu.mak: Build Virtio Block support

Quoted 5 lines
 default-configs/riscv32-softmmu.mak |  6 +++
 default-configs/riscv64-softmmu.mak |  8 ++++
 hw/riscv/virt.c                     | 73 ++++++++++++++++++++++++++++-
 include/hw/riscv/virt.h             |  6 ++-
 4 files changed, 90 insertions(+), 3 deletions(-)

Sorry I'm so slow here, I'm still chewing through my patch backlog. It looks like this hasn't made it upstream yet. I rebased it on top of master but have yet to figure out how to make it work, though I think that's on the Linux side.

I haven't yet looked at the code, but I like the functionality so I don't want to lose this. Can you submit a v2 that applies cleanly to master, or do you want me to deal with it?