From patchwork Mon Oct 10 11:53:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 680369 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 3sszFk2PLQz9ryr for ; Mon, 10 Oct 2016 22:59:54 +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=WhJWChGT; dkim-atps=neutral Received: from localhost ([::1]:49068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btZFG-0008NX-TH for incoming@patchwork.ozlabs.org; Mon, 10 Oct 2016 07:59:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btZ9h-0003aW-8l for qemu-devel@nongnu.org; Mon, 10 Oct 2016 07:54:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btZ9e-0005yf-RH for qemu-devel@nongnu.org; Mon, 10 Oct 2016 07:54:04 -0400 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:33917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btZ9e-0005y7-EX for qemu-devel@nongnu.org; Mon, 10 Oct 2016 07:54:02 -0400 Received: by mail-lf0-x242.google.com with SMTP id p80so9619484lfp.1 for ; Mon, 10 Oct 2016 04:54:02 -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=0j7aimE7WmDIRETQXZz9/w+Ji7oi4yf/jQvOS/U+12c=; b=WhJWChGTGgm7WndP8iYsKwTkIbnz2SWqde7T19Mk9XRyksdnCxyputXTOCR7+TsKwn VDo2EBLFsPNaIWjPb27UmH/DTu77nB4sEnN2P5dUXAsfs906o7v7aKtPR+TEXPxBhYib tY+ouNo2yK2PkVLoq5Ray34dc+PFy2cMZHovlO8zKQRFBWlchcOJ/rFp3Upj03zDlocD KXja7k9DIdjdLEj8gatWPzZkE/A7q/ulliinmYRWKN7T0CPFzlfEr9inqUUlSA6CnFoN XjbdqEPW5fIikyrNe3XV2Ei7o9jP7jaa0sLGTwGwX/U79p1uF9JuPPqaYssGcKQpHhxH bZGg== 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=0j7aimE7WmDIRETQXZz9/w+Ji7oi4yf/jQvOS/U+12c=; b=Y5W4ZM//drnFicXXYk7Ycl0ba8FP/cfvah2X3wDvRNzpC50dpX2wYaBqTZLLXl06IN iycaks38IIEsW7sZdM/g3dM2fU5j6eKvRSvxpMxp1C+XFbSF/4fm5maOFnSNNW26Z3xF liCtDpZBkXnJUKJnd1MtTJ2mpqmopEj1JDQymdoubZmJLPVY0JrQiNyJqqYBH2SsneZp mIru69W12k5edI+fnSZvDQBXwUse70T3EjEHkPuQxSHSYW9R7Xk1C1yCDG290rv6Q7zV 9vjnc6YdA90k/s0y/ZxzyFLgaXgdIPcF2mBjx0xwq+c8BUqSIDk5WlU17kpt9Mv9db9p xIug== X-Gm-Message-State: AA6/9RlKqLaNVrMVJS07BQJOyl9pxqurnn/sz3QtSK4fF5gLq3Mc8krQqCxexuEPrKRqGA== X-Received: by 10.194.87.34 with SMTP id u2mr36769497wjz.118.1476100441462; Mon, 10 Oct 2016 04:54:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 04:54:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 10 Oct 2016 13:53:30 +0200 Message-Id: <1476100421-28772-3-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::242 Subject: [Qemu-devel] [PATCH 02/13] virtio: move ioeventfd_disabled flag to VirtioBusState 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" This simplifies the code and removes the ioeventfd_set_disabled callback. Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini Reviewed-by: Cornelia Huck --- hw/s390x/virtio-ccw.c | 11 +---------- hw/s390x/virtio-ccw.h | 1 - hw/virtio/virtio-bus.c | 4 ++-- hw/virtio/virtio-mmio.c | 13 +------------ hw/virtio/virtio-pci.c | 11 +---------- hw/virtio/virtio-pci.h | 1 - include/hw/virtio/virtio-bus.h | 8 ++++++-- 7 files changed, 11 insertions(+), 38 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 31304fe..672e6c4 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -82,15 +82,7 @@ static bool virtio_ccw_ioeventfd_disabled(DeviceState *d) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); - return dev->ioeventfd_disabled || - !(dev->flags & VIRTIO_CCW_FLAG_USE_IOEVENTFD); -} - -static void virtio_ccw_ioeventfd_set_disabled(DeviceState *d, bool disabled) -{ - VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); - - dev->ioeventfd_disabled = disabled; + return !(dev->flags & VIRTIO_CCW_FLAG_USE_IOEVENTFD); } static int virtio_ccw_ioeventfd_assign(DeviceState *d, EventNotifier *notifier, @@ -1619,7 +1611,6 @@ static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data) k->ioeventfd_started = virtio_ccw_ioeventfd_started; k->ioeventfd_set_started = virtio_ccw_ioeventfd_set_started; k->ioeventfd_disabled = virtio_ccw_ioeventfd_disabled; - k->ioeventfd_set_disabled = virtio_ccw_ioeventfd_set_disabled; k->ioeventfd_assign = virtio_ccw_ioeventfd_assign; } diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h index 565094e..327e75a 100644 --- a/hw/s390x/virtio-ccw.h +++ b/hw/s390x/virtio-ccw.h @@ -87,7 +87,6 @@ struct VirtioCcwDevice { uint32_t max_rev; VirtioBusState bus; bool ioeventfd_started; - bool ioeventfd_disabled; uint32_t flags; uint8_t thinint_isc; AdapterRoutes routes; diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index 11f65bd..3607c29 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -195,7 +195,7 @@ void virtio_bus_start_ioeventfd(VirtioBusState *bus) if (!k->ioeventfd_started || k->ioeventfd_started(proxy)) { return; } - if (k->ioeventfd_disabled(proxy)) { + if (bus->ioeventfd_disabled || k->ioeventfd_disabled(proxy)) { return; } vdev = virtio_bus_get_device(bus); @@ -257,7 +257,7 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign) if (!k->ioeventfd_started) { return -ENOSYS; } - k->ioeventfd_set_disabled(proxy, assign); + bus->ioeventfd_disabled = assign; if (assign) { /* * Stop using the generic ioeventfd, we are doing eventfd handling diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 13798b3..12a9e79 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -89,7 +89,6 @@ typedef struct { uint32_t guest_page_shift; /* virtio-bus */ VirtioBusState bus; - bool ioeventfd_disabled; bool ioeventfd_started; bool format_transport_address; } VirtIOMMIOProxy; @@ -111,16 +110,7 @@ static void virtio_mmio_ioeventfd_set_started(DeviceState *d, bool started, static bool virtio_mmio_ioeventfd_disabled(DeviceState *d) { - VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d); - - return !kvm_eventfds_enabled() || proxy->ioeventfd_disabled; -} - -static void virtio_mmio_ioeventfd_set_disabled(DeviceState *d, bool disabled) -{ - VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d); - - proxy->ioeventfd_disabled = disabled; + return !kvm_eventfds_enabled(); } static int virtio_mmio_ioeventfd_assign(DeviceState *d, @@ -560,7 +550,6 @@ static void virtio_mmio_bus_class_init(ObjectClass *klass, void *data) k->ioeventfd_started = virtio_mmio_ioeventfd_started; k->ioeventfd_set_started = virtio_mmio_ioeventfd_set_started; k->ioeventfd_disabled = virtio_mmio_ioeventfd_disabled; - k->ioeventfd_set_disabled = virtio_mmio_ioeventfd_set_disabled; k->ioeventfd_assign = virtio_mmio_ioeventfd_assign; k->has_variable_vring_alignment = true; bus_class->max_dev = 1; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index b93e2df..580fe96 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -281,15 +281,7 @@ static bool virtio_pci_ioeventfd_disabled(DeviceState *d) { VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); - return proxy->ioeventfd_disabled || - !(proxy->flags & VIRTIO_PCI_FLAG_USE_IOEVENTFD); -} - -static void virtio_pci_ioeventfd_set_disabled(DeviceState *d, bool disabled) -{ - VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); - - proxy->ioeventfd_disabled = disabled; + return !(proxy->flags & VIRTIO_PCI_FLAG_USE_IOEVENTFD); } #define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 @@ -2542,7 +2534,6 @@ static void virtio_pci_bus_class_init(ObjectClass *klass, void *data) k->ioeventfd_started = virtio_pci_ioeventfd_started; k->ioeventfd_set_started = virtio_pci_ioeventfd_set_started; k->ioeventfd_disabled = virtio_pci_ioeventfd_disabled; - k->ioeventfd_set_disabled = virtio_pci_ioeventfd_set_disabled; k->ioeventfd_assign = virtio_pci_ioeventfd_assign; } diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 541cbdb..17ff195 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -158,7 +158,6 @@ struct VirtIOPCIProxy { uint32_t guest_features[2]; VirtIOPCIQueue vqs[VIRTIO_QUEUE_MAX]; - bool ioeventfd_disabled; bool ioeventfd_started; VirtIOIRQFD *vector_irqfd; int nvqs_with_notifiers; diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h index 2e4b67e..4aabec4 100644 --- a/include/hw/virtio/virtio-bus.h +++ b/include/hw/virtio/virtio-bus.h @@ -83,8 +83,6 @@ typedef struct VirtioBusClass { void (*ioeventfd_set_started)(DeviceState *d, bool started, bool err); /* Returns true if the ioeventfd has been disabled for the device. */ bool (*ioeventfd_disabled)(DeviceState *d); - /* Sets the 'ioeventfd disabled' state for the device. */ - void (*ioeventfd_set_disabled)(DeviceState *d, bool disabled); /* * Assigns/deassigns the ioeventfd backing for the transport on * the device for queue number n. Returns an error value on @@ -102,6 +100,12 @@ typedef struct VirtioBusClass { struct VirtioBusState { BusState parent_obj; + + /* + * Set if the default ioeventfd handlers are disabled by vhost + * or dataplane. + */ + bool ioeventfd_disabled; }; void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp);