]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
spapr-pci: fix config space access to support bridges
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Wed, 21 Aug 2013 06:02:15 +0000 (16:02 +1000)
committerAlexander Graf <agraf@suse.de>
Mon, 2 Sep 2013 08:06:42 +0000 (10:06 +0200)
spapr-pci config space accessors use find_dev() to find a PCI device.
However find_dev() only searched on a primary bus and did not do
recursive search through secondary buses so config space access was not
possible for devices other that on a primary bus.

This fixed find_dev() by using the PCI API pci_find_device() function.
This effectively enabled pci bridges on spapr.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
hw/ppc/spapr_pci.c

index 1ca35a0a72ba5bdd16fbb0821b10fcad53d98882..65be265b743efaa2c43e85ee9c73c4bf9c8d47ef 100644 (file)
@@ -65,22 +65,14 @@ static PCIDevice *find_dev(sPAPREnvironment *spapr, uint64_t buid,
 {
     sPAPRPHBState *sphb = find_phb(spapr, buid);
     PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
-    BusState *bus = BUS(phb->bus);
-    BusChild *kid;
+    int bus_num = (config_addr >> 16) & 0xFF;
     int devfn = (config_addr >> 8) & 0xFF;
 
     if (!phb) {
         return NULL;
     }
 
-    QTAILQ_FOREACH(kid, &bus->children, sibling) {
-        PCIDevice *dev = (PCIDevice *)kid->child;
-        if (dev->devfn == devfn) {
-            return dev;
-        }
-    }
-
-    return NULL;
+    return pci_find_device(phb->bus, bus_num, devfn);
 }
 
 static uint32_t rtas_pci_cfgaddr(uint32_t arg)