MLK-14796 PCI: imx: kernel panic when reboot ep board
authorRichard Zhu <hongxing.zhu@nxp.com>
Fri, 11 Jan 2019 09:24:05 +0000 (14:54 +0530)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
pp->ops is not assigned properly, thus there
would be kernel panic when reboot ep board.
Initialized pp->ops in ep initializatione,
fix this issue.
don't call dw_pcie_wait_for_link because
the usleep is used in it.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
rebase on v4.19
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
drivers/pci/controller/dwc/pci-imx6.c

index 36d0a27..7420edd 100644 (file)
@@ -665,18 +665,24 @@ static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie)
 
 static int imx6_pcie_wait_for_link(struct imx6_pcie *imx6_pcie)
 {
+       int count = 20000;
        struct dw_pcie *pci = imx6_pcie->pci;
        struct device *dev = pci->dev;
 
        /* check if the link is up or not */
-       if (!dw_pcie_wait_for_link(pci))
-               return 0;
-
-       dev_dbg(dev, "DEBUG_R0: 0x%08x, DEBUG_R1: 0x%08x\n",
-               dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R0),
-               dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R1));
+       while (!dw_pcie_link_up(pci)) {
+               udelay(10);
+               if (--count)
+                       continue;
+
+               dev_err(dev, "phy link never came up\n");
+               dev_dbg(dev, "DEBUG_R0: 0x%08x, DEBUG_R1: 0x%08x\n",
+                       dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R0),
+                       dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R1));
+               return -ETIMEDOUT;
+       }
 
-       return -ETIMEDOUT;
+       return 0;
 }
 
 static int imx6_pcie_wait_for_speed_change(struct imx6_pcie *imx6_pcie)
@@ -1444,6 +1450,7 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
                }
 
                pp->mem_base = pp->mem->start;
+               pp->ops = &imx6_pcie_host_ops;
 
                /* enable disp_mix power domain */
                if (imx6_pcie->variant == IMX7D)