From 48b91619b8d95223aad729547960ea3029344e23 Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Tue, 21 Mar 2023 17:41:14 +0800 Subject: [PATCH] PCI: rockchip: dw: Double check LTSSM We saw a link failure after linkup which should fail to probe the device actually. That was misleading for PCIe stack to scan the device. Add a double check for that. If that happened, just try to link until the timeout happened. [ 2.373308] rk-pcie fe180000.pcie: PCIe Linking... LTSSM is 0x3 [ 2.455521] rk-pcie fe180000.pcie: PCIe Link up, LTSSM is 0x2 [ 2.455658] rk-pcie fe180000.pcie: PCI host bridge to bus 0003:30 Signed-off-by: Shawn Lin Change-Id: I0f9bcbb42d77a80aa1cb533952427b71096240d6 --- drivers/pci/controller/dwc/pcie-dw-rockchip.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c index 3cd09125933b..3bcbc3a17d2f 100644 --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c @@ -815,10 +815,13 @@ static int rk_pcie_establish_link(struct dw_pcie *pci) * more for Gen switch. */ msleep(50); - dev_info(pci->dev, "PCIe Link up, LTSSM is 0x%x\n", - rk_pcie_readl_apb(rk_pcie, PCIE_CLIENT_LTSSM_STATUS)); - rk_pcie_debug_dump(rk_pcie); - return 0; + /* In case link drop after linkup, double check it */ + if (dw_pcie_link_up(pci)) { + dev_info(pci->dev, "PCIe Link up, LTSSM is 0x%x\n", + rk_pcie_readl_apb(rk_pcie, PCIE_CLIENT_LTSSM_STATUS)); + rk_pcie_debug_dump(rk_pcie); + return 0; + } } dev_info_ratelimited(pci->dev, "PCIe Linking... LTSSM is 0x%x\n",