From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAHuv-0006it-Ik for qemu-devel@nongnu.org; Fri, 16 Aug 2013 07:10:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VAHui-0000vS-ST for qemu-devel@nongnu.org; Fri, 16 Aug 2013 07:10:05 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:61630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAHui-0000v3-MQ for qemu-devel@nongnu.org; Fri, 16 Aug 2013 07:09:52 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa1so1741669pad.5 for ; Fri, 16 Aug 2013 04:09:51 -0700 (PDT) From: Alexey Kardashevskiy Date: Fri, 16 Aug 2013 21:09:38 +1000 Message-Id: <1376651378-19410-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH v2] spapr-pci: fix config space access to support bridges List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , Alexey Kardashevskiy , Alexander Graf , qemu-ppc@nongnu.org, Paul Mackerras , =?UTF-8?q?Andreas=20F=C3=A4rber?= 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 --- 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(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 1ca35a0..91d78a6 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -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) -- 1.8.3.2