From patchwork Fri Aug 3 10:51:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 1270341 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 30B7CDF25A for ; Fri, 3 Aug 2012 10:51:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753334Ab2HCKv2 (ORCPT ); Fri, 3 Aug 2012 06:51:28 -0400 Received: from mout.web.de ([212.227.15.4]:58821 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751846Ab2HCKv1 (ORCPT ); Fri, 3 Aug 2012 06:51:27 -0400 Received: from mchn199C.mchp.siemens.de ([178.3.219.114]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0Mf0a9-1T83891cW9-00OJlF; Fri, 03 Aug 2012 12:51:25 +0200 Message-ID: <501BAD29.6080102@web.de> Date: Fri, 03 Aug 2012 12:51:21 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti CC: kvm , Alex Williamson Subject: [PATCH 1/2] pci-assign: Switch to pci_device_route_intx_to_irq interface X-Enigmail-Version: 1.4.3 X-Provags-ID: V02:K0:3p8lJA1s/0ko+SMGMuhgF6kdZtIqOp2l+K5l67+Wk9J KUXNGAyBef6MqXxQVC4p/B5zXeJgp50OvBNzG2Qx2tsZL8P/T+ GNb3JHwxXpg8ggW8sImjpa0bFzrlGCaqYgOUC3ATVSvYPASKgQ 4soMFNnYm6FonlMwJzGBxai1aAKzsugvC6kKAVJubSQY/KjmN8 bwISsm25thBP/ezTVetFg== Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Jan Kiszka Drop pci_map_irq/piix_get_irq in favor of upstream's new interface. This should also properly model disabling of the line at PCI host controller level. Signed-off-by: Jan Kiszka --- hw/device-assignment.c | 29 +++++++++++++++++++---------- hw/pc.h | 4 ---- hw/pci.c | 4 ---- hw/pci.h | 2 -- hw/piix_pci.c | 7 ------- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index cc39958..d14c327 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -115,7 +115,7 @@ typedef struct AssignedDevice { AssignedDevRegion v_addrs[PCI_NUM_REGIONS - 1]; PCIDevRegions real_device; int run; - int girq; + PCIINTxRoute intx_route; uint16_t h_segnr; uint8_t h_busnr; uint8_t h_devfn; @@ -865,21 +865,24 @@ static int assign_device(AssignedDevice *dev) static int assign_irq(AssignedDevice *dev) { struct kvm_assigned_irq assigned_irq_data; - int irq, r = 0; + PCIINTxRoute intx_route; + int r = 0; /* Interrupt PIN 0 means don't use INTx */ if (assigned_dev_pci_read_byte(&dev->dev, PCI_INTERRUPT_PIN) == 0) return 0; - irq = pci_map_irq(&dev->dev, dev->intpin); - irq = piix_get_irq(irq); + intx_route = pci_device_route_intx_to_irq(&dev->dev, 0); + assert(intx_route.mode != PCI_INTX_INVERTED); - if (dev->girq == irq) + if (dev->intx_route.mode == intx_route.mode && + dev->intx_route.irq == intx_route.irq) { return r; + } memset(&assigned_irq_data, 0, sizeof(assigned_irq_data)); assigned_irq_data.assigned_dev_id = calc_assigned_dev_id(dev); - assigned_irq_data.guest_irq = irq; + assigned_irq_data.guest_irq = intx_route.irq; if (dev->irq_requested_type) { assigned_irq_data.flags = dev->irq_requested_type; r = kvm_deassign_irq(kvm_state, &assigned_irq_data); @@ -889,6 +892,11 @@ static int assign_irq(AssignedDevice *dev) dev->irq_requested_type = 0; } + if (intx_route.mode == PCI_INTX_DISABLED) { + dev->intx_route = intx_route; + return 0; + } + retry: assigned_irq_data.flags = KVM_DEV_IRQ_GUEST_INTX; if (dev->features & ASSIGNED_DEVICE_PREFER_MSI_MASK && @@ -917,7 +925,7 @@ retry: return r; } - dev->girq = irq; + dev->intx_route = intx_route; dev->irq_requested_type = assigned_irq_data.flags; return r; } @@ -1029,7 +1037,7 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev) perror("assigned_dev_enable_msi: assign irq"); } - assigned_dev->girq = -1; + assigned_dev->intx_route.mode = PCI_INTX_DISABLED; assigned_dev->irq_requested_type = assigned_irq_data.flags; } else { assign_irq(assigned_dev); @@ -1160,7 +1168,7 @@ static void assigned_dev_update_msix(PCIDevice *pci_dev) return; } } - assigned_dev->girq = -1; + assigned_dev->intx_route.mode = PCI_INTX_DISABLED; assigned_dev->irq_requested_type = assigned_irq_data.flags; } else { assign_irq(assigned_dev); @@ -1784,7 +1792,8 @@ static int assigned_initfn(struct PCIDevice *pci_dev) e_intx = dev->dev.config[0x3d] - 1; dev->intpin = e_intx; dev->run = 0; - dev->girq = -1; + dev->intx_route.mode = PCI_INTX_DISABLED; + dev->intx_route.irq = -1; dev->h_segnr = dev->host.domain; dev->h_busnr = dev->host.bus; dev->h_devfn = PCI_DEVFN(dev->host.slot, dev->host.function); diff --git a/hw/pc.h b/hw/pc.h index a662090..5b36eb5 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -171,10 +171,6 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, extern PCIDevice *piix4_dev; int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn); -int piix_get_irq(int pin); - -int ipf_map_irq(PCIDevice *pci_dev, int irq_num); - /* vga.c */ enum vga_retrace_method { VGA_RETRACE_DUMB, diff --git a/hw/pci.c b/hw/pci.c index 5ef3453..0b22913 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1089,10 +1089,6 @@ static void pci_set_irq(void *opaque, int irq_num, int level) pci_change_irq_level(pci_dev, irq_num, change); } -int pci_map_irq(PCIDevice *pci_dev, int pin) -{ - return pci_dev->bus->map_irq(pci_dev, pin); -} /* Special hooks used by device assignment */ void pci_bus_set_route_irq_fn(PCIBus *bus, pci_route_irq_fn route_intx_to_irq) { diff --git a/hw/pci.h b/hw/pci.h index c69af01..4b6ab3d 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -274,8 +274,6 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, uint8_t attr, MemoryRegion *memory); pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num); -int pci_map_irq(PCIDevice *pci_dev, int pin); - int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t offset, uint8_t size); diff --git a/hw/piix_pci.c b/hw/piix_pci.c index a5090cb..355814f 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -435,13 +435,6 @@ static void piix3_write_config(PCIDevice *dev, } } -int piix_get_irq(int pin) -{ - if (piix3_dev) - return piix3_dev->dev.config[0x60+pin]; - return 0; -} - static void piix3_write_config_xen(PCIDevice *dev, uint32_t address, uint32_t val, int len) {