spapr-pci: fix config space access to support bridges
PATCH v2 1/1 spapr-pci: fix config space access to support bridges
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.
---
Does not it make sense to move spapr_pci.c from hw/ppc to hw/pci? We already do move interrupt controllers to hw/intc.
---
Changes:
v2:
* fixed coding style
* config space access traces moved out
--- hw/ppc/spapr_pci.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
hw/ppc/spapr_pci.c +1 -10
@@ -65,22 +65,13 @@ 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 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, (config_addr >>16 ) &0xff , devfn); }static uint32_t rtas_pci_cfgaddr (uint32_t arg)
Signature · 1 line
1.8.3.2
Quoted 39 lines · Alexey Kardashevskiy
spapr-pci config space accessors use
find_dev()to find a PCI device. Howeverfind_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 APIpci_find_device()function. This effectively enabled pci bridges on spapr.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Does not it make sense to move
spapr_pci.cfrom hw/ppc to hw/pci? We already do move interrupt controllers to hw/intc.---
Changes:
v2:
* fixed coding style
* config space access traces moved out
---hw/ppc/spapr_pci.c| 11 +----------1 file changed, 1 insertion(+), 10 deletions(-)hw/ppc/spapr_pci.c +0
-2@@ -65,22 +65,13 @@ 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 devfn = (config_addr >>8 ) &0xFF ;if (!phb) {return NULL ; }
hw/ppc/spapr_pci.c static PCIDevice *find_dev(sPAPREnvironment *spapr, uint64_t buid, · line 74
Quoted 10 lines
hw/ppc/spapr_pci.c +1
-8- 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, (config_addr >>16 ) &0xff , devfn);
Please put the (config_addr >> 16) into a separate variable so it's obvious what we're passing in here. Otherwise looks like a reasonably straight forward change to me, but I'd like to see an ack from Michael.
Alex
Quoted 10 lines · Alexey Kardashevskiy
spapr-pci config space accessors use
find_dev()to find a PCI device. Howeverfind_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 APIpci_find_device()function. This effectively enabled pci bridges on spapr.Signed-off-by Alexey Kardashevskiy <[email protected]>---
Quoted 2 lines
Does not it make sense to move
spapr_pci.cfrom hw/ppc to hw/pci?
It's a pci host bridge, isn't it?
If yes you can put it in hw/pci-host.
hw/pci is core code.
Quoted 43 lines
We already
do move interrupt controllers to hw/intc.---
Changes:
v2:
* fixed coding style
* config space access traces moved out--- hw/ppc/spapr_pci.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)hw/ppc/spapr_pci.c +1
-10@@ -65,22 +65,13 @@ 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 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, (config_addr >>16 ) &0xff , devfn); }static uint32_t rtas_pci_cfgaddr (uint32_t arg)Signature · 1 line
1.8.3.2