From patchwork Fri Aug 17 06:59:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 1337461 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A4691E0000 for ; Fri, 17 Aug 2012 06:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030542Ab2HQG7d (ORCPT ); Fri, 17 Aug 2012 02:59:33 -0400 Received: from goliath.siemens.de ([192.35.17.28]:32218 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964893Ab2HQG71 (ORCPT ); Fri, 17 Aug 2012 02:59:27 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id q7H6xO0j011308; Fri, 17 Aug 2012 08:59:24 +0200 Received: from mchn199C.mchp.siemens.de.com ([146.254.78.141]) by mail1.siemens.de (8.13.6/8.13.6) with SMTP id q7H6xF74015872; Fri, 17 Aug 2012 08:59:23 +0200 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Alex Williamson , "Michael S. Tsirkin" Subject: [PATCH v2 13/20] pci-assign: Factor out kvm_device_msix_assign Date: Fri, 17 Aug 2012 08:59:01 +0200 Message-Id: <417190fd31ffaac867273f06f2cb1c741ea25469.1345186746.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 a0adda0..5e2d4f5 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -2185,6 +2185,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