Skip to content

Commit 5be5024

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 14b8b73 commit 5be5024

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
@@ -737,14 +737,14 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
737737
ret = apple_pcie_port_register_irqs(port);
738738
WARN_ON(ret);
739739

740-
if (link_stat & PORT_LINKSTS_UP)
741-
return 0;
742-
743-
/* start link training */
744-
writel_relaxed(PORT_LTSSMCTL_START, port->base + PORT_LTSSMCTL);
740+
link_stat = readl_relaxed(port->base + PORT_LINKSTS);
741+
if (!(link_stat & PORT_LINKSTS_UP)) {
742+
/* start link training */
743+
writel_relaxed(PORT_LTSSMCTL_START, port->base + PORT_LTSSMCTL);
745744

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

749749
if (pcie->hw->port_refclk)
750750
rmw_clear(PORT_REFCLK_CGDIS, port->base + PORT_REFCLK);

0 commit comments

Comments
 (0)