Skip to contentSkip to conversation

kconfig: Add PCIe devices to s390x machines

PATCH In review Cédric Le Goater 5 participants 7 messages Jul 12, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 kconfig: Add PCIe devices to s390x machines

It is useful to extend the number of available PCIe devices to KVM guests for passthrough scenarios and also to expose these models to a different (big endian) architecture. Introduce a new config PCIE_DEVICES to select models, Intel Ethernet adapters and one USB controller. These devices all support MSI-X which is a requirement on s390x as legacy INTx are not supported.

Cc Matthew Rosato <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Thomas Huth <[email protected]>

---

There could be a more general use of PCIE_DEVICES

v4: Introduce PCIE_DEVICES
v3: PCI -> PCI_EXPRESS
v2: select -> imply

 configs/devices/s390x-softmmu/default.mak | 1 +
 hw/net/Kconfig                            | 4 ++--
 hw/pci/Kconfig                            | 3 +++
 hw/s390x/Kconfig                          | 3 ++-
 hw/usb/Kconfig                            | 2 +-
 5 files changed, 9 insertions(+), 4 deletions(-)
configs/devices/s390x-softmmu/default.mak +1 -0
index f2287a133f36..2d5ff476e32a 100644
@@ -7,6 +7,7 @@
 #CONFIG_VFIO_CCW=n
 #CONFIG_VIRTIO_PCI=n
 #CONFIG_WDT_DIAG288=n
+#CONFIG_PCIE_DEVICE=n
 
 # Boards:
 #
hw/net/Kconfig +2 -2
index 98e00be4f937..7fcc0d7faa29 100644
@@ -41,12 +41,12 @@ config E1000_PCI
 
 config E1000E_PCI_EXPRESS
     bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES
     depends on PCI_EXPRESS && MSI_NONBROKEN
 
 config IGB_PCI_EXPRESS
     bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES
     depends on PCI_EXPRESS && MSI_NONBROKEN
 
 config RTL8139_PCI
hw/pci/Kconfig +3 -0
index 77f8b005ffb1..fe70902cd821 100644
@@ -8,6 +8,9 @@ config PCI_EXPRESS
 config PCI_DEVICES
     bool
 
+config PCIE_DEVICES
+    bool
+
 config MSI_NONBROKEN
     # selected by interrupt controllers that do not support MSI,
     # or support it and have a good implementation. See commit
hw/s390x/Kconfig +2 -1
index 454e0ff4b613..4c068d7960b9 100644
@@ -5,7 +5,8 @@ config S390_CCW_VIRTIO
     imply VFIO_AP
     imply VFIO_CCW
     imply WDT_DIAG288
-    select PCI
+    imply PCIE_DEVICES
+    select PCI_EXPRESS
     select S390_FLIC
     select S390_FLIC_KVM if KVM
     select SCLPCONSOLE
hw/usb/Kconfig +1 -1
index 0ec6def4b8b8..0f486764ed69 100644
@@ -36,7 +36,7 @@ config USB_XHCI
 
 config USB_XHCI_PCI
     bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES
     depends on PCI
     select USB_XHCI
 
Signature · 1 line
2.41.0
#1 lore raw

Hi Cédric,

Quoted 43 lines · Cédric Le Goater

It is useful to extend the number of available PCIe devices to KVM guests for passthrough scenarios and also to expose these models to a different (big endian) architecture. Introduce a new config PCIE_DEVICES to select models, Intel Ethernet adapters and one USB controller. These devices all support MSI-X which is a requirement on s390x as legacy INTx are not supported.

Cc Matthew Rosato <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Thomas Huth <[email protected]>

---

There could be a more general use of PCIE_DEVICES

