From patchwork Tue Mar 3 10:39:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 9680 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n23AdMuL021475 for ; Tue, 3 Mar 2009 10:39:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752827AbZCCKjV (ORCPT ); Tue, 3 Mar 2009 05:39:21 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752868AbZCCKjU (ORCPT ); Tue, 3 Mar 2009 05:39:20 -0500 Received: from mga11.intel.com ([192.55.52.93]:5723 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752827AbZCCKjU (ORCPT ); Tue, 3 Mar 2009 05:39:20 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 03 Mar 2009 02:37:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,295,1233561600"; d="scan'208";a="435687123" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.13.189]) by fmsmga002.fm.intel.com with ESMTP; 03 Mar 2009 02:35:04 -0800 Received: from yasker by syang10-desktop with local (Exim 4.69) (envelope-from ) id 1LeS1r-0003jS-2c; Tue, 03 Mar 2009 18:39:15 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Sheng Yang Subject: [PATCH] KVM: Fix assigned device with no irq Date: Tue, 3 Mar 2009 18:39:15 +0800 Message-Id: <1236076755-14328-1-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.5.6.3 In-Reply-To: <200903031747.53086.sheng@linux.intel.com> References: <200903031747.53086.sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Some device like VF of SRIOV only support MSI-X. With this patch, SRIOV can be enabled with KVM assigned device(all kernel space patches are ready). Signed-off-by: Sheng Yang --- virt/kvm/kvm_main.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 4d2be16..ce80f3a 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -217,8 +217,11 @@ static void kvm_free_assigned_irq(struct kvm *kvm, kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id); assigned_dev->irq_source_id = -1; - if (!assigned_dev->irq_requested_type) + if (!assigned_dev->irq_requested_type) { + if (assigned_dev->dev->msi_enabled) + pci_disable_msi(assigned_dev->dev); return; + } /* * In kvm_free_device_irq, cancel_work_sync return true if: @@ -308,6 +311,10 @@ static int assigned_device_update_intx(struct kvm *kvm, if (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_INTX) return 0; + /* IRQ 0 means uninitialized here */ + if (airq->host_irq == 0) + return 0; + if (irqchip_in_kernel(kvm)) { if (!msi2intx && (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) { @@ -529,9 +536,8 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm, r = 0; } else { printk(KERN_WARNING - "kvm: failed to enable MSI device!\n"); - r = -ENOTTY; - goto out_release; + "kvm: device didn't support INTx or MSI!\n"); + r = 0; } } else { /* Non-sharing INTx mode */