From patchwork Mon Sep 1 05:41:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 4816471 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3A96CC0338 for ; Mon, 1 Sep 2014 05:42:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 648E6200F4 for ; Mon, 1 Sep 2014 05:42:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 517F5200F0 for ; Mon, 1 Sep 2014 05:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751195AbaIAFmE (ORCPT ); Mon, 1 Sep 2014 01:42:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9686 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078AbaIAFmD (ORCPT ); Mon, 1 Sep 2014 01:42:03 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s815fv5A023583 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 1 Sep 2014 01:41:58 -0400 Received: from zen.nay.redhat.com ([10.66.70.124]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s815fsfx014461; Mon, 1 Sep 2014 01:41:55 -0400 From: Amos Kong To: virtualization@lists.linux-foundation.org Cc: rusty@rustcorp.com.au, mst@redhat.com, kvm@vger.kernel.org, jasowang@redhat.com Subject: [PATCH RFC] virtio-pci: share config interrupt between virtio devices Date: Mon, 1 Sep 2014 13:41:54 +0800 Message-Id: <1409550114-8186-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP One VM only has 128 msix interrupt, virtio-config interrupt has less workload. This patch shares one normal interrupt for configuration between virtio devices. Signed-off-by: Amos Kong --- drivers/virtio/virtio_pci.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index 3d1463c..b1263b3 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c @@ -52,6 +52,7 @@ struct virtio_pci_device /* Name strings for interrupts. This size should be enough, * and I'm too lazy to allocate each name separately. */ char (*msix_names)[256]; + char config_msix_name[256]; /* Number of available vectors */ unsigned msix_vectors; /* Vectors allocated, excluding per-vq vectors if any */ @@ -282,12 +283,6 @@ static void vp_free_vectors(struct virtio_device *vdev) free_cpumask_var(vp_dev->msix_affinity_masks[i]); if (vp_dev->msix_enabled) { - /* Disable the vector used for configuration */ - iowrite16(VIRTIO_MSI_NO_VECTOR, - vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR); - /* Flush the write out to device */ - ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR); - pci_disable_msix(vp_dev->pci_dev); vp_dev->msix_enabled = 0; } @@ -339,24 +334,18 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors, goto error; vp_dev->msix_enabled = 1; - /* Set the vector used for configuration */ - v = vp_dev->msix_used_vectors; - snprintf(vp_dev->msix_names[v], sizeof *vp_dev->msix_names, + /* Set shared IRQ for configuration */ + snprintf(vp_dev->config_msix_name, sizeof(*vp_dev->msix_names), "%s-config", name); - err = request_irq(vp_dev->msix_entries[v].vector, - vp_config_changed, 0, vp_dev->msix_names[v], + err = request_irq(vp_dev->pci_dev->irq, + vp_config_changed, + IRQF_SHARED, + vp_dev->config_msix_name, vp_dev); - if (err) - goto error; - ++vp_dev->msix_used_vectors; - - iowrite16(v, vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR); - /* Verify we had enough resources to assign the vector */ - v = ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR); - if (v == VIRTIO_MSI_NO_VECTOR) { - err = -EBUSY; + if (!err) + vp_dev->intx_enabled = 1; + else goto error; - } if (!per_vq_vectors) { /* Shared vector for all VQs */ @@ -535,14 +524,16 @@ static int vp_try_to_find_vqs(struct virtio_device *vdev, unsigned nvqs, goto error_request; } else { if (per_vq_vectors) { - /* Best option: one for change interrupt, one per vq. */ - nvectors = 1; + /* Best option: one normal interrupt for change, + one msix per vq. */ + nvectors = 0; for (i = 0; i < nvqs; ++i) if (callbacks[i]) ++nvectors; } else { - /* Second best: one for change, shared for all vqs. */ - nvectors = 2; + /* Second best: one normal interrupt for + change, share one msix for all vqs. */ + nvectors = 1; } err = vp_request_msix_vectors(vdev, nvectors, per_vq_vectors);