v4: Introduce PCIE_DEVICES
v3: PCI -> PCI_EXPRESS
v2: select -> imply

  configs/devices/s390x-softmmu/default.mak | 1 +
  hw/net/Kconfig                            | 4 ++--
  hw/pci/Kconfig                            | 3 +++
  hw/s390x/Kconfig                          | 3 ++-
  hw/usb/Kconfig                            | 2 +-
  5 files changed, 9 insertions(+), 4 deletions(-)
configs/devices/s390x-softmmu/default.mak +1 -0
index f2287a133f36..2d5ff476e32a 100644
@@ -7,6 +7,7 @@
  #CONFIG_VFIO_CCW=n
  #CONFIG_VIRTIO_PCI=n
  #CONFIG_WDT_DIAG288=n
+#CONFIG_PCIE_DEVICE=n
 
  # Boards:
  #
hw/net/Kconfig +0 -0
index 98e00be4f937..7fcc0d7faa29 100644

hw/net/Kconfig config E1000_PCI · line 44

Quoted 5 lines
hw/net/Kconfig +1 -1
@@ -41,12 +41,12 @@ config E1000_PCI
 
  config E1000E_PCI_EXPRESS
      bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES

There seems to be a pre-existing bug, shouldn't this be

default y if PCIE_DEVICES

?

