From patchwork Mon Oct 10 11:53:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 680368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sszBf4sjHz9s2Q for ; Mon, 10 Oct 2016 22:57:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=AQVxfaKz; dkim-atps=neutral Received: from localhost ([::1]:49055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btZCg-0006Ao-Br for incoming@patchwork.ozlabs.org; Mon, 10 Oct 2016 07:57:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btZ9q-0003k0-8A for qemu-devel@nongnu.org; Mon, 10 Oct 2016 07:54:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btZ9p-00065Y-4o for qemu-devel@nongnu.org; Mon, 10 Oct 2016 07:54:14 -0400 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:35049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btZ9o-00065C-NZ for qemu-devel@nongnu.org; Mon, 10 Oct 2016 07:54:13 -0400 Received: by mail-lf0-x244.google.com with SMTP id x79so6189292lff.2 for ; Mon, 10 Oct 2016 04:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Tn0T8R/t0JxU7QMDUTEQwiFr9oRrXSEy2cNPOJwlRqg=; b=AQVxfaKzOscNYUGI3gRwE7yb4ZVyeo5uiAlU2Qn8uMUf9FQrB6OfcjBMAWwmBdZiG9 Luv9irn7X/6V6FDbXxQ4IMd/pckXH2VbbUUonf9lUVxkYS5oizJYVZWXrxDEE3mZuXj/ 9YEz10CODMuxAzg3UdLonbCJYLiO/Cn5wGOYBdgIBMSv4+jK6nasWwaNPp7iDqhQXiCt QiBCKUjXxMjkjWpPfpdHYnbZHeZD4f0m7BSJhcECq+pmaP/jN3HIWJjwaPScSASg3sMo xTm9mLSNLR6ZA1lzqacHbIVo/8rmhnh6cVaFTgiTauzGjTrXAuWc9/QDEveiApNw1+9B SSOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Tn0T8R/t0JxU7QMDUTEQwiFr9oRrXSEy2cNPOJwlRqg=; b=WrTw6v4b8uxbXbzYfpR0Xll0FalreLMVbllcTAdR7xz4sj0in1GYyRNUHhAJF7/rCc KOMsIq1O2815RBy6KLXM0ZdeL9Bpp6vk5xwm0vLCe4/2J2homMTls5Sc6Llb0LXZ9LQF s89Ulo7X3IS2ChPqEpK3i7mygEmn9ApBWDpRHGAUrq6SdMjqEuDGFHke/b/e17xJnuE+ Z9B0k169AN7YzD1rMJ7aDSQaCJf81+P+/VBEWfmINoKlQaiC3bZ/4nK/wGK2QgEj2yYK kgV3o+kWI29lWYa22/AEQvXISvQg1IZ3mAoUGg+ycU+c7na1dB+nVERZg5QswrsCEt1k XYqw== X-Gm-Message-State: AA6/9RkeJCGJ7Kzi2XA1cZ6PUrjARPKhdt+ACRIRYBwepaoA0/QJNsuHZkQQ2JMJg6701g== X-Received: by 10.194.191.228 with SMTP id hb4mr30087444wjc.213.1476100451853; Mon, 10 Oct 2016 04:54:11 -0700 (PDT) Received: from donizetti.lan (94-39-150-81.adsl-ull.clienti.tiscali.it. [94.39.150.81]) by smtp.gmail.com with ESMTPSA id g9sm39619628wjk.25.2016.10.10.04.54.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 04:54:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 10 Oct 2016 13:53:38 +0200 Message-Id: <1476100421-28772-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476100421-28772-1-git-send-email-pbonzini@redhat.com> References: <1476100421-28772-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::244 Subject: [Qemu-devel] [PATCH 10/13] virtio: remove ioeventfd_disabled altogether X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, famz@redhat.com, stefanha@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Cornelia Huck --- 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 501a5f4..131f164 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1196,6 +1196,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); @@ -1215,6 +1216,7 @@ fail_vq: } assert (e >= 0); } + virtio_device_start_ioeventfd(vdev); fail: return r; } @@ -1237,6 +1239,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 046bcc9..440c742 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -190,7 +190,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); @@ -223,8 +223,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) { @@ -234,19 +234,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 af6b5c4..cbdf745 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;