From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmhRo-0007OT-OE for qemu-devel@nongnu.org; Wed, 21 Sep 2016 09:20:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmhRi-0001Be-LP for qemu-devel@nongnu.org; Wed, 21 Sep 2016 09:20:23 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmhRi-0001BR-CK for qemu-devel@nongnu.org; Wed, 21 Sep 2016 09:20:18 -0400 Received: by mail-wm0-f66.google.com with SMTP id 133so8573534wmq.2 for ; Wed, 21 Sep 2016 06:20:18 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 21 Sep 2016 15:18:55 +0200 Message-Id: <1474463939-12223-9-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 08/12] virtio: remove set_handler argument from set_host_notifier_internal 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 Make virtio_device_start_ioeventfd_impl use the same logic as dataplane to set up the host notifier. This removes the need for the set_handler argument in set_host_notifier_internal. This is a first step towards using virtio_bus_set_host_notifier as the sole entry point to set up ioeventfds. At least now the functions have the same interface, but they still differ in that virtio_bus_set_host_notifier sets ioeventfd_disabled. Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-bus.c | 12 +++--------- hw/virtio/virtio.c | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index 05af529..c196ba1 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -146,14 +146,8 @@ void virtio_bus_set_vdev_config(VirtioBusState *bus, uint8_t *config) } } -/* - * This function handles both assigning the ioeventfd handler and - * registering it with the kernel. - * assign: register/deregister ioeventfd with the kernel - * set_handler: use the generic ioeventfd handler - */ int set_host_notifier_internal(DeviceState *proxy, VirtioBusState *bus, - int n, bool assign, bool set_handler) + int n, bool assign) { VirtIODevice *vdev = virtio_bus_get_device(bus); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus); @@ -167,7 +161,7 @@ int set_host_notifier_internal(DeviceState *proxy, VirtioBusState *bus, error_report("%s: unable to init event notifier: %d", __func__, r); return r; } - virtio_queue_set_host_notifier_fd_handler(vq, true, set_handler); + virtio_queue_set_host_notifier_fd_handler(vq, true, false); r = k->ioeventfd_assign(proxy, notifier, n, assign); if (r < 0) { error_report("%s: unable to assign ioeventfd: %d", __func__, r); @@ -252,7 +246,7 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign) */ virtio_bus_stop_ioeventfd(bus); } - return set_host_notifier_internal(proxy, bus, n, assign, false); + return set_host_notifier_internal(proxy, bus, n, assign); } static char *virtio_bus_get_dev_path(DeviceState *dev) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index d1cc2f5..e7b7d0a 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1926,11 +1926,21 @@ static int virtio_device_start_ioeventfd_impl(VirtIODevice *vdev) if (!virtio_queue_get_num(vdev, n)) { continue; } - r = set_host_notifier_internal(proxy, qbus, n, true, true); + r = set_host_notifier_internal(proxy, qbus, n, true); if (r < 0) { err = r; goto assign_error; } + virtio_queue_set_host_notifier_fd_handler(&vdev->vq[n], true, true); + } + + for (n = 0; n < VIRTIO_QUEUE_MAX; n++) { + /* Kick right away to begin processing requests already in vring */ + VirtQueue *vq = &vdev->vq[n];; + if (!vq->vring.num) { + continue; + } + event_notifier_set(&vq->host_notifier); } return 0; @@ -1940,7 +1950,7 @@ assign_error: continue; } - r = set_host_notifier_internal(proxy, qbus, n, false, false); + r = set_host_notifier_internal(proxy, qbus, n, false); assert(r >= 0); } return err; @@ -1964,7 +1974,7 @@ static void virtio_device_stop_ioeventfd_impl(VirtIODevice *vdev) if (!virtio_queue_get_num(vdev, n)) { continue; } - r = set_host_notifier_internal(proxy, qbus, n, false, false); + r = set_host_notifier_internal(proxy, qbus, n, false); assert(r >= 0); } } -- 2.7.4