Skip to content

Commit 9cdce1c

Browse files
Zhou Wangbjorn-helgaas
authored andcommitted
Revert "PCI: designware: Program ATU with untranslated address"
Revert f4c55c5 ("PCI: designware: Program ATU with untranslated address"). Note that dra7xx_pcie_host_init() now modifies pp->io_base, but we still need the original value for dw_pcie_setup() in the path below, so this adds a new io_base_tmp member. It will be removed later when dw_pcie_setup() is removed. dra7xx_add_pcie_port dw_pcie_host_init pp->io_base = range.cpu_addr pp->io_base_tmp = range.cpu_addr # <-- added pp->ops->host_init dra7xx_pcie_host_init # ops->host_init pp->io_base &= DRA7XX_CPU_TO_BUS_ADDR # <-- modified pci_common_init_dev(..., &dw_pci) pcibios_init_hw hw->setup dw_pcie_setup # hw_pci.setup pci_ioremap_io(..., pp->io_base_tmp) # <-- original addr required [bhelgaas: changelog] Tested-by: James Morse <james.morse@arm.com> Tested-by: Gabriel Fernandez <gabriel.fernandez@st.com> Tested-by: Minghuan Lian <Minghuan.Lian@freescale.com> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com> Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
1 parent 883cc17 commit 9cdce1c

3 files changed

Lines changed: 16 additions & 38 deletions

File tree

‎drivers/pci/host/pci-dra7xx.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ static void dra7xx_pcie_host_init(struct pcie_port *pp)
153153
{
154154
dw_pcie_setup_rc(pp);
155155

156-
pp->io_mod_base &= DRA7XX_CPU_TO_BUS_ADDR;
157-
pp->mem_mod_base &= DRA7XX_CPU_TO_BUS_ADDR;
158-
pp->cfg0_mod_base &= DRA7XX_CPU_TO_BUS_ADDR;
159-
pp->cfg1_mod_base &= DRA7XX_CPU_TO_BUS_ADDR;
156+
pp->io_base &= DRA7XX_CPU_TO_BUS_ADDR;
157+
pp->mem_base &= DRA7XX_CPU_TO_BUS_ADDR;
158+
pp->cfg0_base &= DRA7XX_CPU_TO_BUS_ADDR;
159+
pp->cfg1_base &= DRA7XX_CPU_TO_BUS_ADDR;
160160

161161
dra7xx_pcie_establish_link(pp);
162162
if (IS_ENABLED(CONFIG_PCI_MSI))

‎drivers/pci/host/pcie-designware.c‎

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -417,24 +417,15 @@ int dw_pcie_host_init(struct pcie_port *pp)
417417
struct of_pci_range range;
418418
struct of_pci_range_parser parser;
419419
struct resource *cfg_res;
420-
u32 val, ns;
421-
const __be32 *addrp;
422-
int i, index, ret;
423-
424-
ns = of_n_size_cells(np);
420+
u32 val;
421+
int i, ret;
425422

426423
cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
427424
if (cfg_res) {
428425
pp->cfg0_size = resource_size(cfg_res)/2;
429426
pp->cfg1_size = resource_size(cfg_res)/2;
430427
pp->cfg0_base = cfg_res->start;
431428
pp->cfg1_base = cfg_res->start + pp->cfg0_size;
432-
433-
/* Find the untranslated configuration space address */
434-
index = of_property_match_string(np, "reg-names", "config");
435-
addrp = of_get_address(np, index, NULL, NULL);
436-
pp->cfg0_mod_base = of_read_number(addrp, ns);
437-
pp->cfg1_mod_base = pp->cfg0_mod_base + pp->cfg0_size;
438429
} else if (!pp->va_cfg0_base) {
439430
dev_err(pp->dev, "missing *config* reg space\n");
440431
}
@@ -461,30 +452,20 @@ int dw_pcie_host_init(struct pcie_port *pp)
461452
pp->io_size = resource_size(&pp->io);
462453
pp->io_bus_addr = range.pci_addr;
463454
pp->io_base = range.cpu_addr;
464-
465-
/* Find the untranslated IO space address */
466-
pp->io_mod_base = range.cpu_addr;
455+
pp->io_base_tmp = range.cpu_addr;
467456
}
468457
if (restype == IORESOURCE_MEM) {
469458
of_pci_range_to_resource(&range, np, &pp->mem);
470459
pp->mem.name = "MEM";
471460
pp->mem_size = resource_size(&pp->mem);
472461
pp->mem_bus_addr = range.pci_addr;
473-
474-
/* Find the untranslated MEM space address */
475-
pp->mem_mod_base = range.cpu_addr;
476462
}
477463
if (restype == 0) {
478464
of_pci_range_to_resource(&range, np, &pp->cfg);
479465
pp->cfg0_size = resource_size(&pp->cfg)/2;
480466
pp->cfg1_size = resource_size(&pp->cfg)/2;
481467
pp->cfg0_base = pp->cfg.start;
482468
pp->cfg1_base = pp->cfg.start + pp->cfg0_size;
483-
484-
/* Find the untranslated configuration space address */
485-
pp->cfg0_mod_base = range.cpu_addr;
486-
pp->cfg1_mod_base = pp->cfg0_mod_base +
487-
pp->cfg0_size;
488469
}
489470
}
490471

