From: Le Tan Date: Wed, 2 Jul 2014 00:06:35 +0000 (+0800) Subject: pci: assign devfn to pci_dev before calling pci_device_iommu_address_space() X-Git-Tag: qemu-xen-4.5.0-rc1^2~19 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=210ec8f757f0945f0d47ecbaee43b87a7ba0c141;p=qemu-upstream-4.5-testing.git pci: assign devfn to pci_dev before calling pci_device_iommu_address_space() In function do_pci_register_device() in file hw/pci/pci.c, move the assignment of pci_dev->devfn to the position before the call to pci_device_iommu_address_space(pci_dev) which will use the value of pci_dev->devfn. Fixes: 9eda7d373e9c691c070eddcbe3467b991f67f6bd pci: Introduce helper to retrieve a PCI device's DMA address space Cc: qemu-stable@nongnu.org Signed-off-by: Le Tan Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit efc8188e9398e54567b238b756eec2cc746cd2a4) Signed-off-by: Michael Roth --- diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2a9f08eb0..e05d60cfd 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -830,6 +830,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, } pci_dev->bus = bus; + pci_dev->devfn = devfn; dma_as = pci_device_iommu_address_space(pci_dev); memory_region_init_alias(&pci_dev->bus_master_enable_region, @@ -839,7 +840,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, name); - pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; pci_config_alloc(pci_dev);