Skip to contentSkip to conversation

pci: Return PCI_INTX_DISABLED when no bus INTx routing support

PATCH Superseded Alex Williamson 3 participants 5 messages Oct 17, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: Return PCI_INTX_DISABLED when no bus INTx routing support

Rather than assert, simply return PCI_INTX_DISABLED when we don't have a pci_route_irq_fn. PIIX already returns DISABLED for an invalid pin, so users already deal with this state. Users of this interface should only be acting on an ENABLED or INVERTED return value (though we really have no support for INVERTED).

---

A compromise to the gridlock; defuse the assert, but don't add a new state to the API. Thanks,

Alex

 hw/pci.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/pci.c +5 -1
index 83d262a..9525220 100644
@@ -1094,7 +1094,11 @@ PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
          pin = bus->map_irq(dev, pin);
          dev = bus->parent_dev;
     } while (dev);
-    assert(bus->route_intx_to_irq);
+
+    if (!bus->route_intx_to_irq) {
+        return (PCIINTxRoute) { PCI_INTX_DISABLED, -1 };
+    }
+
     return bus->route_intx_to_irq(bus->irq_opaque, pin);
 }
 
#1 lore raw
Quoted 11 lines · Alex Williamson

Rather than assert, simply return PCI_INTX_DISABLED when we don't have a pci_route_irq_fn. PIIX already returns DISABLED for an invalid pin, so users already deal with this state. Users of this interface should only be acting on an ENABLED or INVERTED return value (though we really have no support for INVERTED).

---

A compromise to the gridlock; defuse the assert, but don't add a new state to the API. Thanks,

But how do you tell "unsupported" apart from "disabled" in VFIO? If the chipset truly disabled the line, you must not provide it to the guest in some other way.

Jan

Quoted 24 lines

Alex

 hw/pci.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/pci.c +5 -1
index 83d262a..9525220 100644
@@ -1094,7 +1094,11 @@ PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
          pin = bus->map_irq(dev, pin);
          dev = bus->parent_dev;
     } while (dev);
-    assert(bus->route_intx_to_irq);
+
+    if (!bus->route_intx_to_irq) {
+        return (PCIINTxRoute) { PCI_INTX_DISABLED, -1 };
+    }
+
     return bus->route_intx_to_irq(bus->irq_opaque, pin);
 }
 
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Alex Williamson

Rather than assert, simply return PCI_INTX_DISABLED when we don't have a pci_route_irq_fn. PIIX already returns DISABLED for an invalid pin, so users already deal with this state. Users of this interface should only be acting on an ENABLED or INVERTED return value (though we really have no support for INVERTED).

---

Quoted 8 lines
Quoted 2 lines

A compromise to the gridlock; defuse the assert, but don't add a new state to the API. Thanks,

But how do you tell "unsupported" apart from "disabled" in VFIO? If the chipset truly disabled the line, you must not provide it to the guest in some other way.

Jan

vfio does not care. It merely disables irqfd and delivers irqs to qemu.

Quoted 28 lines
Quoted 24 lines

Alex

 hw/pci.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/pci.c +5 -1
index 83d262a..9525220 100644
@@ -1094,7 +1094,11 @@ PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
          pin = bus->map_irq(dev, pin);
          dev = bus->parent_dev;
     } while (dev);
-    assert(bus->route_intx_to_irq);
+
+    if (!bus->route_intx_to_irq) {
+        return (PCIINTxRoute) { PCI_INTX_DISABLED, -1 };
+    }
+
     return bus->route_intx_to_irq(bus->irq_opaque, pin);
 }
 
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#3 lore raw
In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Alex Williamson

Rather than assert, simply return PCI_INTX_DISABLED when we don't have a pci_route_irq_fn. PIIX already returns DISABLED for an invalid pin, so users already deal with this state. Users of this interface should only be acting on an ENABLED or INVERTED return value (though we really have no support for INVERTED).

Quoted 8 lines
Quoted 5 lines

---

A compromise to the gridlock; defuse the assert, but don't add a new state to the API. Thanks,

But how do you tell "unsupported" apart from "disabled" in VFIO? If the chipset truly disabled the line, you must not provide it to the guest in

The downside to not being able to distinguish is that vfio can't tell the user anything useful about whether it should work, but needs to be implemented in the chipset or if it's just currently disabled. Maybe an error_report below would fix that, but yes, we do lose granularity we had with NOROUTE.

Functionally, there's no direct kvm interrupt injection when this returns DISABLED, so vfio routes the interrupt to qemu where we do qemu_set_irq, and it can get dropped if it's really disabled. pci-assign will just not program the interrupt to kvm and intx won't work :-\ Thanks,

Alex

Quoted 22 lines
Quoted 21 lines
 hw/pci.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/pci.c +5 -1
index 83d262a..9525220 100644
@@ -1094,7 +1094,11 @@ PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
          pin = bus->map_irq(dev, pin);
          dev = bus->parent_dev;
     } while (dev);
-    assert(bus->route_intx_to_irq);
+
+    if (!bus->route_intx_to_irq) {
+        return (PCIINTxRoute) { PCI_INTX_DISABLED, -1 };
+    }
+
     return bus->route_intx_to_irq(bus->irq_opaque, pin);
 }
 
#4 lore raw
Quoted 14 lines · Alex Williamson
Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Alex Williamson

Rather than assert, simply return PCI_INTX_DISABLED when we don't have a pci_route_irq_fn. PIIX already returns DISABLED for an invalid pin, so users already deal with this state. Users of this interface should only be acting on an ENABLED or INVERTED return value (though we really have no support for INVERTED).

---

A compromise to the gridlock; defuse the assert, but don't add a new state to the API. Thanks,

Quoted 8 lines
Quoted 2 lines

But how do you tell "unsupported" apart from "disabled" in VFIO? If the chipset truly disabled the line, you must not provide it to the guest in

The downside to not being able to distinguish is that vfio can't tell the user anything useful about whether it should work, but needs to be implemented in the chipset or if it's just currently disabled. Maybe an error_report below would fix that, but yes, we do lose granularity we had with NOROUTE.

Stick error_report in pci_device_route_intx_to_irq you mean? OK why not.

Quoted 8 lines

Functionally, there's no direct kvm interrupt injection when this returns DISABLED, so vfio routes the interrupt to qemu where we do qemu_set_irq, and it can get dropped if it's really disabled. pci-assign will just not program the interrupt to kvm and intx won't work :-\ Thanks,

Alex

All this handling is just dead code anyway, it's there just in case anyway.

Quoted 24 lines
Quoted 22 lines
Quoted 21 lines
 hw/pci.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/pci.c +5 -1
index 83d262a..9525220 100644
@@ -1094,7 +1094,11 @@ PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
          pin = bus->map_irq(dev, pin);
          dev = bus->parent_dev;
     } while (dev);
-    assert(bus->route_intx_to_irq);
+
+    if (!bus->route_intx_to_irq) {
+        return (PCIINTxRoute) { PCI_INTX_DISABLED, -1 };
+    }
+
     return bus->route_intx_to_irq(bus->irq_opaque, pin);
 }