Skip to content

Commit 0f71c60

Browse files
robherringLorenzo Pieralisi
authored andcommitted
PCI: dwc: Remove storing of PCI resources
The PCI bridge resources are stored in pci_host_bridge.windows, so there's no need to store them in a DWC specific struct. There's also no need to parse the resources and store them a 2nd time as they are mainly used for one time setup of iATU windows. Link: https://lore.kernel.org/r/20200821035420.380495-19-robh@kernel.org Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Murali Karicheri <m-karicheri2@ti.com> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Jonathan Chocron <jonnyc@amazon.com> Cc: Jingoo Han <jingoohan1@gmail.com> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
1 parent 5808d43 commit 0f71c60

File tree

4 files changed

+19
-29
lines changed

4 files changed

+19
-29
lines changed

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,14 @@ static void ks_pcie_setup_rc_app_regs(struct keystone_pcie *ks_pcie)
400400
u32 num_viewport = ks_pcie->num_viewport;
401401
struct dw_pcie *pci = ks_pcie->pci;
402402
struct pcie_port *pp = &pci->pp;
403-
u64 start = pp->mem->start;
404-
u64 end = pp->mem->end;
403+
u64 start, end;
404+
struct resource *mem;
405405
int i;
406406

407+
mem = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM)->res;
408+
start = mem->start;
409+
end = mem->end;
410+
407411
/* Disable BARs for inbound access */
408412
ks_pcie_set_dbi_mode(ks_pcie);
409413
dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, 0);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)
260260
u8 secondary_bus;
261261
u32 cfg_control;
262262
u32 reg;
263+
struct resource *bus = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS)->res;
263264

264265
target_bus_cfg = &pcie->target_bus_cfg;
265266

@@ -273,13 +274,13 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)
273274
target_bus_cfg->ecam_mask = ecam_bus_mask;
274275
/* This portion is taken from the cfg_target_bus reg */
275276
target_bus_cfg->reg_mask = ~target_bus_cfg->ecam_mask;
276-
target_bus_cfg->reg_val = pp->busn->start & target_bus_cfg->reg_mask;
277+
target_bus_cfg->reg_val = bus->start & target_bus_cfg->reg_mask;
277278

278279
al_pcie_target_bus_set(pcie, target_bus_cfg->reg_val,
279280
target_bus_cfg->reg_mask);
280281

281-
secondary_bus = pp->busn->start + 1;
282-
subordinate_bus = pp->busn->end;
282+
secondary_bus = bus->start + 1;
283+
subordinate_bus = bus->end;
283284

284285
/* Set the valid values of secondary and subordinate buses */
285286
cfg_control_offset = AXI_BASE_OFFSET + pcie->reg_offsets.ob_ctrl +

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,9 @@ int dw_pcie_host_init(struct pcie_port *pp)
326326
resource_list_for_each_entry(win, &bridge->windows) {
327327
switch (resource_type(win->res)) {
328328
case IORESOURCE_IO:
329-
pp->io = win->res;
330-
pp->io->name = "I/O";
331-
pp->io_size = resource_size(pp->io);
332-
pp->io_bus_addr = pp->io->start - win->offset;
333-
pp->io_base = pci_pio_to_address(pp->io->start);
334-
break;
335-
case IORESOURCE_MEM:
336-
pp->mem = win->res;
337-
pp->mem->name = "MEM";
338-
pp->mem_size = resource_size(pp->mem);
339-
pp->mem_bus_addr = pp->mem->start - win->offset;
329+
pp->io_size = resource_size(win->res);
330+
pp->io_bus_addr = win->res->start - win->offset;
331+
pp->io_base = pci_pio_to_address(win->res->start);
340332
break;
341333
case 0:
342334
pp->cfg = win->res;
@@ -345,9 +337,6 @@ int dw_pcie_host_init(struct pcie_port *pp)
345337
pp->cfg0_base = pp->cfg->start;
346338
pp->cfg1_base = pp->cfg->start + pp->cfg0_size;
347339
break;
348-
case IORESOURCE_BUS:
349-
pp->busn = win->res;
350-
break;
351340
}
352341
}
353342

@@ -361,8 +350,6 @@ int dw_pcie_host_init(struct pcie_port *pp)
361350
}
362351
}
363352

364-
pp->mem_base = pp->mem->start;
365-
366353
if (!pp->va_cfg0_base) {
367354
pp->va_cfg0_base = devm_pci_remap_cfgspace(dev,
368355
pp->cfg0_base, pp->cfg0_size);
@@ -602,9 +589,13 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
602589
* ATU, so we should not program the ATU here.
603590
*/
604591
if (pp->bridge->child_ops == &dw_child_pcie_ops) {
592+
struct resource_entry *entry =
593+
resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM);
594+
605595
dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX0,
606-
PCIE_ATU_TYPE_MEM, pp->mem_base,
607-
pp->mem_bus_addr, pp->mem_size);
596+
PCIE_ATU_TYPE_MEM, entry->res->start,
597+
entry->res->start - entry->offset,
598+
resource_size(entry->res));
608599
if (pci->num_viewport > 2)
609600
dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX2,
610601
PCIE_ATU_TYPE_IO, pp->io_base,

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,7 @@ struct pcie_port {
175175
resource_size_t io_base;
176176
phys_addr_t io_bus_addr;
177177
u32 io_size;
178-
u64 mem_base;
179-
phys_addr_t mem_bus_addr;
180-
u32 mem_size;
181178
struct resource *cfg;
182-
struct resource *io;
183-
struct resource *mem;
184-
struct resource *busn;
185179
int irq;
186180
const struct dw_pcie_host_ops *ops;
187181
int msi_irq;

0 commit comments

Comments
 (0)