Skip to content

Commit b359748

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 8e7e689 commit b359748

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
@@ -724,14 +724,14 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
724724
ret = apple_pcie_port_register_irqs(port);
725725
WARN_ON(ret);
726726

727-
if (link_stat & PORT_LINKSTS_UP)
728-
return 0;
729-
730-
/* start link training */
731-
writel_relaxed(PORT_LTSSMCTL_START, port->base + PORT_LTSSMCTL);
727+
link_stat = readl_relaxed(port->base + PORT_LINKSTS);
728+
if (!(link_stat & PORT_LINKSTS_UP)) {
729+
/* start link training */
730+
writel_relaxed(PORT_LTSSMCTL_START, port->base + PORT_LTSSMCTL);
732731

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

736736
return 0;
737737
}

0 commit comments

Comments
 (0)