Skip to content

Commit 975d812

Browse files
marcanjannau
authored andcommitted
PCI: apple: Reorder & improve link-up logic
Always re-check LINKSTS right before deciding whether to start the link training and wait for it, just in case the link happened to come up while we were setting up IRQs. Also, always do the clock-gate disable even if the link is already up. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 035d7af commit 975d812

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/pci/controller/pcie-apple.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,14 +702,14 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
702702
ret = apple_pcie_port_register_irqs(port);
703703
WARN_ON(ret);
704704

705-
if (link_stat & PORT_LINKSTS_UP)
706-
return 0;
707-
708-
/* start link training */
709-
writel_relaxed(PORT_LTSSMCTL_START, port->base + PORT_LTSSMCTL);
705+
link_stat = readl_relaxed(port->base + PORT_LINKSTS);
706+
if (!(link_stat & PORT_LINKSTS_UP)) {
707+
/* start link training */
708+
writel_relaxed(PORT_LTSSMCTL_START, port->base + PORT_LTSSMCTL);
710709

711-
if (!wait_for_completion_timeout(&pcie->event, link_up_timeout * HZ / 1000))
712-
dev_warn(pcie->dev, "%pOF link didn't come up\n", np);
710+
if (!wait_for_completion_timeout(&pcie->event, link_up_timeout * HZ / 1000))
711+
dev_warn(pcie->dev, "%pOF link didn't come up\n", np);
712+
}
713713

714714
return 0;
715715
}

0 commit comments

Comments
 (0)