From patchwork Tue Mar 17 03:50:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 12535 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 n2H3pZdC014488 for ; Tue, 17 Mar 2009 03:51:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762725AbZCQDu2 (ORCPT ); Mon, 16 Mar 2009 23:50:28 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762712AbZCQDu0 (ORCPT ); Mon, 16 Mar 2009 23:50:26 -0400 Received: from mga01.intel.com ([192.55.52.88]:8708 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762688AbZCQDuX (ORCPT ); Mon, 16 Mar 2009 23:50:23 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 16 Mar 2009 20:42:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,375,1233561600"; d="scan'208";a="673489738" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.13.189]) by fmsmga001.fm.intel.com with ESMTP; 16 Mar 2009 20:54:06 -0700 Received: from yasker by syang10-desktop with local (Exim 4.69) (envelope-from ) id 1LjQJl-0007HJ-Oh; Tue, 17 Mar 2009 11:50:17 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti , Anthony Liguori Cc: kvm@vger.kernel.org, Marcelo Tosatti , Sheng Yang Subject: [PATCH 02/16] kvm: deassign irq for INTx Date: Tue, 17 Mar 2009 11:50:03 +0800 Message-Id: <1237261817-27955-3-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.5.6.3 In-Reply-To: <1237261817-27955-1-git-send-email-sheng@linux.intel.com> References: <1237261817-27955-1-git-send-email-sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Marcelo Tosatti Also add irq_requested_type for assigned device to track current status. Signed-off-by: Marcelo Tosatti Signed-off-by: Sheng Yang --- qemu/hw/device-assignment.c | 12 ++++++++++++ qemu/hw/device-assignment.h | 1 + 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c index 7c73210..4ec655c 100644 --- a/qemu/hw/device-assignment.c +++ b/qemu/hw/device-assignment.c @@ -536,6 +536,17 @@ static int assign_irq(AssignedDevInfo *adev) calc_assigned_dev_id(dev->h_busnr, dev->h_devfn); assigned_irq_data.guest_irq = irq; assigned_irq_data.host_irq = dev->real_device.irq; +#ifdef KVM_CAP_ASSIGN_DEV_IRQ + if (dev->irq_requested_type) { + assigned_irq_data.flags = dev->irq_requested_type; + r = kvm_deassign_irq(kvm_context, &assigned_irq_data); + /* -ENXIO means no assigned irq */ + if (r && r != -ENXIO) + perror("assign_irq: deassign"); + } + assigned_irq_data.flags = KVM_DEV_IRQ_HOST_INTX | KVM_DEV_IRQ_GUEST_INTX; +#endif + r = kvm_assign_irq(kvm_context, &assigned_irq_data); if (r < 0) { fprintf(stderr, "Failed to assign irq for \"%s\": %s\n", @@ -546,6 +557,7 @@ static int assign_irq(AssignedDevInfo *adev) } dev->girq = irq; + dev->irq_requested_type = assigned_irq_data.flags; return r; } diff --git a/qemu/hw/device-assignment.h b/qemu/hw/device-assignment.h index da775d7..e648240 100644 --- a/qemu/hw/device-assignment.h +++ b/qemu/hw/device-assignment.h @@ -79,6 +79,7 @@ typedef struct { int girq; unsigned char h_busnr; unsigned int h_devfn; + int irq_requested_type; int bound; } AssignedDevice;