From patchwork Thu Aug 16 13:54:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 1332231 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2637440210 for ; Thu, 16 Aug 2012 13:56:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932538Ab2HPNz6 (ORCPT ); Thu, 16 Aug 2012 09:55:58 -0400 Received: from david.siemens.de ([192.35.17.14]:34095 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757120Ab2HPNym (ORCPT ); Thu, 16 Aug 2012 09:54:42 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id q7GDsZeo007017; Thu, 16 Aug 2012 15:54:35 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q7GDsYJM012893; Thu, 16 Aug 2012 15:54:35 +0200 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Alex Williamson Subject: [PATCH 12/19] pci-assign: Factor out kvm_device_msix_assign Date: Thu, 16 Aug 2012 15:54:26 +0200 Message-Id: <9d01edf3046728cfe381d23a894efd881b1cb28f.1345125266.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Avoid passing kvm_assigned_irq on MSI-X assignment. Drop kvm_assign_irq as it's now no longer used. Signed-off-by: Jan Kiszka --- hw/device-assignment.c | 9 +-------- qemu-kvm.c | 27 --------------------------- qemu-kvm.h | 11 ----------- target-i386/kvm.c | 6 ++++++ target-i386/kvm_i386.h | 1 + 5 files changed, 8 insertions(+), 46 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 7ffd26c..32a082d 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1096,15 +1096,11 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev) static void assigned_dev_update_msix(PCIDevice *pci_dev) { - struct kvm_assigned_irq assigned_irq_data; AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev); uint16_t ctrl_word = pci_get_word(pci_dev->config + pci_dev->msix_cap + PCI_MSIX_FLAGS); int r; - memset(&assigned_irq_data, 0, sizeof assigned_irq_data); - assigned_irq_data.assigned_dev_id = assigned_dev->dev_id; - /* Some guests gratuitously disable MSIX even if they're not using it, * try to catch this by only deassigning irqs if the guest is using * MSIX or intends to start. */ @@ -1122,16 +1118,13 @@ static void assigned_dev_update_msix(PCIDevice *pci_dev) } if (ctrl_word & PCI_MSIX_FLAGS_ENABLE) { - assigned_irq_data.flags = KVM_DEV_IRQ_HOST_MSIX | - KVM_DEV_IRQ_GUEST_MSIX; - if (assigned_dev_update_msix_mmio(pci_dev) < 0) { perror("assigned_dev_update_msix_mmio"); return; } if (assigned_dev->msi_virq_nr > 0) { - if (kvm_assign_irq(kvm_state, &assigned_irq_data) < 0) { + if (kvm_device_msix_assign(kvm_state, assigned_dev->dev_id) < 0) { perror("assigned_dev_enable_msix: assign irq"); return; } diff --git a/qemu-kvm.c b/qemu-kvm.c index e45e4a7..3dc56ea 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -30,33 +30,6 @@ #define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1)) -#ifdef KVM_CAP_DEVICE_ASSIGNMENT -static int kvm_old_assign_irq(KVMState *s, - struct kvm_assigned_irq *assigned_irq) -{ - return kvm_vm_ioctl(s, KVM_ASSIGN_IRQ, assigned_irq); -} - -#ifdef KVM_CAP_ASSIGN_DEV_IRQ -int kvm_assign_irq(KVMState *s, struct kvm_assigned_irq *assigned_irq) -{ - int ret; - - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_ASSIGN_DEV_IRQ); - if (ret > 0) { - return kvm_vm_ioctl(s, KVM_ASSIGN_DEV_IRQ, assigned_irq); - } - - return kvm_old_assign_irq(s, assigned_irq); -} -#else -int kvm_assign_irq(KVMState *s, struct kvm_assigned_irq *assigned_irq) -{ - return kvm_old_assign_irq(s, assigned_irq); -} -#endif -#endif - #if !defined(TARGET_I386) void kvm_arch_init_irq_routing(KVMState *s) { diff --git a/qemu-kvm.h b/qemu-kvm.h index ae7a33c..f7d9cd5 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -32,17 +32,6 @@ #include "kvm.h" -/*! - * \brief Assign IRQ for an assigned device - * - * Used for PCI device assignment, this function assigns IRQ numbers for - * an physical device and guest IRQ handling. - * - * \param kvm Pointer to the current kvm_context - * \param assigned_irq Parameters, like dev id, host irq, guest irq, etc - */ -int kvm_assign_irq(KVMState *s, struct kvm_assigned_irq *assigned_irq); - #endif /* CONFIG_KVM */ #endif diff --git a/target-i386/kvm.c b/target-i386/kvm.c index e9353ed..67635af 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -2186,6 +2186,12 @@ int kvm_device_msix_set_vector(KVMState *s, uint32_t dev_id, uint32_t vector, return kvm_vm_ioctl(s, KVM_ASSIGN_SET_MSIX_ENTRY, &msix_entry); } +int kvm_device_msix_assign(KVMState *s, uint32_t dev_id) +{ + return kvm_assign_irq_internal(s, dev_id, KVM_DEV_IRQ_HOST_MSIX | + KVM_DEV_IRQ_GUEST_MSIX, 0); +} + int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id) { return kvm_deassign_irq_internal(s, dev_id, KVM_DEV_IRQ_GUEST_MSIX | diff --git a/target-i386/kvm_i386.h b/target-i386/kvm_i386.h index bd3b398..f6ab82f 100644 --- a/target-i386/kvm_i386.h +++ b/target-i386/kvm_i386.h @@ -32,6 +32,7 @@ int kvm_device_msix_init_vectors(KVMState *s, uint32_t dev_id, uint32_t nr_vectors); int kvm_device_msix_set_vector(KVMState *s, uint32_t dev_id, uint32_t vector, int virq); +int kvm_device_msix_assign(KVMState *s, uint32_t dev_id); int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id); #endif