From patchwork Wed Apr 1 08:15:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 457137 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 BC49A14011D for ; Wed, 1 Apr 2015 19:22:56 +1100 (AEDT) Received: from localhost ([::1]:42122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdDvK-0000Em-Pp for incoming@patchwork.ozlabs.org; Wed, 01 Apr 2015 04:22:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdDp8-0005cK-Cw for qemu-devel@nongnu.org; Wed, 01 Apr 2015 04:16:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdDp3-0002kc-Dk for qemu-devel@nongnu.org; Wed, 01 Apr 2015 04:16:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdDp3-0002kW-5W for qemu-devel@nongnu.org; Wed, 01 Apr 2015 04:16:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t318GLgg013259 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 1 Apr 2015 04:16:21 -0400 Received: from jason-ThinkPad-T430s.redhat.com (vpn1-6-136.pek2.redhat.com [10.72.6.136]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t318FExn006923; Wed, 1 Apr 2015 04:16:18 -0400 From: Jason Wang To: qemu-devel@nongnu.org Date: Wed, 1 Apr 2015 16:15:06 +0800 Message-Id: <1427876112-12615-13-git-send-email-jasowang@redhat.com> In-Reply-To: <1427876112-12615-1-git-send-email-jasowang@redhat.com> References: <1427876112-12615-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: cornelia.huck@de.ibm.com, Jason Wang , mst@redhat.com Subject: [Qemu-devel] [PATCH V5 12/18] virtio-pci: switch to use bus specific queue limit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Instead of depending on a macro, switch to use a bus specific queue limit. Cc: Michael S. Tsirkin Signed-off-by: Jason Wang --- hw/virtio/virtio-pci.c | 12 +++++++----- include/hw/virtio/virtio.h | 2 -- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 075b13b..e556919 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -42,6 +42,8 @@ * configuration space */ #define VIRTIO_PCI_CONFIG_SIZE(dev) VIRTIO_PCI_CONFIG_OFF(msix_enabled(dev)) +#define VIRTIO_PCI_QUEUE_MAX 64 + static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size, VirtIOPCIProxy *dev); @@ -171,7 +173,7 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy) return; } - for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { + for (n = 0; n < virtio_get_queue_max(vdev); n++) { if (!virtio_queue_get_num(vdev, n)) { continue; } @@ -207,7 +209,7 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy) return; } - for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { + for (n = 0; n < virtio_get_queue_max(vdev); n++) { if (!virtio_queue_get_num(vdev, n)) { continue; } @@ -243,11 +245,11 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) virtio_queue_set_addr(vdev, vdev->queue_sel, pa); break; case VIRTIO_PCI_QUEUE_SEL: - if (val < VIRTIO_PCI_QUEUE_MAX) + if (val < virtio_get_queue_max(vdev)) vdev->queue_sel = val; break; case VIRTIO_PCI_QUEUE_NOTIFY: - if (val < VIRTIO_PCI_QUEUE_MAX) { + if (val < virtio_get_queue_max(vdev)) { virtio_queue_notify(vdev, val); } break; @@ -748,7 +750,7 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) bool with_irqfd = msix_enabled(&proxy->pci_dev) && kvm_msi_via_irqfd_enabled(); - nvqs = MIN(nvqs, VIRTIO_PCI_QUEUE_MAX); + nvqs = MIN(nvqs, virtio_get_queue_max(vdev)); /* When deassigning, pass a consistent nvqs value * to avoid leaking notifiers. diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 91fd673..7ff40ac 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -48,8 +48,6 @@ typedef struct VirtQueueElement struct iovec out_sg[VIRTQUEUE_MAX_SIZE]; } VirtQueueElement; -#define VIRTIO_PCI_QUEUE_MAX 64 - #define VIRTIO_NO_VECTOR 0xffff #define TYPE_VIRTIO_DEVICE "virtio-device"