1
0

401-pci-mvebu-time-out-reset-on-link-up.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From 287b9df160b6159f8d385424904f8bac501280c1 Mon Sep 17 00:00:00 2001
  2. From: Russell King <rmk+kernel@armlinux.org.uk>
  3. Date: Sat, 9 Jul 2016 10:58:16 +0100
  4. Subject: pci: mvebu: time out reset on link up
  5. If the port reports that the link is up while we are resetting, there's
  6. little point in waiting for the full duration.
  7. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
  8. ---
  9. drivers/pci/host/pci-mvebu.c | 20 ++++++++++++++------
  10. 1 file changed, 14 insertions(+), 6 deletions(-)
  11. --- a/drivers/pci/host/pci-mvebu.c
  12. +++ b/drivers/pci/host/pci-mvebu.c
  13. @@ -1167,6 +1167,7 @@ static int mvebu_pcie_powerup(struct mve
  14. if (port->reset_gpio) {
  15. u32 reset_udelay = PCI_PM_D3COLD_WAIT * 1000;
  16. + unsigned int i;
  17. of_property_read_u32(port->dn, "reset-delay-us",
  18. &reset_udelay);
  19. @@ -1174,7 +1175,13 @@ static int mvebu_pcie_powerup(struct mve
  20. udelay(100);
  21. gpiod_set_value_cansleep(port->reset_gpio, 0);
  22. - msleep(reset_udelay / 1000);
  23. + for (i = 0; i < reset_udelay; i += 1000) {
  24. + if (mvebu_pcie_link_up(port))
  25. + break;
  26. + msleep(1);
  27. + }
  28. +
  29. + printk("%s: reset completed in %dus\n", port->name, i);
  30. }
  31. return 0;
  32. @@ -1261,15 +1268,16 @@ static int mvebu_pcie_probe(struct platf
  33. if (!child)
  34. continue;
  35. - ret = mvebu_pcie_powerup(port);
  36. - if (ret < 0)
  37. - continue;
  38. -
  39. port->base = mvebu_pcie_map_registers(pdev, child, port);
  40. if (IS_ERR(port->base)) {
  41. dev_err(dev, "%s: cannot map registers\n", port->name);
  42. port->base = NULL;
  43. - mvebu_pcie_powerdown(port);
  44. + continue;
  45. + }
  46. +
  47. + ret = mvebu_pcie_powerup(port);
  48. + if (ret < 0) {
  49. + port->base = NULL;
  50. continue;
  51. }