From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmhRn-0007N8-9O for qemu-devel@nongnu.org; Wed, 21 Sep 2016 09:20:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmhRk-0001C9-8c for qemu-devel@nongnu.org; Wed, 21 Sep 2016 09:20:22 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35799) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmhRj-0001C2-W6 for qemu-devel@nongnu.org; Wed, 21 Sep 2016 09:20:20 -0400 Received: by mail-wm0-f67.google.com with SMTP id 133so8573687wmq.2 for ; Wed, 21 Sep 2016 06:20:19 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 21 Sep 2016 15:18:56 +0200 Message-Id: <1474463939-12223-10-git-send-email-pbonzini@redhat.com> In-Reply-To: <1474463939-12223-1-git-send-email-pbonzini@redhat.com> References: <1474463939-12223-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 09/12] virtio: remove ioeventfd_disabled altogether List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: borntraeger@de.ibm.com, cornelia.huck@de.ibm.com, mst@redhat.com, famz@redhat.com Now that there is not anymore a switch from the generic ioeventfd handler to the dataplane handler, virtio_bus_set_host_notifier(assign=true) is always called with !bus->ioeventfd_started, hence virtio_bus_stop_ioeventfd does nothing in this case. Move the invocation to vhost.c, which is the only place that needs it. Signed-off-by: Paolo Bonzini --- hw/virtio/vhost.c | 3 +++ hw/virtio/virtio-bus.c | 23 ++++++++--------------- include/hw/virtio/virtio-bus.h | 6 ------ 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index c5a1fe0..284bee1 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1182,6 +1182,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) goto fail; } + virtio_device_stop_ioeventfd(vdev); for (i = 0; i < hdev->nvqs; ++i) { r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i, true); @@ -1201,6 +1202,7 @@ fail_vq: } assert (e >= 0); } + virtio_device_start_ioeventfd(vdev); fail: return r; } @@ -1223,6 +1225,7 @@ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) } assert (r >= 0); } + virtio_device_start_ioeventfd(vdev); } /* Test and clear event pending status. diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index c196ba1..ef8f622 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -188,7 +188,7 @@ int virtio_bus_start_ioeventfd(VirtioBusState *bus) if (!k->ioeventfd_assign || !k->ioeventfd_enabled(proxy)) { return -ENOSYS; } - if (bus->ioeventfd_started || bus->ioeventfd_disabled) { + if (bus->ioeventfd_started) { return 0; } r = vdc->start_ioeventfd(vdev); @@ -221,8 +221,8 @@ bool virtio_bus_ioeventfd_enabled(VirtioBusState *bus) } /* - * This function switches from/to the generic ioeventfd handler. - * assign==false means 'use generic ioeventfd handler'. + * This function switches ioeventfd on/off in the device. + * The caller must set or clear the handlers for the EventNotifier. */ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign) { @@ -232,19 +232,12 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign) if (!k->ioeventfd_assign) { return -ENOSYS; } - bus->ioeventfd_disabled = assign; if (assign) { - /* - * Stop using the generic ioeventfd, we are doing eventfd handling - * ourselves below - * - * FIXME: We should just switch the handler and not deassign the - * ioeventfd. - * Otherwise, there's a window where we don't have an - * ioeventfd and we may end up with a notification where - * we don't expect one. - */ - virtio_bus_stop_ioeventfd(bus); + assert(!bus->ioeventfd_started); + } else { + if (!bus->ioeventfd_started) { + return 0; + } } return set_host_notifier_internal(proxy, bus, n, assign); } diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h index 0abc890..b812cad 100644 --- a/include/hw/virtio/virtio-bus.h +++ b/include/hw/virtio/virtio-bus.h @@ -94,12 +94,6 @@ struct VirtioBusState { BusState parent_obj; /* - * Set if the default ioeventfd handlers are disabled by vhost - * or dataplane. - */ - bool ioeventfd_disabled; - - /* * Set if ioeventfd has been started. */ bool ioeventfd_started; -- 2.7.4