Skip to content

Commit d8bbeb3

Browse files
Joao Pintobjorn-helgaas
authored andcommitted
PCI: designware: Wait for iATU enable
Add a loop with timeout to make sure the iATU is really enabled before subsequent config and I/O accesses. [bhelgaas: split to separate patch, use dev_err() instead of dev_dbg()] Signed-off-by: Joao Pinto <jpinto@synopsys.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent c388de1 commit d8bbeb3

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

drivers/pci/host/pcie-designware.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
#define LINK_WAIT_USLEEP_MIN 90000
3232
#define LINK_WAIT_USLEEP_MAX 100000
3333

34-
/* Synopsis specific PCIE configuration registers */
34+
/* Parameters for the waiting for iATU enabled routine */
35+
#define LINK_WAIT_MAX_IATU_RETRIES 5
36+
#define LINK_WAIT_IATU_MIN 9000
37+
#define LINK_WAIT_IATU_MAX 10000
38+
39+
/* Synopsys-specific PCIe configuration registers */
3540
#define PCIE_PORT_LINK_CONTROL 0x710
3641
#define PORT_LINK_MODE_MASK (0x3f << 16)
3742
#define PORT_LINK_MODE_1_LANES (0x1 << 16)
@@ -157,7 +162,7 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
157162
static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index,
158163
int type, u64 cpu_addr, u64 pci_addr, u32 size)
159164
{
160-
u32 val;
165+
u32 retries, val;
161166

162167
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | index,
163168
PCIE_ATU_VIEWPORT);
@@ -174,7 +179,14 @@ static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index,
174179
* Make sure ATU enable takes effect before any subsequent config
175180
* and I/O accesses.
176181
*/
177-
val = dw_pcie_readl_rc(pp, PCIE_ATU_CR2);
182+
for (retries = 0; retries < LINK_WAIT_MAX_IATU_RETRIES; retries++) {
183+
val = dw_pcie_readl_rc(pp, PCIE_ATU_CR2);
184+
if (val == PCIE_ATU_ENABLE)
185+
return;
186+
187+
usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX);
188+
}
189+
dev_err(pp->dev, "iATU is not being enabled\n");
178190
}
179191

180192
static struct irq_chip dw_msi_irq_chip = {

0 commit comments

Comments
 (0)