@@ -555,7 +536,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
555536

556537
if (!pp->ops->rd_other_conf)
557538
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
558-
PCIE_ATU_TYPE_MEM, pp->mem_mod_base,
539+
PCIE_ATU_TYPE_MEM, pp->mem_base,
559540
pp->mem_bus_addr, pp->mem_size);
560541

561542
dw_pcie_wr_own_conf(pp, PCI_BASE_ADDRESS_0, 4, 0);
@@ -592,12 +573,12 @@ static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
592573

593574
if (bus->parent->number == pp->root_bus_nr) {
594575
type = PCIE_ATU_TYPE_CFG0;
595-
cpu_addr = pp->cfg0_mod_base;
576+
cpu_addr = pp->cfg0_base;
596577
cfg_size = pp->cfg0_size;
597578
va_cfg_base = pp->va_cfg0_base;
598579
} else {
599580
type = PCIE_ATU_TYPE_CFG1;
600-
cpu_addr = pp->cfg1_mod_base;
581+
cpu_addr = pp->cfg1_base;
601582
cfg_size = pp->cfg1_size;
602583
va_cfg_base = pp->va_cfg1_base;
603584
}
@@ -607,7 +588,7 @@ static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
607588
busdev, cfg_size);
608589
ret = dw_pcie_cfg_read(va_cfg_base + where, size, val);
609590
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
610-
PCIE_ATU_TYPE_IO, pp->io_mod_base,
591+
PCIE_ATU_TYPE_IO, pp->io_base,
611592
pp->io_bus_addr, pp->io_size);
612593

613594
return ret;
@@ -626,12 +607,12 @@ static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
626607

627608
if (bus->parent->number == pp->root_bus_nr) {
628609
type = PCIE_ATU_TYPE_CFG0;
629-
cpu_addr = pp->cfg0_mod_base;
610+
cpu_addr = pp->cfg0_base;
630611
cfg_size = pp->cfg0_size;
631612
va_cfg_base = pp->va_cfg0_base;
632613
} else {
633614
type = PCIE_ATU_TYPE_CFG1;
634-
cpu_addr = pp->cfg1_mod_base;
615+
cpu_addr = pp->cfg1_base;
635616
cfg_size = pp->cfg1_size;
636617
va_cfg_base = pp->va_cfg1_base;
637618
}
@@ -641,7 +622,7 @@ static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
641622
busdev, cfg_size);
642623
ret = dw_pcie_cfg_write(va_cfg_base + where, size, val);
643624
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
644-
PCIE_ATU_TYPE_IO, pp->io_mod_base,
625+
PCIE_ATU_TYPE_IO, pp->io_base,
645626
pp->io_bus_addr, pp->io_size);
646627

647628
return ret;
@@ -729,7 +710,7 @@ static int dw_pcie_setup(int nr, struct pci_sys_data *sys)
729710

730711
if (global_io_offset < SZ_1M && pp->io_size > 0) {
731712
sys->io_offset = global_io_offset - pp->io_bus_addr;
732-
pci_ioremap_io(global_io_offset, pp->io_base);
713+
pci_ioremap_io(global_io_offset, pp->io_base_tmp);
733714
global_io_offset += SZ_64K;
734715
pci_add_resource_offset(&sys->resources, &pp->io,
735716
sys->io_offset);

‎drivers/pci/host/pcie-designware.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,16 @@ struct pcie_port {
2727
u8 root_bus_nr;
2828
void __iomem *dbi_base;
2929
u64 cfg0_base;
30-
u64 cfg0_mod_base;
3130
void __iomem *va_cfg0_base;
3231
u32 cfg0_size;
3332
u64 cfg1_base;
34-
u64 cfg1_mod_base;
3533
void __iomem *va_cfg1_base;
3634
u32 cfg1_size;
3735
u64 io_base;
38-
u64 io_mod_base;
36+
u64 io_base_tmp;
3937
phys_addr_t io_bus_addr;
4038
u32 io_size;
4139
u64 mem_base;
42-
u64 mem_mod_base;
4340
phys_addr_t mem_bus_addr;
4441
u32 mem_size;
4542
struct resource cfg;

0 commit comments

Comments
 (0)