From nobody Tue Feb 10 04:16:25 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0148275B15; Wed, 7 Jan 2026 08:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767773521; cv=none; b=tI+kFMwZ+/RhnsZpZepWBuMvkpNsHT+6gUwcBtDbQpTur3IaQNrZFh2V/KAoKysuLEribbpG0sdnkKmIwiZthJaMM4g5Wh8dkKc1C8EsofKg00oX+/tONSdY/sDxjs7dXuo3L6hKiJhFJ8L2Sfov51CYKeS3RtZ9dbh1h21Y/sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767773521; c=relaxed/simple; bh=/HUbHnhoN+KoA7lEL28DWh1/9SAiXUrJsxGb+QY8XV8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IFHpIVYMyjdn3a5o72DsSDt2+8O0fx24GB1Z+z9TehOtc0FwUqaT9BfYD8DOzcvTTHd3HeM83Wj2ZgparnTxPvlQaQQJHsU8AoOYSGG8AtwmP5pr6ivea28cAx8lHDCEOX4VH7B3FN+XxK5U227cDCWltYqJtX3rKyhktFol2Xw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jHY+HZCe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jHY+HZCe" Received: by smtp.kernel.org (Postfix) with ESMTPS id 88E07C19423; Wed, 7 Jan 2026 08:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767773520; bh=/HUbHnhoN+KoA7lEL28DWh1/9SAiXUrJsxGb+QY8XV8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jHY+HZCexwIx2lJT6KaxU3IiRydHI54cXJq6LnuHxNRQnHF5XEcndawi7U+eAYPsg f6xdyrUn+42A4UaFaPYdqDwcAaiylGQO1W/q64XB4fNi+0mbccE8fqRxvETeTJV1Ce VxN0+VZC1XArezGlAbcgAqeh8huFB1ClY1tylN7oBEMwe/MQTo90IJtxGgmDAARqz9 ElhZnjTNyNWyOyzI0GYPdOSdgaPrKA4y13Kp1wuF5OMGipQOUocuVuTOMY77t1fSRK PzdC18G4WGCGF/wUExakFIkNcrbeOXT5WdURI1N/yRDmG21VCsvm21wgdlXdymYV8C YplWRl6KizVzQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 791CECF6BF4; Wed, 7 Jan 2026 08:12:00 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Wed, 07 Jan 2026 13:41:54 +0530 Subject: [PATCH v4 1/6] PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260107-pci-dwc-suspend-rework-v4-1-9b5f3c72df0a@oss.qualcomm.com> References: <20260107-pci-dwc-suspend-rework-v4-0-9b5f3c72df0a@oss.qualcomm.com> In-Reply-To: <20260107-pci-dwc-suspend-rework-v4-0-9b5f3c72df0a@oss.qualcomm.com> To: Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, vincent.guittot@linaro.org, zhangsenchuan@eswincomputing.com, Shawn Lin , Richard Zhu , Manivannan Sadhasivam X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2146; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=o/5Daxo7XavRGG4F5ekAsfAm4FYtHGKP45ahA68HQwY=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpXhVNsiYqYPnHrsxF4Lzs40U2nUYrjnT+ssLTe YDmlgNzKRCJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCaV4VTQAKCRBVnxHm/pHO 9RJ2CACHGLq4GrQ/ZaYw12uJqQNtll4VHVYi8UWhFUujmPCX23Mu8VPyTa0omkvA8b0xy7Rgqw6 8mOoUxHWK+san0A6DCXd7G6Zhue3rcesnQTy10cuVKtU+UrqoIjXNftr3tdQelaKMzWU1MiWuWd DNkpGWs5ABVOufoiZAlej46i99BhZn6tg1mEv7X0yQTfkheioiSOpR4dJ89d6rFlLALor/8s3ix g7tDx7dk/ySHbDgKQ0Z6mHTdzG5KdsWANLYvYylcUiCphlp5IiqMm7lFy0rOrWpZfKy0FwNasMe gUQhpRfxbWvups/aE7VNIOBfZmqFssR0xAe9c/O22YzHLktH X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam 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 Reviewed-by: Shawn Lin --- drivers/pci/controller/dwc/pcie-designware.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/con= troller/dwc/pcie-designware.c index 345365ea97c7..55c1c60f7f8f 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -692,9 +692,16 @@ void dw_pcie_disable_atu(struct dw_pcie *pci, u32 dir,= int index) dw_pcie_writel_atu(pci, dir, index, PCIE_ATU_REGION_CTRL2, 0); } =20 +/** + * dw_pcie_wait_for_link - Wait for the PCIe link to be up + * @pci: DWC instance + * + * Returns: 0 if link is up, -ENODEV if device is not found, -ETIMEDOUT if= the + * link fails to come up for other reasons. + */ int dw_pcie_wait_for_link(struct dw_pcie *pci) { - u32 offset, val; + u32 offset, val, ltssm; int retries; =20 /* Check if the link is up or not */ @@ -706,6 +713,17 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci) } =20 if (retries >=3D PCIE_LINK_WAIT_MAX_RETRIES) { + /* + * If the link is in Detect.Quiet or Detect.Active state, it + * indicates that no device is detected. + */ + ltssm =3D dw_pcie_get_ltssm(pci); + if (ltssm =3D=3D DW_PCIE_LTSSM_DETECT_QUIET || + ltssm =3D=3D DW_PCIE_LTSSM_DETECT_ACT) { + dev_info(pci->dev, "Device not found\n"); + return -ENODEV; + } + dev_info(pci->dev, "Phy link never came up\n"); return -ETIMEDOUT; } --=20 2.48.1