Skip to contentSkip to conversation

hw/pci-host/sabre: Mark unusable PCI busses as full to ease device plugging

PATCH Superseded Thomas Huth 2 participants 3 messages Feb 16 – Mar 9

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/pci-host/sabre: Mark unusable PCI busses as full to ease device plugging

From: Thomas Huth <[email protected]>

When trying to plug a PCI device to a Sparc64 machine, you currently have to specify the right bus ("bus=pciB"), otherwise you get this error:

 $ qemu-system-sparc64 -device virtio-scsi-pci
 qemu-system-sparc64: -device virtio-scsi-pci: PCI: no slot/function
  available for virtio-scsi-pci, all in use or reserved

This is quite annoying for the unexperienced users, and it also breaks e.g. the iotests ("make check-block") when running with qemu-system-sparc64.

Mark the non-usable PCI busses as full now, so that QEMU can automatically plug new PCI devices to the right "pciB" bus.

---
Note: Only lightly tested, it seems to work fine for me at a first glance, but maybe I missed something...

 hw/pci-host/sabre.c | 2 ++
 1 file changed, 2 insertions(+)
hw/pci-host/sabre.c +2 -0
index cd2328ad53f..9c8519f3849 100644
@@ -382,6 +382,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
                                      &s->pci_mmio,
                                      &s->pci_ioport,
                                      0, 0x40, TYPE_PCI_BUS);
+    qbus_mark_full(&phb->bus->qbus);
 
     pci_create_simple(phb->bus, 0, TYPE_SABRE_PCI_DEVICE);
 
@@ -400,6 +401,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
     s->bridgeA = PCI_BRIDGE(pci_dev);
     pci_bridge_map_irq(s->bridgeA, "pciA", pci_simbaA_map_irq);
     pci_realize_and_unref(pci_dev, phb->bus, &error_fatal);
+    qbus_mark_full(&s->bridgeA->sec_bus.qbus);
 }
 
 static void sabre_init(Object *obj)
Signature · 1 line
2.53.0
#1 lore raw
Quoted 36 lines · Thomas Huth

From: Thomas Huth <[email protected]>

When trying to plug a PCI device to a Sparc64 machine, you currently have to specify the right bus ("bus=pciB"), otherwise you get this error:

  $ qemu-system-sparc64 -device virtio-scsi-pci
  qemu-system-sparc64: -device virtio-scsi-pci: PCI: no slot/function
   available for virtio-scsi-pci, all in use or reserved

This is quite annoying for the unexperienced users, and it also breaks e.g. the iotests ("make check-block") when running with qemu-system-sparc64.

Mark the non-usable PCI busses as full now, so that QEMU can automatically plug new PCI devices to the right "pciB" bus.

---
Note: Only lightly tested, it seems to work fine for me at a first glance, but maybe I missed something...

  hw/pci-host/sabre.c | 2 ++
  1 file changed, 2 insertions(+)
hw/pci-host/sabre.c +1 -0
index cd2328ad53f..9c8519f3849 100644
@@ -382,6 +382,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
                                       &s->pci_mmio,
                                       &s->pci_ioport,
                                       0, 0x40, TYPE_PCI_BUS);
+    qbus_mark_full(&phb->bus->qbus);
 
      pci_create_simple(phb->bus, 0, TYPE_SABRE_PCI_DEVICE);
 

hw/pci-host/sabre.c static void sabre_realize(DeviceState *dev, Error **errp) · line 407

Quoted 7 lines
hw/pci-host/sabre.c +1 -0
@@ -400,6 +401,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
      s->bridgeA = PCI_BRIDGE(pci_dev);
      pci_bridge_map_irq(s->bridgeA, "pciA", pci_simbaA_map_irq);
      pci_realize_and_unref(pci_dev, phb->bus, &error_fatal);
+    qbus_mark_full(&s->bridgeA->sec_bus.qbus);
  }
 
  static void sabre_init(Object *obj)

Apologies for the delay on this: I think the patch makes logical sense, however the existing logic to manage the available PCI slots is handled in sun4uv_init(). Do you think it makes sense to move the qbus_mark_full() calls to the same place?

ATB,

Mark.

#2 lore raw
Quoted 36 lines · Mark Cave-Ayland
Quoted 34 lines · Thomas Huth

From: Thomas Huth <[email protected]>

When trying to plug a PCI device to a Sparc64 machine, you currently have to specify the right bus ("bus=pciB"), otherwise you get this error:

  $ qemu-system-sparc64 -device virtio-scsi-pci
  qemu-system-sparc64: -device virtio-scsi-pci: PCI: no slot/function
   available for virtio-scsi-pci, all in use or reserved

This is quite annoying for the unexperienced users, and it also breaks e.g. the iotests ("make check-block") when running with qemu-system-sparc64.

Mark the non-usable PCI busses as full now, so that QEMU can automatically plug new PCI devices to the right "pciB" bus.

---
  Note: Only lightly tested, it seems to work fine for me at a first glance, but maybe I missed something...

  hw/pci-host/sabre.c | 2 ++

  1 file changed, 2 insertions(+)
hw/pci-host/sabre.c +1 -0
index cd2328ad53f..9c8519f3849 100644
@@ -382,6 +382,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
                                        &s->pci_mmio,
                                        &s->pci_ioport,
                                        0, 0x40, TYPE_PCI_BUS);
+    qbus_mark_full(&phb->bus->qbus);
       pci_create_simple(phb->bus, 0, TYPE_SABRE_PCI_DEVICE);
@@ -400,6 +401,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
Quoted 8 lines

hw/pci-host/sabre.c static void sabre_realize(DeviceState *dev, Error **errp) · line 407

Quoted 6 lines
hw/pci-host/sabre.c +1 -0
       s->bridgeA = PCI_BRIDGE(pci_dev);
       pci_bridge_map_irq(s->bridgeA, "pciA", pci_simbaA_map_irq);
       pci_realize_and_unref(pci_dev, phb->bus, &error_fatal);
+    qbus_mark_full(&s->bridgeA->sec_bus.qbus);
   }
   static void sabre_init(Object *obj)

Apologies for the delay on this: I think the patch makes logical sense, however the existing logic to manage the available PCI slots is handled in sun4uv_init(). Do you think it makes sense to move the qbus_mark_full() calls to the same place?

That makes sense, indeed! I'll send a v2...

Thomas