Skip to content

Commit 34e68eb

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 <[email protected]>
1 parent ed5c554 commit 34e68eb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/pci/controller/pcie-apple.c

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

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

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);
744+
if (!wait_for_completion_timeout(&pcie->event, link_up_timeout * HZ / 1000))
745+
dev_warn(pcie->dev, "%pOF link didn't come up\n", np);
746+
}
747747

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

0 commit comments

Comments
 (0)