Skip to contentSkip to conversation

pci-assign: Fall back to host-side MSI if INTx sharing fails

PATCH Applied Jan Kiszka 3 participants 3 messages Mar 19, 2012 – Mar 21, 2012 KVM

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 pci-assign: Fall back to host-side MSI if INTx sharing fails

If the host or the device does not support INTx sharing, retry the IRQ assignment with host-side MSI support enabled but warn about potential consequences. This allows to preserve the previous behavior where we defaulted to MSI and did not support INTx sharing at all.

---

Detecting if the user actually specified prefer_msi=off as property of pci-assign is non-trivial. So I decided to go for the retry approach, ignoring potential user requests. The warning should attract the attention.

 hw/device-assignment.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
hw/device-assignment.c +12 -0
index 89823f1..c953713 100644
@@ -835,6 +835,7 @@ static int assign_irq(AssignedDevice *dev)
         dev->irq_requested_type = 0;
     }
 
+retry:
     assigned_irq_data.flags = KVM_DEV_IRQ_GUEST_INTX;
     if (dev->features & ASSIGNED_DEVICE_PREFER_MSI_MASK &&
         dev->cap.available & ASSIGNED_DEVICE_CAP_MSI)
@@ -844,6 +845,17 @@ static int assign_irq(AssignedDevice *dev)
 
     r = kvm_assign_irq(kvm_state, &assigned_irq_data);
     if (r < 0) {
+        if (r == -EIO && !(dev->features & ASSIGNED_DEVICE_PREFER_MSI_MASK) &&
+            dev->cap.available & ASSIGNED_DEVICE_CAP_MSI) {
+            /* Retry with host-side MSI. There might be an IRQ conflict and
+             * either the kernel or the device doesn't support sharing. */
+            fprintf(stderr,
+                    "Host-side INTx sharing not supported, "
+                    "using MSI instead.\n"
+                    "Some devices do not to work properly in this mode.\n");
+            dev->features |= ASSIGNED_DEVICE_PREFER_MSI_MASK;
+            goto retry;
+        }
         fprintf(stderr, "Failed to assign irq for \"%s\": %s\n",
                 dev->dev.qdev.id, strerror(-r));
         fprintf(stderr, "Perhaps you are assigning a device "
Signature · 1 line
1.7.3.4
Acked-by on v1 1/1
#1 lore raw
Quoted 36 lines · Jan Kiszka

If the host or the device does not support INTx sharing, retry the IRQ assignment with host-side MSI support enabled but warn about potential consequences. This allows to preserve the previous behavior where we defaulted to MSI and did not support INTx sharing at all.

---

Detecting if the user actually specified prefer_msi=off as property of pci-assign is non-trivial. So I decided to go for the retry approach, ignoring potential user requests. The warning should attract the attention.

 hw/device-assignment.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
hw/device-assignment.c +5 -0
index 89823f1..c953713 100644
@@ -835,6 +835,7 @@ static int assign_irq(AssignedDevice *dev)
         dev->irq_requested_type = 0;
     }
 
+retry:
     assigned_irq_data.flags = KVM_DEV_IRQ_GUEST_INTX;
     if (dev->features & ASSIGNED_DEVICE_PREFER_MSI_MASK &&
         dev->cap.available & ASSIGNED_DEVICE_CAP_MSI)
@@ -844,6 +845,17 @@ static int assign_irq(AssignedDevice *dev)
 
     r = kvm_assign_irq(kvm_state, &assigned_irq_data);
     if (r < 0) {
+        if (r == -EIO && !(dev->features & ASSIGNED_DEVICE_PREFER_MSI_MASK) &&
+            dev->cap.available & ASSIGNED_DEVICE_CAP_MSI) {
+            /* Retry with host-side MSI. There might be an IRQ conflict and
+             * either the kernel or the device doesn't support sharing. */

hw/device-assignment.c static int assign_irq(AssignedDevice *dev) · line 861

Quoted 10 lines
hw/device-assignment.c +7 -0
+            fprintf(stderr,
+                    "Host-side INTx sharing not supported, "
+                    "using MSI instead.\n"
+                    "Some devices do not to work properly in this mode.\n");
+            dev->features |= ASSIGNED_DEVICE_PREFER_MSI_MASK;
+            goto retry;
+        }
         fprintf(stderr, "Failed to assign irq for \"%s\": %s\n",
                 dev->dev.qdev.id, strerror(-r));
         fprintf(stderr, "Perhaps you are assigning a device "
Applied
#2 lore raw
In reply to Jan Kiszka
Quoted 6 lines · Jan Kiszka

If the host or the device does not support INTx sharing, retry the IRQ assignment with host-side MSI support enabled but warn about potential consequences. This allows to preserve the previous behavior where we defaulted to MSI and did not support INTx sharing at all.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function