Skip to contentSkip to conversation

Connect a PCIe host and graphics support to RISC-V

PATCH In review Alistair Francis 2 participants 6 messages Dec 11, 2018 RISC-V

lore
Share & tools
lore
#0 lore raw

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

This series is now ready to be merged, all of the patches are reviewed and tested.

Palmer can you take this with all the other RISC-V patches sent during the freeze?

V8:
- Drop SiFive U support
- Drop legacy -nic support
- Small other review changes
V7:
- Fix the GPEX memory mapping thanks to Bin Meng
- Fix the interrupt mapping thanks to Logan Gunthorpe
V6:
- Fix the interrupt issue for the GPEX device
V5:
- Rebase
- Include pci.mak in the default configs
V4:
- Fix the spike device tree
- Don't use stdvga device
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 (4):
hw/riscv/virt: Increase the number of interrupts hw/riscv/virt: Adjust memory layout spacing hw/riscv/virt: Connect the gpex PCIe
riscv: Enable VGA and PCIE_VGA

 default-configs/riscv32-softmmu.mak |   8 +-
 default-configs/riscv64-softmmu.mak |   8 +-
 hw/riscv/virt.c                     | 147 ++++++++++++++++++++++++++--
 include/hw/riscv/virt.h             |  15 ++-
 4 files changed, 165 insertions(+), 13 deletions(-)
Signature · 1 line
2.19.1
#1 lore raw

