Skip to contentSkip to conversation

virtio-pci: fix level interrupts

PATCH Superseded Michael S. Tsirkin 2 participants 3 messages May 7, 2013

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtio-pci: fix level interrupts

mask notifiers are never called without msix, so devices with backend masking like vhost don't work. Call mask notifiers explicitly at startup/cleanup to make it work.

---

Changes from v1:
- rebase to master

 hw/virtio/virtio-pci.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/virtio/virtio-pci.c +5 -0
index d8708c1..c97aee1 100644
@@ -744,6 +744,7 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
                                          bool with_irqfd)
 {
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(d);
     VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
     EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
 
@@ -758,6 +759,10 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
         event_notifier_cleanup(notifier);
     }
 
+    if (!msix_enabled(&proxy->pci_dev) && vdc->guest_notifier_mask) {
+        vdc->guest_notifier_mask(proxy->vdev, n, !assign);
+    }
+
     return 0;
 }
 
Signature · 1 line
MST
#1 lore raw
Quoted 20 lines · Michael S. Tsirkin

mask notifiers are never called without msix, so devices with backend masking like vhost don't work. Call mask notifiers explicitly at startup/cleanup to make it work.

---

Changes from v1:
- rebase to master

  hw/virtio/virtio-pci.c | 5 +++++
  1 file changed, 5 insertions(+)
hw/virtio/virtio-pci.c +0 -0
index d8708c1..c97aee1 100644

hw/virtio/virtio-pci.c static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign, · line 747

Quoted 4 lines
hw/virtio/virtio-pci.c +1 -0
@@ -744,6 +744,7 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
                                           bool with_irqfd)
  {
      VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(d);

I think there is a mistake here. VIRTIO_DEVICE_GET_CLASS(proxy->vdev) should be used.

Quoted 14 lines
hw/virtio/virtio-pci.c +4 -0
      VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
      EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
 
@@ -758,6 +759,10 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
          event_notifier_cleanup(notifier);
      }
 
+    if (!msix_enabled(&proxy->pci_dev) && vdc->guest_notifier_mask) {
+        vdc->guest_notifier_mask(proxy->vdev, n, !assign);
+    }
+
      return 0;
  }
 
#2 lore raw
Quoted 16 lines · KONRAD Frédéric
Quoted 15 lines · Michael S. Tsirkin

mask notifiers are never called without msix, so devices with backend masking like vhost don't work. Call mask notifiers explicitly at startup/cleanup to make it work.

---

Changes from v1:
- rebase to master

 hw/virtio/virtio-pci.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 12 lines

hw/virtio/virtio-pci.c static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign, · line 747

Quoted 9 lines
hw/virtio/virtio-pci.c +1 -0
index d8708c1..c97aee1 100644
@@ -744,6 +744,7 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
                                          bool with_irqfd)
 {
     VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(d);

I think there is a mistake here. VIRTIO_DEVICE_GET_CLASS(proxy->vdev) should be used.

Hmm yes. I just realized I forgot vhostforce=on in my test script, so wasn't testing it at all actually :( Once I force it, it crashes happily.

So self-NAK, sorry about the noise.

Quoted 11 lines
Quoted 11 lines
hw/virtio/virtio-pci.c +4 -0
     VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
     EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
@@ -758,6 +759,10 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign,
         event_notifier_cleanup(notifier);
     }
+    if (!msix_enabled(&proxy->pci_dev) && vdc->guest_notifier_mask) {
+        vdc->guest_notifier_mask(proxy->vdev, n, !assign);
+    }
+
     return 0;
 }