From f2039834bee36908f0af49981eb1bfd4641a017f Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Wed, 16 Sep 2015 16:03:50 +0200 Subject: [PATCH 08/22] spapr_pci: Rework device-tree rendering Message-id: <1442419432-8537-4-git-send-email-lvivier@redhat.com> Patchwork-id: 67782 O-Subject: [RHEL7.2 qemu-kvm-rhev PATCH 3/5] spapr_pci: Rework device-tree rendering Bugzilla: 1263795 RH-Acked-by: Laszlo Ersek RH-Acked-by: Thomas Huth RH-Acked-by: David Gibson From: Alexey Kardashevskiy This replaces object_child_foreach() and callback with existing SPAPR_PCI_LIOBN() and spapr_tce_find_by_liobn() to make the code easier to read. This is a mechanical patch so no behaviour change is expected. Signed-off-by: Alexey Kardashevskiy Signed-off-by: David Gibson Signed-off-by: Alexander Graf (cherry picked from commit ccf9ff8527a87ee485fbb6a0a73d28641cab5f60) Signed-off-by: Miroslav Rezanina Conflicts: hw/ppc/spapr_pci.c Conflicts in context because of out of order commit: cc183c2 spapr_pci: enable basic hotplug operations Signed-off-by: Laurent Vivier BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1250326 --- hw/ppc/spapr_pci.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 1f98046..71439c7 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1484,29 +1484,6 @@ PCIHostState *spapr_create_phb(sPAPRMachineState *spapr, int index) return PCI_HOST_BRIDGE(dev); } -typedef struct sPAPRTCEDT { - void *fdt; - int node_off; -} sPAPRTCEDT; - -static int spapr_phb_children_dt(Object *child, void *opaque) -{ - sPAPRTCEDT *p = opaque; - sPAPRTCETable *tcet; - - tcet = (sPAPRTCETable *) object_dynamic_cast(child, TYPE_SPAPR_TCE_TABLE); - if (!tcet || SPAPR_PCI_DMA_WINDOW_NUM(tcet->liobn)) { - return 0; - } - - spapr_dma_dt(p->fdt, p->node_off, "ibm,dma-window", - tcet->liobn, tcet->bus_offset, - tcet->nb_table << tcet->page_shift); - /* Stop after the first window */ - - return 1; -} - int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, void *fdt) @@ -1545,6 +1522,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t interrupt_map_mask[] = { cpu_to_be32(b_ddddd(-1)|b_fff(0)), 0x0, 0x0, cpu_to_be32(-1)}; uint32_t interrupt_map[PCI_SLOT_MAX * PCI_NUM_PINS][7]; + sPAPRTCETable *tcet; /* Start populating the FDT */ sprintf(nodename, "pci@%" PRIx64, phb->buid); @@ -1589,8 +1567,10 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, _FDT(fdt_setprop(fdt, bus_off, "interrupt-map", &interrupt_map, sizeof(interrupt_map))); - object_child_foreach(OBJECT(phb), spapr_phb_children_dt, - &((sPAPRTCEDT){ .fdt = fdt, .node_off = bus_off })); + tcet = spapr_tce_find_by_liobn(SPAPR_PCI_LIOBN(phb->index, 0)); + spapr_dma_dt(fdt, bus_off, "ibm,dma-window", + tcet->liobn, tcet->bus_offset, + tcet->nb_table << tcet->page_shift); ret = spapr_drc_populate_dt(fdt, bus_off, OBJECT(phb), SPAPR_DR_CONNECTOR_TYPE_PCI); -- 1.8.3.1