Skip to content

Commit befc86a

Browse files
nxpfranklibjorn-helgaas
authored andcommitted
PCI: dwc: Use parent_bus_offset to remove need for .cpu_addr_fixup()
We know the parent_bus_offset, either computed from a DT reg property (the offset is the CPU physical addr - the 'config'/'addr_space' address on the parent bus) or from a .cpu_addr_fixup() (which may have used a host bridge window offset). Apply that parent_bus_offset instead of calling .cpu_addr_fixup() when programming the ATU. This assumes all intermediate addresses are at the same offset from the CPU physical addresses. [bhelgaas: commit log] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Frank Li <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent f3e1dcc commit befc86a

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

drivers/pci/controller/dwc/pcie-designware-ep.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ static void dw_pcie_ep_unmap_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
314314
struct dw_pcie_ep *ep = epc_get_drvdata(epc);
315315
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
316316

317-
ret = dw_pcie_find_index(ep, addr, &atu_index);
317+
ret = dw_pcie_find_index(ep, addr - pci->parent_bus_offset,
318+
&atu_index);
318319
if (ret < 0)
319320
return;
320321

@@ -333,7 +334,7 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
333334

334335
atu.func_no = func_no;
335336
atu.type = PCIE_ATU_TYPE_MEM;
336-
atu.parent_bus_addr = addr;
337+
atu.parent_bus_addr = addr - pci->parent_bus_offset;
337338
atu.pci_addr = pci_addr;
338339
atu.size = size;
339340
ret = dw_pcie_ep_outbound_atu(ep, &atu);

drivers/pci/controller/dwc/pcie-designware-host.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static void __iomem *dw_pcie_other_conf_map_bus(struct pci_bus *bus,
635635
type = PCIE_ATU_TYPE_CFG1;
636636

637637
atu.type = type;
638-
atu.parent_bus_addr = pp->cfg0_base;
638+
atu.parent_bus_addr = pp->cfg0_base - pci->parent_bus_offset;
639639
atu.pci_addr = busdev;
640640
atu.size = pp->cfg0_size;
641641

@@ -660,7 +660,7 @@ static int dw_pcie_rd_other_conf(struct pci_bus *bus, unsigned int devfn,
660660

661661
if (pp->cfg0_io_shared) {
662662
atu.type = PCIE_ATU_TYPE_IO;
663-
atu.parent_bus_addr = pp->io_base;
663+
atu.parent_bus_addr = pp->io_base - pci->parent_bus_offset;
664664
atu.pci_addr = pp->io_bus_addr;
665665
atu.size = pp->io_size;
666666

@@ -686,7 +686,7 @@ static int dw_pcie_wr_other_conf(struct pci_bus *bus, unsigned int devfn,
686686

687687
if (pp->cfg0_io_shared) {
688688
atu.type = PCIE_ATU_TYPE_IO;
689-
atu.parent_bus_addr = pp->io_base;
689+
atu.parent_bus_addr = pp->io_base - pci->parent_bus_offset;
690690
atu.pci_addr = pp->io_bus_addr;
691691
atu.size = pp->io_size;
692692

@@ -755,7 +755,7 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)
755755

756756
atu.index = i;
757757
atu.type = PCIE_ATU_TYPE_MEM;
758-
atu.parent_bus_addr = entry->res->start;
758+
atu.parent_bus_addr = entry->res->start - pci->parent_bus_offset;
759759
atu.pci_addr = entry->res->start - entry->offset;
760760

761761
/* Adjust iATU size if MSG TLP region was allocated before */
@@ -777,7 +777,7 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)
777777
if (pci->num_ob_windows > ++i) {
778778
atu.index = i;
779779
atu.type = PCIE_ATU_TYPE_IO;
780-
atu.parent_bus_addr = pp->io_base;
780+
atu.parent_bus_addr = pp->io_base - pci->parent_bus_offset;
781781
atu.pci_addr = pp->io_bus_addr;
782782
atu.size = pp->io_size;
783783

@@ -921,7 +921,7 @@ static int dw_pcie_pme_turn_off(struct dw_pcie *pci)
921921
atu.size = resource_size(pci->pp.msg_res);
922922
atu.index = pci->pp.msg_atu_index;
923923

924-
atu.parent_bus_addr = pci->pp.msg_res->start;
924+
atu.parent_bus_addr = pci->pp.msg_res->start - pci->parent_bus_offset;
925925

926926
ret = dw_pcie_prog_outbound_atu(pci, &atu);
927927
if (ret)

drivers/pci/controller/dwc/pcie-designware.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@ int dw_pcie_prog_outbound_atu(struct dw_pcie *pci,
475475
u32 retries, val;
476476
u64 limit_addr;
477477

478-
if (pci->ops && pci->ops->cpu_addr_fixup)
479-
parent_bus_addr = pci->ops->cpu_addr_fixup(pci, parent_bus_addr);
480-
481478
limit_addr = parent_bus_addr + atu->size - 1;
482479

483480
if ((limit_addr & ~pci->region_limit) != (parent_bus_addr & ~pci->region_limit) ||

0 commit comments

Comments
 (0)