Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found

The dw_pcie_wait_for_link() function waits up to 1 second for the PCIe link
to come up and returns -ETIMEDOUT for all failures without distinguishing
cases where no device is present on the bus. But the callers may want to
just skip the failure if the device is not found on the bus and handle
failure for other reasons.

So after timeout, if the LTSSM is in Detect.Quiet or Detect.Active state,
return -ENODEV to indicate the callers that the device is not found on the
bus and return -ETIMEDOUT otherwise.

Also add kernel doc to document the parameter and return values.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Tested-by: Richard Zhu <hongxing.zhu@nxp.com>
Tested-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Link: https://patch.msgid.link/20260120-pci-dwc-suspend-rework-v4-1-2f32d5082549@oss.qualcomm.com

authored by

Manivannan Sadhasivam and committed by
Manivannan Sadhasivam
1bcf245c 68ac85fb

+19 -1
+19 -1
drivers/pci/controller/dwc/pcie-designware.c
··· 692 692 dw_pcie_writel_atu(pci, dir, index, PCIE_ATU_REGION_CTRL2, 0); 693 693 } 694 694 695 + /** 696 + * dw_pcie_wait_for_link - Wait for the PCIe link to be up 697 + * @pci: DWC instance 698 + * 699 + * Returns: 0 if link is up, -ENODEV if device is not found, -ETIMEDOUT if the 700 + * link fails to come up for other reasons. 701 + */ 695 702 int dw_pcie_wait_for_link(struct dw_pcie *pci) 696 703 { 697 - u32 offset, val; 704 + u32 offset, val, ltssm; 698 705 int retries; 699 706 700 707 /* Check if the link is up or not */ ··· 713 706 } 714 707 715 708 if (retries >= PCIE_LINK_WAIT_MAX_RETRIES) { 709 + /* 710 + * If the link is in Detect.Quiet or Detect.Active state, it 711 + * indicates that no device is detected. 712 + */ 713 + ltssm = dw_pcie_get_ltssm(pci); 714 + if (ltssm == DW_PCIE_LTSSM_DETECT_QUIET || 715 + ltssm == DW_PCIE_LTSSM_DETECT_ACT) { 716 + dev_info(pci->dev, "Device not found\n"); 717 + return -ENODEV; 718 + } 719 + 716 720 dev_info(pci->dev, "Phy link never came up\n"); 717 721 return -ETIMEDOUT; 718 722 }