From patchwork Fri Nov 19 23:20:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 343591 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAJNL1nK010882 for ; Fri, 19 Nov 2010 23:21:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932467Ab0KSXU7 (ORCPT ); Fri, 19 Nov 2010 18:20:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38682 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932372Ab0KSXU6 (ORCPT ); Fri, 19 Nov 2010 18:20:58 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAJNKvnh005036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Nov 2010 18:20:57 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oAJNKuEA007334; Fri, 19 Nov 2010 18:20:56 -0500 From: Alex Williamson Subject: [PATCH v3 8/9] device-assignment: Make use of config_map To: kvm@vger.kernel.org, mst@redhat.com Cc: qemu-devel@nongnu.org, alex.williamson@redhat.com, chrisw@redhat.com 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> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 19 Nov 2010 23:21:02 +0000 (UTC) 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)