(Cc'ing maintainers)

hw/net/Kconfig config E1000_PCI · line 49

Quoted 6 lines
hw/net/Kconfig +1 -1
      depends on PCI_EXPRESS && MSI_NONBROKEN
 
  config IGB_PCI_EXPRESS
      bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES

Similarly:

default y if PCIE_DEVICES

Quoted 22 lines
hw/net/Kconfig +0 -0
      depends on PCI_EXPRESS && MSI_NONBROKEN
 
  config RTL8139_PCI
hw/pci/Kconfig +3 -0
index 77f8b005ffb1..fe70902cd821 100644
@@ -8,6 +8,9 @@ config PCI_EXPRESS
  config PCI_DEVICES
      bool
 
+config PCIE_DEVICES
+    bool
+
  config MSI_NONBROKEN
      # selected by interrupt controllers that do not support MSI,
      # or support it and have a good implementation. See commit
hw/s390x/Kconfig +0 -0
index 454e0ff4b613..4c068d7960b9 100644

hw/s390x/Kconfig config S390_CCW_VIRTIO · line 9

Quoted 6 lines
hw/s390x/Kconfig +2 -1
@@ -5,7 +5,8 @@ config S390_CCW_VIRTIO
      imply VFIO_AP
      imply VFIO_CCW
      imply WDT_DIAG288
-    select PCI
+    imply PCIE_DEVICES
+    select PCI_EXPRESS

I'm confused, TYPE_S390_PCI_HOST_BRIDGE exposes a PCI bus... At a minimum you'd need:

-- >8 --
static const TypeInfo s390_pcihost_info = {

     .name          = TYPE_S390_PCI_HOST_BRIDGE,
-    .parent        = TYPE_PCI_HOST_BRIDGE,
+    .parent        = TYPE_PCIE_HOST_BRIDGE,

.instance_size = sizeof(S390pciState),
.class_init = s390_pcihost_class_init,
.interfaces = (InterfaceInfo[]) {
---

Actually I can see:

        if (s390_pci_msix_init(pbdev) && !pbdev->interp) {
            error_setg(errp, "MSI-X support is mandatory "
                       "in the S390 architecture");
            return;
        }

So this must be PCIe, not legacy PCI, right?

hw/usb/Kconfig config USB_XHCI · line 39

Quoted 10 lines
hw/usb/Kconfig +1 -1
index 0ec6def4b8b8..0f486764ed69 100644
@@ -36,7 +36,7 @@ config USB_XHCI
 
  config USB_XHCI_PCI
      bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES

TYPE_XHCI_PCI inherits TYPE_PCI_DEVICE and implements INTERFACE_PCIE_DEVICE, so this is OK.

Quoted 3 lines
hw/usb/Kconfig +0 -0
      depends on PCI
      select USB_XHCI
 
#2 lore raw
Quoted 27 lines
Quoted 11 lines
hw/s390x/Kconfig +0 -0
index 454e0ff4b613..4c068d7960b9 100644
@@ -5,7 +5,8 @@ config S390_CCW_VIRTIO

      imply VFIO_AP
      imply VFIO_CCW
      imply WDT_DIAG288
-    select PCI
+    imply PCIE_DEVICES
+    select PCI_EXPRESS

I'm confused, TYPE_S390_PCI_HOST_BRIDGE exposes a PCI bus... At a minimum you'd need:

-- >8 --
 static const TypeInfo s390_pcihost_info = {
     .name          = TYPE_S390_PCI_HOST_BRIDGE,
-    .parent        = TYPE_PCI_HOST_BRIDGE,
+    .parent        = TYPE_PCIE_HOST_BRIDGE,
     .instance_size = sizeof(S390pciState),
     .class_init    = s390_pcihost_class_init,
     .interfaces = (InterfaceInfo[]) {
---

Actually I can see:

Quoted 7 lines

        if (s390_pci_msix_init(pbdev) && !pbdev->interp) { error_setg(errp, "MSI-X support is mandatory " "in the S390 architecture"); return;
        }

So this must be PCIe, not legacy PCI, right?

It seems difficult to change now without breaking migration compatibility.

C.

#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 51 lines · Philippe Mathieu-Daudé

Hi Cédric,

Quoted 41 lines · Cédric Le Goater

It is useful to extend the number of available PCIe devices to KVM guests for passthrough scenarios and also to expose these models to a different (big endian) architecture. Introduce a new config PCIE_DEVICES to select models, Intel Ethernet adapters and one USB controller. These devices all support MSI-X which is a requirement on s390x as legacy INTx are not supported.

Cc Matthew Rosato <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Thomas Huth <[email protected]>

---

  There could be a more general use of PCIE_DEVICES

  v4: Introduce PCIE_DEVICES
  v3: PCI -> PCI_EXPRESS
  v2: select -> imply configs/devices/s390x-softmmu/default.mak | 1 + hw/net/Kconfig                            | 4 ++-- hw/pci/Kconfig                            | 3 +++ hw/s390x/Kconfig                          | 3 ++- hw/usb/Kconfig                            | 2 +-

  5 files changed, 9 insertions(+), 4 deletions(-)
configs/devices/s390x-softmmu/default.mak +1 -0
index f2287a133f36..2d5ff476e32a 100644
@@ -7,6 +7,7 @@
   #CONFIG_VFIO_CCW=n
   #CONFIG_VIRTIO_PCI=n
   #CONFIG_WDT_DIAG288=n
+#CONFIG_PCIE_DEVICE=n
   # Boards:
   #
hw/net/Kconfig +0 -0
index 98e00be4f937..7fcc0d7faa29 100644
@@ -41,12 +41,12 @@ config E1000_PCI
Quoted 4 lines

  config E1000E_PCI_EXPRESS
      bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES

There seems to be a pre-existing bug, shouldn't this be

Quoted 3 lines

       default y if PCIE_DEVICES

?

I think you should leave this as is and instead add a config selected only when legacy PCI is available and make all legacy PCI devices depend on the config. This will prevent from selecting legacy PCI devices for s390x machines no matter if it's selected due to PCI_DEVICES or selected manually by the user (by mistake).

Quoted 79 lines

(Cc'ing maintainers)

Quoted 5 lines

      depends on PCI_EXPRESS && MSI_NONBROKEN
  config IGB_PCI_EXPRESS
      bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES

Similarly:

       default y if PCIE_DEVICES

Quoted 20 lines

      depends on PCI_EXPRESS && MSI_NONBROKEN
  config RTL8139_PCI

hw/pci/Kconfig +0 -0
index 77f8b005ffb1..fe70902cd821 100644
@@ -8,6 +8,9 @@ config PCI_EXPRESS

  config PCI_DEVICES
      bool

hw/pci/Kconfig +3 -0
+config PCIE_DEVICES
+    bool
+

  config MSI_NONBROKEN

      # selected by interrupt controllers that do not support MSI,
      # or support it and have a good implementation. See commit
hw/s390x/Kconfig +0 -0
index 454e0ff4b613..4c068d7960b9 100644
@@ -5,7 +5,8 @@ config S390_CCW_VIRTIO
Quoted 6 lines

      imply VFIO_AP
      imply VFIO_CCW
      imply WDT_DIAG288
-    select PCI
+    imply PCIE_DEVICES
+    select PCI_EXPRESS

I'm confused, TYPE_S390_PCI_HOST_BRIDGE exposes a PCI bus... At a minimum you'd need:

-- >8 --
 static const TypeInfo s390_pcihost_info = {
     .name          = TYPE_S390_PCI_HOST_BRIDGE,
-    .parent        = TYPE_PCI_HOST_BRIDGE,
+    .parent        = TYPE_PCIE_HOST_BRIDGE,
     .instance_size = sizeof(S390pciState),
     .class_init    = s390_pcihost_class_init,
     .interfaces = (InterfaceInfo[]) {
---

Actually I can see:

        if (s390_pci_msix_init(pbdev) && !pbdev->interp) { error_setg(errp, "MSI-X support is mandatory " "in the S390 architecture"); return;
        }

So this must be PCIe, not legacy PCI, right?

Quoted 9 lines
hw/usb/Kconfig +0 -0
index 0ec6def4b8b8..0f486764ed69 100644
@@ -36,7 +36,7 @@ config USB_XHCI

  config USB_XHCI_PCI
      bool
-    default y if PCI_DEVICES
+    default y if PCI_DEVICES || PCIE_DEVICES

TYPE_XHCI_PCI inherits TYPE_PCI_DEVICE and implements INTERFACE_PCIE_DEVICE, so this is OK.

Quoted 2 lines

      depends on PCI
      select USB_XHCI

#4 lore raw
In reply to Cédric Le Goater

configs/devices/s390x-softmmu/default.mak line 10

Quoted 9 lines
configs/devices/s390x-softmmu/default.mak +1 -0
index f2287a133f36..2d5ff476e32a 100644
@@ -7,6 +7,7 @@
 #CONFIG_VFIO_CCW=n
 #CONFIG_VIRTIO_PCI=n
 #CONFIG_WDT_DIAG288=n
+#CONFIG_PCIE_DEVICE=n

Should be CONFIG_PCIE_DEVICES; fixed and queued, thanks.

Paolo

#5 lore raw
Quoted 11 lines · Paolo Bonzini

configs/devices/s390x-softmmu/default.mak line 10

Quoted 9 lines
configs/devices/s390x-softmmu/default.mak +1 -0
index f2287a133f36..2d5ff476e32a 100644
@@ -7,6 +7,7 @@
  #CONFIG_VFIO_CCW=n
  #CONFIG_VIRTIO_PCI=n
  #CONFIG_WDT_DIAG288=n
+#CONFIG_PCIE_DEVICE=n

Should be CONFIG_PCIE_DEVICES; fixed and queued, thanks.

I think the patch is fine for now, but in the long run, I think we should make sure to mark PCIe-only devices only with PCIE_DEVICES, as Philippe suggested. So PCIe devices will then also not show up any more on targets that only provide a plain PCI bus (like hppa, I guess?).

Thomas

#6 lore raw
Quoted 4 lines · Thomas Huth

I think the patch is fine for now, but in the long run, I think we should make sure to mark PCIe-only devices only with PCIE_DEVICES, as Philippe suggested. So PCIe devices will then also not show up any more on targets that only provide a plain PCI bus (like hppa, I guess?).

Or even "-M pc", I think.

Paolo