Skip to content

Commit 30a3d20

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 ad879e9 commit 30a3d20

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
@@ -698,14 +698,14 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
698698
ret = apple_pcie_port_register_irqs(port);
699699
WARN_ON(ret);
700700

701-
if (link_stat & PORT_LINKSTS_UP)
702-
return 0;
703-
704-
/* start link training */
705-
writel_relaxed(PORT_LTSSMCTL_START, port->base + PORT_LTSSMCTL);
701+
link_stat = readl_relaxed(port->base + PORT_LINKSTS);
702+
if (!(link_stat & PORT_LINKSTS_UP)) {
703+
/* start link training */
704+
writel_relaxed(PORT_LTSSMCTL_START, port->base + PORT_LTSSMCTL);
706705

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

710710
return 0;
711711
}

0 commit comments

Comments
 (0)