PATCH v8 1/4 hw/riscv/virt: Increase the number of interrupts

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..2b2e6dd4ea 100644
@@ -45,7 +45,7 @@ enum {
     UART0_IRQ = 10,
     VIRTIO_IRQ = 1, /* 1 to 8 */
     VIRTIO_COUNT = 8,
-    VIRTIO_NDEV = 10
+    VIRTIO_NDEV = 0x35 /* Arbitrary maximum number of interrupts */
 };
 
 enum {
Signature · 1 line
2.19.1
#2 lore raw

PATCH v8 2/4 hw/riscv/virt: Adjust memory layout spacing

In reply to Alistair Francis
---
 hw/riscv/virt.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/riscv/virt.c +8 -8
index 2b38f89070..6b6fa39aaa 100644
@@ -47,14 +47,14 @@ static const struct MemmapEntry {
     hwaddr base;
     hwaddr size;
 } virt_memmap[] = {
-    [VIRT_DEBUG] =    {        0x0,      0x100 },
-    [VIRT_MROM] =     {     0x1000,    0x11000 },
-    [VIRT_TEST] =     {   0x100000,     0x1000 },
-    [VIRT_CLINT] =    {  0x2000000,    0x10000 },
-    [VIRT_PLIC] =     {  0xc000000,  0x4000000 },
-    [VIRT_UART0] =    { 0x10000000,      0x100 },
-    [VIRT_VIRTIO] =   { 0x10001000,     0x1000 },
-    [VIRT_DRAM] =     { 0x80000000,        0x0 },
+    [VIRT_DEBUG] =       {        0x0,         0x100 },
+    [VIRT_MROM] =        {     0x1000,       0x11000 },
+    [VIRT_TEST] =        {   0x100000,        0x1000 },
+    [VIRT_CLINT] =       {  0x2000000,       0x10000 },
+    [VIRT_PLIC] =        {  0xc000000,     0x4000000 },
+    [VIRT_UART0] =       { 0x10000000,         0x100 },
+    [VIRT_VIRTIO] =      { 0x10001000,        0x1000 },
+    [VIRT_DRAM] =        { 0x80000000,           0x0 },
 };
 
 static uint64_t load_kernel(const char *kernel_filename)
Signature · 1 line
2.19.1
#3 lore raw

PATCH v8 3/4 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 |   5 +-
 default-configs/riscv64-softmmu.mak |   5 +-
 hw/riscv/virt.c                     | 131 +++++++++++++++++++++++++++-
 include/hw/riscv/virt.h             |  13 ++-
 4 files changed, 150 insertions(+), 4 deletions(-)
default-configs/riscv32-softmmu.mak +4 -1
index 7937c69e22..c5ea36cba5 100644
@@ -1,7 +1,10 @@
 # Default configuration for riscv-softmmu
 
+include pci.mak
+
 CONFIG_SERIAL=y
 CONFIG_VIRTIO_MMIO=y
-include virtio.mak
 
 CONFIG_CADENCE=y
+
+CONFIG_PCI_GENERIC=y
default-configs/riscv64-softmmu.mak +4 -1
index 7937c69e22..c5ea36cba5 100644
@@ -1,7 +1,10 @@
 # Default configuration for riscv-softmmu
 
+include pci.mak
+
 CONFIG_SERIAL=y
 CONFIG_VIRTIO_MMIO=y
-include virtio.mak
 
 CONFIG_CADENCE=y
+
+CONFIG_PCI_GENERIC=y
hw/riscv/virt.c +130 -1

173 lines not on this page · raw message

include/hw/riscv/virt.h +12 -1
index 2b2e6dd4ea..f12deaebd6 100644
@@ -38,13 +38,17 @@ enum {
     VIRT_PLIC,
     VIRT_UART0,
     VIRT_VIRTIO,
-    VIRT_DRAM
+    VIRT_DRAM,
+    VIRT_PCIE_MMIO,
+    VIRT_PCIE_PIO,
+    VIRT_PCIE_ECAM
 };
 
 enum {
     UART0_IRQ = 10,
     VIRTIO_IRQ = 1, /* 1 to 8 */
     VIRTIO_COUNT = 8,
+    PCIE_IRQ = 0x20, /* 32 to 35 */
     VIRTIO_NDEV = 0x35 /* Arbitrary maximum number of interrupts */
 };
 
@@ -62,6 +66,13 @@ enum {
 #define VIRT_PLIC_CONTEXT_BASE 0x200000
 #define VIRT_PLIC_CONTEXT_STRIDE 0x1000
 
+#define FDT_PCI_ADDR_CELLS    3
+#define FDT_PCI_INT_CELLS     1
+#define FDT_PLIC_ADDR_CELLS   0
+#define FDT_PLIC_INT_CELLS    1
+#define FDT_INT_MAP_WIDTH     (FDT_PCI_ADDR_CELLS + FDT_PCI_INT_CELLS + 1 + \
+                               FDT_PLIC_ADDR_CELLS + FDT_PLIC_INT_CELLS)
+
 #if defined(TARGET_RISCV32)
 #define VIRT_CPU TYPE_RISCV_CPU_RV32GCSU_V1_10_0
 #elif defined(TARGET_RISCV64)
Signature · 1 line
2.19.1
#4 lore raw

PATCH v8 4/4 riscv: Enable VGA and PCIE_VGA

In reply to Alistair Francis

Enable compile support for VGA devices. This allows the user to conenct a display by adding '-device bochs-display -display sdl' to their command line argument.

---
 default-configs/riscv32-softmmu.mak | 3 +++
 default-configs/riscv64-softmmu.mak | 3 +++
 2 files changed, 6 insertions(+)
default-configs/riscv32-softmmu.mak +3 -0
index c5ea36cba5..dbc9398284 100644
@@ -8,3 +8,6 @@ CONFIG_VIRTIO_MMIO=y
 CONFIG_CADENCE=y
 
 CONFIG_PCI_GENERIC=y
+
+CONFIG_VGA=y
+CONFIG_VGA_PCI=y
default-configs/riscv64-softmmu.mak +3 -0
index c5ea36cba5..dbc9398284 100644
@@ -8,3 +8,6 @@ CONFIG_VIRTIO_MMIO=y
 CONFIG_CADENCE=y
 
 CONFIG_PCI_GENERIC=y
+
+CONFIG_VGA=y
+CONFIG_VGA_PCI=y
Signature · 1 line
2.19.1
#5 lore raw
In reply to Alistair Francis
Quoted 5 lines · Alistair Francis

This series is now ready to be merged, all of the patches are reviewed and tested.

Palmer can you take this with all the other RISC-V patches sent during the freeze?

Yep, I'll be collecting everything this week.

Thanks!

Quoted 38 lines

V8:
- Drop SiFive U support
- Drop legacy -nic support
- Small other review changes
V7:
- Fix the GPEX memory mapping thanks to Bin Meng
- Fix the interrupt mapping thanks to Logan Gunthorpe
V6:
- Fix the interrupt issue for the GPEX device
V5:
- Rebase
- Include pci.mak in the default configs
V4:
- Fix the spike device tree
- Don't use stdvga device
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 (4):
hw/riscv/virt: Increase the number of interrupts hw/riscv/virt: Adjust memory layout spacing hw/riscv/virt: Connect the gpex PCIe
riscv: Enable VGA and PCIE_VGA

 default-configs/riscv32-softmmu.mak |   8 +-
 default-configs/riscv64-softmmu.mak |   8 +-
 hw/riscv/virt.c                     | 147 ++++++++++++++++++++++++++--
 include/hw/riscv/virt.h             |  15 ++-
 4 files changed, 165 insertions(+), 13 deletions(-)
Signature · 1 line
2.19.1