Skip to content

Commit 2d91b49

Browse files
Jisheng Zhangbjorn-helgaas
authored andcommitted
PCI: designware: Use iATU0 for cfg and IO, iATU1 for MEM
Most transactions' type are cfg0 and MEM, so the current iATU usage is not balanced: iATU0 is hot while iATU1 is rarely used. Refactor the iATU usage so we use iATU0 for cfg and IO and iATU1 for MEM. This allocation idea comes from Minghuan Lian <[email protected]>: [bhelgaas: use link with Message-ID] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Jisheng Zhang <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Acked-by: Pratyush Anand <[email protected]>
1 parent 63503c8 commit 2d91b49

File tree

1 file changed

+45
-36
lines changed

1 file changed

+45
-36
lines changed

drivers/pci/host/pcie-designware.c

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,11 @@ int dw_pcie_host_init(struct pcie_port *pp)
510510
if (pp->ops->host_init)
511511
pp->ops->host_init(pp);
512512

513+
if (!pp->ops->rd_other_conf)
514+
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
515+
PCIE_ATU_TYPE_MEM, pp->mem_mod_base,
516+
pp->mem_bus_addr, pp->mem_size);
517+
513518
dw_pcie_wr_own_conf(pp, PCI_BASE_ADDRESS_0, 4, 0);
514519

515520
/* program correct class for RC */
@@ -535,66 +540,70 @@ int dw_pcie_host_init(struct pcie_port *pp)
535540
static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
536541
u32 devfn, int where, int size, u32 *val)
537542
{
538-
int ret = PCIBIOS_SUCCESSFUL;
539-
u32 address, busdev;
543+
int ret, type;
544+
u32 address, busdev, cfg_size;
545+
u64 cpu_addr;
546+
void __iomem *va_cfg_base;
540547

541548
busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
542549
PCIE_ATU_FUNC(PCI_FUNC(devfn));
543550
address = where & ~0x3;
544551

545552
if (bus->parent->number == pp->root_bus_nr) {
546-
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
547-
PCIE_ATU_TYPE_CFG0, pp->cfg0_mod_base,
548-
busdev, pp->cfg0_size);
549-
ret = dw_pcie_cfg_read(pp->va_cfg0_base + address, where, size,
550-
val);
551-
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
552-
PCIE_ATU_TYPE_MEM, pp->mem_mod_base,
553-
pp->mem_bus_addr, pp->mem_size);
553+
type = PCIE_ATU_TYPE_CFG0;
554+
cpu_addr = pp->cfg0_mod_base;
555+
cfg_size = pp->cfg0_size;
556+
va_cfg_base = pp->va_cfg0_base;
554557
} else {
555-
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
556-
PCIE_ATU_TYPE_CFG1, pp->cfg1_mod_base,
557-
busdev, pp->cfg1_size);
558-
ret = dw_pcie_cfg_read(pp->va_cfg1_base + address, where, size,
559-
val);
560-
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
561-
PCIE_ATU_TYPE_IO, pp->io_mod_base,
562-
pp->io_bus_addr, pp->io_size);
558+
type = PCIE_ATU_TYPE_CFG1;
559+
cpu_addr = pp->cfg1_mod_base;
560+
cfg_size = pp->cfg1_size;
561+
va_cfg_base = pp->va_cfg1_base;
563562
}
564563

564+
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
565+
type, cpu_addr,
566+
busdev, cfg_size);
567+
ret = dw_pcie_cfg_read(va_cfg_base + address, where, size, val);
568+
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
569+
PCIE_ATU_TYPE_IO, pp->io_mod_base,
570+
pp->io_bus_addr, pp->io_size);
571+
565572
return ret;
566573
}
567574

568575
static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
569576
u32 devfn, int where, int size, u32 val)
570577
{
571-
int ret = PCIBIOS_SUCCESSFUL;
572-
u32 address, busdev;
578+
int ret, type;
579+
u32 address, busdev, cfg_size;
580+
u64 cpu_addr;
581+
void __iomem *va_cfg_base;
573582

574583
busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
575584
PCIE_ATU_FUNC(PCI_FUNC(devfn));
576585
address = where & ~0x3;
577586

578587
if (bus->parent->number == pp->root_bus_nr) {
579-
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
580-
PCIE_ATU_TYPE_CFG0, pp->cfg0_mod_base,
581-
busdev, pp->cfg0_size);
582-
ret = dw_pcie_cfg_write(pp->va_cfg0_base + address, where, size,
583-
val);
584-
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
585-
PCIE_ATU_TYPE_MEM, pp->mem_mod_base,
586-
pp->mem_bus_addr, pp->mem_size);
588+
type = PCIE_ATU_TYPE_CFG0;
589+
cpu_addr = pp->cfg0_mod_base;
590+
cfg_size = pp->cfg0_size;
591+
va_cfg_base = pp->va_cfg0_base;
587592
} else {
588-
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
589-
PCIE_ATU_TYPE_CFG1, pp->cfg1_mod_base,
590-
busdev, pp->cfg1_size);
591-
ret = dw_pcie_cfg_write(pp->va_cfg1_base + address, where, size,
592-
val);
593-
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
594-
PCIE_ATU_TYPE_IO, pp->io_mod_base,
595-
pp->io_bus_addr, pp->io_size);
593+
type = PCIE_ATU_TYPE_CFG1;
594+
cpu_addr = pp->cfg1_mod_base;
595+
cfg_size = pp->cfg1_size;
596+
va_cfg_base = pp->va_cfg1_base;
596597
}
597598

599+
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
600+
type, cpu_addr,
601+
busdev, cfg_size);
602+
ret = dw_pcie_cfg_write(va_cfg_base + address, where, size, val);
603+
dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
604+
PCIE_ATU_TYPE_IO, pp->io_mod_base,
605+
pp->io_bus_addr, pp->io_size);
606+
598607
return ret;
599608
}
600609

0 commit comments

Comments
 (0)