From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58027 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJaGJ-0001G6-Rp for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:21:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJaGI-0001ob-Ha for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:20:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54094) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJaGI-0001oM-Ab for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:20:58 -0500 From: Alex Williamson Date: Fri, 19 Nov 2010 16:20:56 -0700 Message-ID: <20101119232045.22162.31257.stgit@s20.home> In-Reply-To: <20101119231138.22162.93647.stgit@s20.home> References: <20101119231138.22162.93647.stgit@s20.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v3 8/9] device-assignment: Make use of config_map List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kvm@vger.kernel.org, mst@redhat.com Cc: chrisw@redhat.com, alex.williamson@redhat.com, qemu-devel@nongnu.org We can figure out the capability being touched much more quickly and efficiently with the config_map. Use it. Signed-off-by: Alex Williamson --- hw/device-assignment.c | 32 +++++++++++++++++++------------- 1 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 970ffa1..832c236 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1254,28 +1254,34 @@ static void assigned_dev_update_msix(PCIDevice *pci_dev, unsigned int ctrl_pos) static void assigned_device_pci_cap_write_config(PCIDevice *pci_dev, uint32_t address, uint32_t val, int len) { - AssignedDevice *assigned_dev = container_of(pci_dev, AssignedDevice, dev); + uint8_t cap_id = pci_dev->config_map[address]; pci_default_write_config(pci_dev, address, val, len); + switch (cap_id) { #ifdef KVM_CAP_IRQ_ROUTING + case PCI_CAP_ID_MSI: #ifdef KVM_CAP_DEVICE_MSI - if (assigned_dev->cap.available & ASSIGNED_DEVICE_CAP_MSI) { - int pos = pci_find_capability(pci_dev, PCI_CAP_ID_MSI); - if (ranges_overlap(address, len, pos + PCI_MSI_FLAGS, 1)) { - assigned_dev_update_msi(pci_dev, pos + PCI_MSI_FLAGS); + { + uint8_t cap = pci_find_capability(pci_dev, cap_id); + if (ranges_overlap(address - cap, len, PCI_MSI_FLAGS, 1)) { + assigned_dev_update_msi(pci_dev, cap + PCI_MSI_FLAGS); + } } - } #endif + break; + + case PCI_CAP_ID_MSIX: #ifdef KVM_CAP_DEVICE_MSIX - if (assigned_dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) { - int pos = pci_find_capability(pci_dev, PCI_CAP_ID_MSIX); - if (ranges_overlap(address, len, pos + PCI_MSIX_FLAGS + 1, 1)) { - assigned_dev_update_msix(pci_dev, pos + PCI_MSIX_FLAGS); - } - } + { + uint8_t cap = pci_find_capability(pci_dev, cap_id); + if (ranges_overlap(address - cap, len, PCI_MSIX_FLAGS + 1, 1)) { + assigned_dev_update_msix(pci_dev, cap + PCI_MSIX_FLAGS); + } + } #endif + break; #endif - return; + } } static int assigned_device_pci_cap_init(PCIDevice *pci_dev)