* [PATCH v4 1/6] PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:11 ` Manivannan Sadhasivam via B4 Relay
2026-01-07 8:34 ` Shawn Lin
2026-01-07 8:11 ` [PATCH v4 2/6] PCI: dwc: Rename and move ltssm_status_string() to pcie-designware.c Manivannan Sadhasivam via B4 Relay
` (7 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2026-01-07 8:11 UTC (permalink / raw)
To: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, vincent.guittot, zhangsenchuan,
Shawn Lin, Richard Zhu, Manivannan Sadhasivam
From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
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>
---
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/controller/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);
}
+/**
+ * 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;
/* Check if the link is up or not */
@@ -706,6 +713,17 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
}
if (retries >= PCIE_LINK_WAIT_MAX_RETRIES) {
+ /*
+ * If the link is in Detect.Quiet or Detect.Active state, it
+ * indicates that no device is detected.
+ */
+ ltssm = dw_pcie_get_ltssm(pci);
+ if (ltssm == DW_PCIE_LTSSM_DETECT_QUIET ||
+ ltssm == 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;
}
--
2.48.1
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH v4 1/6] PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found
2026-01-07 8:11 ` [PATCH v4 1/6] PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:34 ` Shawn Lin
0 siblings, 0 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-07 8:34 UTC (permalink / raw)
To: manivannan.sadhasivam, Jingoo Han, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas
Cc: shawn.lin, linux-pci, linux-kernel, vincent.guittot,
zhangsenchuan, Richard Zhu
在 2026/01/07 星期三 16:11, Manivannan Sadhasivam via B4 Relay 写道:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> 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.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> 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/controller/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);
> }
>
> +/**
> + * 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;
>
> /* Check if the link is up or not */
> @@ -706,6 +713,17 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
> }
>
> if (retries >= PCIE_LINK_WAIT_MAX_RETRIES) {
> + /*
> + * If the link is in Detect.Quiet or Detect.Active state, it
> + * indicates that no device is detected.
> + */
> + ltssm = dw_pcie_get_ltssm(pci);
> + if (ltssm == DW_PCIE_LTSSM_DETECT_QUIET ||
> + ltssm == 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;
> }
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v4 2/6] PCI: dwc: Rename and move ltssm_status_string() to pcie-designware.c
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
2026-01-07 8:11 ` [PATCH v4 1/6] PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:11 ` Manivannan Sadhasivam via B4 Relay
2026-01-07 8:35 ` Shawn Lin
2026-01-07 8:11 ` [PATCH v4 3/6] PCI: dwc: Rework the error print of dw_pcie_wait_for_link() Manivannan Sadhasivam via B4 Relay
` (6 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2026-01-07 8:11 UTC (permalink / raw)
To: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, vincent.guittot, zhangsenchuan,
Shawn Lin, Richard Zhu, Manivannan Sadhasivam
From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Rename ltssm_status_string() to dw_pcie_ltssm_status_string() and move it
to the common file pcie-designware.c so that this function could be used
outside of pcie-designware-debugfs.c file.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
---
.../pci/controller/dwc/pcie-designware-debugfs.c | 54 +---------------------
drivers/pci/controller/dwc/pcie-designware.c | 52 +++++++++++++++++++++
drivers/pci/controller/dwc/pcie-designware.h | 2 +
3 files changed, 55 insertions(+), 53 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
index df98fee69892..0d1340c9b364 100644
--- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
+++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
@@ -443,65 +443,13 @@ static ssize_t counter_value_read(struct file *file, char __user *buf,
return simple_read_from_buffer(buf, count, ppos, debugfs_buf, pos);
}
-static const char *ltssm_status_string(enum dw_pcie_ltssm ltssm)
-{
- const char *str;
-
- switch (ltssm) {
-#define DW_PCIE_LTSSM_NAME(n) case n: str = #n; break
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_QUIET);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_ACT);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_ACTIVE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_COMPLIANCE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_CONFIG);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_PRE_DETECT_QUIET);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_WAIT);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LINKWD_START);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LINKWD_ACEPT);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LANENUM_WAI);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LANENUM_ACEPT);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_COMPLETE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_IDLE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_LOCK);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_SPEED);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_RCVRCFG);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_IDLE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L0);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L0S);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L123_SEND_EIDLE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_IDLE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L2_IDLE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L2_WAKE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED_ENTRY);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED_IDLE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_ENTRY);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_ACTIVE);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_EXIT);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_EXIT_TIMEOUT);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_HOT_RESET_ENTRY);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_HOT_RESET);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ0);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ1);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ2);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ3);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_1);
- DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_2);
- default:
- str = "DW_PCIE_LTSSM_UNKNOWN";
- break;
- }
-
- return str + strlen("DW_PCIE_LTSSM_");
-}
-
static int ltssm_status_show(struct seq_file *s, void *v)
{
struct dw_pcie *pci = s->private;
enum dw_pcie_ltssm val;
val = dw_pcie_get_ltssm(pci);
- seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
+ seq_printf(s, "%s (0x%02x)\n", dw_pcie_ltssm_status_string(val), val);
return 0;
}
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 55c1c60f7f8f..87f2ebc134d6 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -692,6 +692,58 @@ 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);
}
+const char *dw_pcie_ltssm_status_string(enum dw_pcie_ltssm ltssm)
+{
+ const char *str;
+
+ switch (ltssm) {
+#define DW_PCIE_LTSSM_NAME(n) case n: str = #n; break
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_QUIET);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_ACT);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_ACTIVE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_COMPLIANCE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_CONFIG);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_PRE_DETECT_QUIET);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_WAIT);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LINKWD_START);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LINKWD_ACEPT);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LANENUM_WAI);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LANENUM_ACEPT);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_COMPLETE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_IDLE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_LOCK);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_SPEED);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_RCVRCFG);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_IDLE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L0);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L0S);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L123_SEND_EIDLE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_IDLE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L2_IDLE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L2_WAKE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED_ENTRY);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED_IDLE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_ENTRY);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_ACTIVE);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_EXIT);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_EXIT_TIMEOUT);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_HOT_RESET_ENTRY);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_HOT_RESET);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ0);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ1);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ2);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ3);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_1);
+ DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_2);
+ default:
+ str = "DW_PCIE_LTSSM_UNKNOWN";
+ break;
+ }
+
+ return str + strlen("DW_PCIE_LTSSM_");
+}
+
/**
* dw_pcie_wait_for_link - Wait for the PCIe link to be up
* @pci: DWC instance
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index f87c67a7a482..c1def4d9cf62 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -828,6 +828,8 @@ static inline enum dw_pcie_ltssm dw_pcie_get_ltssm(struct dw_pcie *pci)
return (enum dw_pcie_ltssm)FIELD_GET(PORT_LOGIC_LTSSM_STATE_MASK, val);
}
+const char *dw_pcie_ltssm_status_string(enum dw_pcie_ltssm ltssm);
+
#ifdef CONFIG_PCIE_DW_HOST
int dw_pcie_suspend_noirq(struct dw_pcie *pci);
int dw_pcie_resume_noirq(struct dw_pcie *pci);
--
2.48.1
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH v4 2/6] PCI: dwc: Rename and move ltssm_status_string() to pcie-designware.c
2026-01-07 8:11 ` [PATCH v4 2/6] PCI: dwc: Rename and move ltssm_status_string() to pcie-designware.c Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:35 ` Shawn Lin
0 siblings, 0 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-07 8:35 UTC (permalink / raw)
To: manivannan.sadhasivam, Jingoo Han, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas
Cc: shawn.lin, linux-pci, linux-kernel, vincent.guittot,
zhangsenchuan, Richard Zhu
在 2026/01/07 星期三 16:11, Manivannan Sadhasivam via B4 Relay 写道:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> Rename ltssm_status_string() to dw_pcie_ltssm_status_string() and move it
> to the common file pcie-designware.c so that this function could be used
> outside of pcie-designware-debugfs.c file.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> .../pci/controller/dwc/pcie-designware-debugfs.c | 54 +---------------------
> drivers/pci/controller/dwc/pcie-designware.c | 52 +++++++++++++++++++++
> drivers/pci/controller/dwc/pcie-designware.h | 2 +
> 3 files changed, 55 insertions(+), 53 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> index df98fee69892..0d1340c9b364 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> @@ -443,65 +443,13 @@ static ssize_t counter_value_read(struct file *file, char __user *buf,
> return simple_read_from_buffer(buf, count, ppos, debugfs_buf, pos);
> }
>
> -static const char *ltssm_status_string(enum dw_pcie_ltssm ltssm)
> -{
> - const char *str;
> -
> - switch (ltssm) {
> -#define DW_PCIE_LTSSM_NAME(n) case n: str = #n; break
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_QUIET);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_ACT);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_ACTIVE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_COMPLIANCE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_CONFIG);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_PRE_DETECT_QUIET);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_WAIT);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LINKWD_START);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LINKWD_ACEPT);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LANENUM_WAI);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LANENUM_ACEPT);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_COMPLETE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_IDLE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_LOCK);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_SPEED);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_RCVRCFG);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_IDLE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L0);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L0S);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L123_SEND_EIDLE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_IDLE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L2_IDLE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L2_WAKE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED_ENTRY);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED_IDLE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_ENTRY);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_ACTIVE);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_EXIT);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_EXIT_TIMEOUT);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_HOT_RESET_ENTRY);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_HOT_RESET);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ0);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ1);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ2);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ3);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_1);
> - DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_2);
> - default:
> - str = "DW_PCIE_LTSSM_UNKNOWN";
> - break;
> - }
> -
> - return str + strlen("DW_PCIE_LTSSM_");
> -}
> -
> static int ltssm_status_show(struct seq_file *s, void *v)
> {
> struct dw_pcie *pci = s->private;
> enum dw_pcie_ltssm val;
>
> val = dw_pcie_get_ltssm(pci);
> - seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
> + seq_printf(s, "%s (0x%02x)\n", dw_pcie_ltssm_status_string(val), val);
>
> return 0;
> }
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 55c1c60f7f8f..87f2ebc134d6 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -692,6 +692,58 @@ 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);
> }
>
> +const char *dw_pcie_ltssm_status_string(enum dw_pcie_ltssm ltssm)
> +{
> + const char *str;
> +
> + switch (ltssm) {
> +#define DW_PCIE_LTSSM_NAME(n) case n: str = #n; break
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_QUIET);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_ACT);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_ACTIVE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_COMPLIANCE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_POLL_CONFIG);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_PRE_DETECT_QUIET);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DETECT_WAIT);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LINKWD_START);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LINKWD_ACEPT);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LANENUM_WAI);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_LANENUM_ACEPT);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_COMPLETE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_CFG_IDLE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_LOCK);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_SPEED);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_RCVRCFG);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_IDLE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L0);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L0S);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L123_SEND_EIDLE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_IDLE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L2_IDLE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L2_WAKE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED_ENTRY);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED_IDLE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_DISABLED);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_ENTRY);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_ACTIVE);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_EXIT);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_LPBK_EXIT_TIMEOUT);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_HOT_RESET_ENTRY);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_HOT_RESET);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ0);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ1);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ2);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_RCVRY_EQ3);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_1);
> + DW_PCIE_LTSSM_NAME(DW_PCIE_LTSSM_L1_2);
> + default:
> + str = "DW_PCIE_LTSSM_UNKNOWN";
> + break;
> + }
> +
> + return str + strlen("DW_PCIE_LTSSM_");
> +}
> +
> /**
> * dw_pcie_wait_for_link - Wait for the PCIe link to be up
> * @pci: DWC instance
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index f87c67a7a482..c1def4d9cf62 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -828,6 +828,8 @@ static inline enum dw_pcie_ltssm dw_pcie_get_ltssm(struct dw_pcie *pci)
> return (enum dw_pcie_ltssm)FIELD_GET(PORT_LOGIC_LTSSM_STATE_MASK, val);
> }
>
> +const char *dw_pcie_ltssm_status_string(enum dw_pcie_ltssm ltssm);
> +
> #ifdef CONFIG_PCIE_DW_HOST
> int dw_pcie_suspend_noirq(struct dw_pcie *pci);
> int dw_pcie_resume_noirq(struct dw_pcie *pci);
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v4 3/6] PCI: dwc: Rework the error print of dw_pcie_wait_for_link()
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
2026-01-07 8:11 ` [PATCH v4 1/6] PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found Manivannan Sadhasivam via B4 Relay
2026-01-07 8:11 ` [PATCH v4 2/6] PCI: dwc: Rename and move ltssm_status_string() to pcie-designware.c Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:11 ` Manivannan Sadhasivam via B4 Relay
2026-01-07 8:38 ` Shawn Lin
2026-01-07 8:11 ` [PATCH v4 4/6] PCI: dwc: Only skip the dw_pcie_wait_for_link() failure if it returns -ENODEV Manivannan Sadhasivam via B4 Relay
` (5 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2026-01-07 8:11 UTC (permalink / raw)
To: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, vincent.guittot, zhangsenchuan,
Shawn Lin, Richard Zhu, Manivannan Sadhasivam
From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
If the link fails to come up even after detecting the device on the bus
i.e., if the LTSSM is not in Detect.Quiet and Detect.Active states, then
dw_pcie_wait_for_link() should log it as an error.
So promote dev_info() to dev_err(), reword the error log to make it clear
and also print the LTSSM state to aid debugging.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
---
drivers/pci/controller/dwc/pcie-designware.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 87f2ebc134d6..c2dfadc53d04 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -776,7 +776,8 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
return -ENODEV;
}
- dev_info(pci->dev, "Phy link never came up\n");
+ dev_err(pci->dev, "Link failed to come up. LTSSM: %s\n",
+ dw_pcie_ltssm_status_string(ltssm));
return -ETIMEDOUT;
}
--
2.48.1
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH v4 3/6] PCI: dwc: Rework the error print of dw_pcie_wait_for_link()
2026-01-07 8:11 ` [PATCH v4 3/6] PCI: dwc: Rework the error print of dw_pcie_wait_for_link() Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:38 ` Shawn Lin
2026-01-07 9:09 ` Manivannan Sadhasivam
0 siblings, 1 reply; 18+ messages in thread
From: Shawn Lin @ 2026-01-07 8:38 UTC (permalink / raw)
To: manivannan.sadhasivam, Jingoo Han, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas
Cc: shawn.lin, linux-pci, linux-kernel, vincent.guittot,
zhangsenchuan, Richard Zhu
在 2026/01/07 星期三 16:11, Manivannan Sadhasivam via B4 Relay 写道:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> If the link fails to come up even after detecting the device on the bus
> i.e., if the LTSSM is not in Detect.Quiet and Detect.Active states, then
> dw_pcie_wait_for_link() should log it as an error.
>
> So promote dev_info() to dev_err(), reword the error log to make it clear
> and also print the LTSSM state to aid debugging.
LTSSM might still be changing, so not sure how much value it would be
to print it at a singal moment, but anyway
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> drivers/pci/controller/dwc/pcie-designware.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 87f2ebc134d6..c2dfadc53d04 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -776,7 +776,8 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
> return -ENODEV;
> }
>
> - dev_info(pci->dev, "Phy link never came up\n");
> + dev_err(pci->dev, "Link failed to come up. LTSSM: %s\n",
> + dw_pcie_ltssm_status_string(ltssm));
> return -ETIMEDOUT;
> }
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/6] PCI: dwc: Rework the error print of dw_pcie_wait_for_link()
2026-01-07 8:38 ` Shawn Lin
@ 2026-01-07 9:09 ` Manivannan Sadhasivam
2026-01-07 9:28 ` Shawn Lin
0 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam @ 2026-01-07 9:09 UTC (permalink / raw)
To: Shawn Lin
Cc: manivannan.sadhasivam, Jingoo Han, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, linux-pci,
linux-kernel, vincent.guittot, zhangsenchuan, Richard Zhu
On Wed, Jan 07, 2026 at 04:38:14PM +0800, Shawn Lin wrote:
> 在 2026/01/07 星期三 16:11, Manivannan Sadhasivam via B4 Relay 写道:
> > From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> >
> > If the link fails to come up even after detecting the device on the bus
> > i.e., if the LTSSM is not in Detect.Quiet and Detect.Active states, then
> > dw_pcie_wait_for_link() should log it as an error.
> >
> > So promote dev_info() to dev_err(), reword the error log to make it clear
> > and also print the LTSSM state to aid debugging.
>
> LTSSM might still be changing, so not sure how much value it would be
> to print it at a singal moment, but anyway
>
It is very unlikely that the LTSSM would be changing after the 1s timeout.
Printing the state will allow debugging the link up failure.
- Mani
> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
>
> >
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> > ---
> > drivers/pci/controller/dwc/pcie-designware.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> > index 87f2ebc134d6..c2dfadc53d04 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > @@ -776,7 +776,8 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
> > return -ENODEV;
> > }
> > - dev_info(pci->dev, "Phy link never came up\n");
> > + dev_err(pci->dev, "Link failed to come up. LTSSM: %s\n",
> > + dw_pcie_ltssm_status_string(ltssm));
> > return -ETIMEDOUT;
> > }
> >
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/6] PCI: dwc: Rework the error print of dw_pcie_wait_for_link()
2026-01-07 9:09 ` Manivannan Sadhasivam
@ 2026-01-07 9:28 ` Shawn Lin
0 siblings, 0 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-07 9:28 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: shawn.lin, manivannan.sadhasivam, Jingoo Han, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, linux-pci,
linux-kernel, vincent.guittot, zhangsenchuan, Richard Zhu
在 2026/01/07 星期三 17:09, Manivannan Sadhasivam 写道:
> On Wed, Jan 07, 2026 at 04:38:14PM +0800, Shawn Lin wrote:
>> 在 2026/01/07 星期三 16:11, Manivannan Sadhasivam via B4 Relay 写道:
>>> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>>>
>>> If the link fails to come up even after detecting the device on the bus
>>> i.e., if the LTSSM is not in Detect.Quiet and Detect.Active states, then
>>> dw_pcie_wait_for_link() should log it as an error.
>>>
>>> So promote dev_info() to dev_err(), reword the error log to make it clear
>>> and also print the LTSSM state to aid debugging.
>>
>> LTSSM might still be changing, so not sure how much value it would be
>> to print it at a singal moment, but anyway
>>
>
> It is very unlikely that the LTSSM would be changing after the 1s timeout.
> Printing the state will allow debugging the link up failure.
>
Most cases, yes. But I saw some reports that the LTSSM is stiling
changing between RCVRY_* and CFG_* when supporting customers. Especially
a buggy card I remembered, which sends some hot reset immediately after
link comes up. If it misses the first 1s wait for link check, then we
could see ltssm changing here. But better than nothing, keeps a log here
isn't a big deal I think. :)
> - Mani
>
>> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
>>
>>>
>>> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>>> ---
>>> drivers/pci/controller/dwc/pcie-designware.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
>>> index 87f2ebc134d6..c2dfadc53d04 100644
>>> --- a/drivers/pci/controller/dwc/pcie-designware.c
>>> +++ b/drivers/pci/controller/dwc/pcie-designware.c
>>> @@ -776,7 +776,8 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
>>> return -ENODEV;
>>> }
>>> - dev_info(pci->dev, "Phy link never came up\n");
>>> + dev_err(pci->dev, "Link failed to come up. LTSSM: %s\n",
>>> + dw_pcie_ltssm_status_string(ltssm));
>>> return -ETIMEDOUT;
>>> }
>>>
>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v4 4/6] PCI: dwc: Only skip the dw_pcie_wait_for_link() failure if it returns -ENODEV
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
` (2 preceding siblings ...)
2026-01-07 8:11 ` [PATCH v4 3/6] PCI: dwc: Rework the error print of dw_pcie_wait_for_link() Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:11 ` Manivannan Sadhasivam via B4 Relay
2026-01-07 8:38 ` Shawn Lin
2026-01-07 8:11 ` [PATCH v4 5/6] PCI: host-common: Add an API to check for any device under the Root Ports Manivannan Sadhasivam via B4 Relay
` (4 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2026-01-07 8:11 UTC (permalink / raw)
To: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, vincent.guittot, zhangsenchuan,
Shawn Lin, Richard Zhu, Manivannan Sadhasivam
From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
dw_pcie_wait_for_link() now returns -ENODEV if the device is not found on
the bus and -ETIMEDOUT if the link fails to come up for any other reasons.
And it is incorrect to skip the link up failures other than device not
found. So only skip the failure for device not found case and handle
failure for other reasons.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
---
drivers/pci/controller/dwc/pcie-designware-host.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index fad0cbedefbc..ccde12b85463 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -675,8 +675,10 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
goto err_remove_edma;
}
- /* Ignore errors, the link may come up later */
- dw_pcie_wait_for_link(pci);
+ /* Skip failure if the device is not found as it may show up later */
+ ret = dw_pcie_wait_for_link(pci);
+ if (ret && ret != -ENODEV)
+ goto err_stop_link;
ret = pci_host_probe(bridge);
if (ret)
--
2.48.1
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH v4 4/6] PCI: dwc: Only skip the dw_pcie_wait_for_link() failure if it returns -ENODEV
2026-01-07 8:11 ` [PATCH v4 4/6] PCI: dwc: Only skip the dw_pcie_wait_for_link() failure if it returns -ENODEV Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:38 ` Shawn Lin
0 siblings, 0 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-07 8:38 UTC (permalink / raw)
To: manivannan.sadhasivam, Jingoo Han, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas
Cc: shawn.lin, linux-pci, linux-kernel, vincent.guittot,
zhangsenchuan, Richard Zhu
在 2026/01/07 星期三 16:11, Manivannan Sadhasivam via B4 Relay 写道:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> dw_pcie_wait_for_link() now returns -ENODEV if the device is not found on
> the bus and -ETIMEDOUT if the link fails to come up for any other reasons.
> And it is incorrect to skip the link up failures other than device not
> found. So only skip the failure for device not found case and handle
> failure for other reasons.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> drivers/pci/controller/dwc/pcie-designware-host.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index fad0cbedefbc..ccde12b85463 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -675,8 +675,10 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
> goto err_remove_edma;
> }
>
> - /* Ignore errors, the link may come up later */
> - dw_pcie_wait_for_link(pci);
> + /* Skip failure if the device is not found as it may show up later */
> + ret = dw_pcie_wait_for_link(pci);
> + if (ret && ret != -ENODEV)
> + goto err_stop_link;
>
> ret = pci_host_probe(bridge);
> if (ret)
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v4 5/6] PCI: host-common: Add an API to check for any device under the Root Ports
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
` (3 preceding siblings ...)
2026-01-07 8:11 ` [PATCH v4 4/6] PCI: dwc: Only skip the dw_pcie_wait_for_link() failure if it returns -ENODEV Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:11 ` Manivannan Sadhasivam via B4 Relay
2026-01-07 8:39 ` Shawn Lin
2026-01-07 8:11 ` [PATCH v4 6/6] PCI: dwc: Skip failure during dw_pcie_resume_noirq() if no device is available Manivannan Sadhasivam via B4 Relay
` (3 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2026-01-07 8:11 UTC (permalink / raw)
To: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, vincent.guittot, zhangsenchuan,
Shawn Lin, Richard Zhu, Manivannan Sadhasivam, Frank Li
From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Some controller drivers need to check if there is any device available
under the Root Ports. So add an API that returns 'true' if a device is
found under any of the Root Ports, 'false' otherwise.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
---
drivers/pci/controller/pci-host-common.c | 21 +++++++++++++++++++++
drivers/pci/controller/pci-host-common.h | 2 ++
2 files changed, 23 insertions(+)
diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
index c473e7c03bac..a88622203227 100644
--- a/drivers/pci/controller/pci-host-common.c
+++ b/drivers/pci/controller/pci-host-common.c
@@ -17,6 +17,27 @@
#include "pci-host-common.h"
+/**
+ * pci_root_ports_have_device - Check if the Root Ports under the Root bus have
+ * any device underneath
+ * @root_bus: Root bus to check for
+ *
+ * Return: true if a device is found, false otherwise
+ */
+bool pci_root_ports_have_device(struct pci_bus *root_bus)
+{
+ struct pci_bus *child;
+
+ /* Iterate over the Root Port busses and look for any device */
+ list_for_each_entry(child, &root_bus->children, node) {
+ if (!list_empty(&child->devices))
+ return true;
+ }
+
+ return false;
+}
+EXPORT_SYMBOL_GPL(pci_root_ports_have_device);
+
static void gen_pci_unmap_cfg(void *ptr)
{
pci_ecam_free((struct pci_config_window *)ptr);
diff --git a/drivers/pci/controller/pci-host-common.h b/drivers/pci/controller/pci-host-common.h
index b5075d4bd7eb..8088faf94282 100644
--- a/drivers/pci/controller/pci-host-common.h
+++ b/drivers/pci/controller/pci-host-common.h
@@ -20,4 +20,6 @@ void pci_host_common_remove(struct platform_device *pdev);
struct pci_config_window *pci_host_common_ecam_create(struct device *dev,
struct pci_host_bridge *bridge, const struct pci_ecam_ops *ops);
+
+bool pci_root_ports_have_device(struct pci_bus *root_bus);
#endif
--
2.48.1
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH v4 5/6] PCI: host-common: Add an API to check for any device under the Root Ports
2026-01-07 8:11 ` [PATCH v4 5/6] PCI: host-common: Add an API to check for any device under the Root Ports Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:39 ` Shawn Lin
0 siblings, 0 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-07 8:39 UTC (permalink / raw)
To: manivannan.sadhasivam, Jingoo Han, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas
Cc: shawn.lin, linux-pci, linux-kernel, vincent.guittot,
zhangsenchuan, Richard Zhu, Frank Li
在 2026/01/07 星期三 16:11, Manivannan Sadhasivam via B4 Relay 写道:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> Some controller drivers need to check if there is any device available
> under the Root Ports. So add an API that returns 'true' if a device is
> found under any of the Root Ports, 'false' otherwise.
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> drivers/pci/controller/pci-host-common.c | 21 +++++++++++++++++++++
> drivers/pci/controller/pci-host-common.h | 2 ++
> 2 files changed, 23 insertions(+)
>
> diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
> index c473e7c03bac..a88622203227 100644
> --- a/drivers/pci/controller/pci-host-common.c
> +++ b/drivers/pci/controller/pci-host-common.c
> @@ -17,6 +17,27 @@
>
> #include "pci-host-common.h"
>
> +/**
> + * pci_root_ports_have_device - Check if the Root Ports under the Root bus have
> + * any device underneath
> + * @root_bus: Root bus to check for
> + *
> + * Return: true if a device is found, false otherwise
> + */
> +bool pci_root_ports_have_device(struct pci_bus *root_bus)
> +{
> + struct pci_bus *child;
> +
> + /* Iterate over the Root Port busses and look for any device */
> + list_for_each_entry(child, &root_bus->children, node) {
> + if (!list_empty(&child->devices))
> + return true;
> + }
> +
> + return false;
> +}
> +EXPORT_SYMBOL_GPL(pci_root_ports_have_device);
> +
> static void gen_pci_unmap_cfg(void *ptr)
> {
> pci_ecam_free((struct pci_config_window *)ptr);
> diff --git a/drivers/pci/controller/pci-host-common.h b/drivers/pci/controller/pci-host-common.h
> index b5075d4bd7eb..8088faf94282 100644
> --- a/drivers/pci/controller/pci-host-common.h
> +++ b/drivers/pci/controller/pci-host-common.h
> @@ -20,4 +20,6 @@ void pci_host_common_remove(struct platform_device *pdev);
>
> struct pci_config_window *pci_host_common_ecam_create(struct device *dev,
> struct pci_host_bridge *bridge, const struct pci_ecam_ops *ops);
> +
> +bool pci_root_ports_have_device(struct pci_bus *root_bus);
> #endif
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v4 6/6] PCI: dwc: Skip failure during dw_pcie_resume_noirq() if no device is available
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
` (4 preceding siblings ...)
2026-01-07 8:11 ` [PATCH v4 5/6] PCI: host-common: Add an API to check for any device under the Root Ports Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:11 ` Manivannan Sadhasivam via B4 Relay
2026-01-07 8:41 ` Shawn Lin
2026-01-13 17:53 ` [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Vincent Guittot
` (2 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam via B4 Relay @ 2026-01-07 8:11 UTC (permalink / raw)
To: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, vincent.guittot, zhangsenchuan,
Shawn Lin, Richard Zhu, Manivannan Sadhasivam
From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
If there is no device attached to any of the Root Ports available under the
Root bus before suspend and during resume, then there is no point in
returning failure.
So skip returning failure so that the resume succeeds and allow the device
to get attached later.
If there was a device before suspend and not available during resume, then
propagate the error to indicate that the device got removed during suspend.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
---
drivers/pci/controller/dwc/pcie-designware-host.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index ccde12b85463..c30a2ed324cd 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -20,6 +20,7 @@
#include <linux/platform_device.h>
#include "../../pci.h"
+#include "../pci-host-common.h"
#include "pcie-designware.h"
static struct pci_ops dw_pcie_ops;
@@ -1227,6 +1228,7 @@ EXPORT_SYMBOL_GPL(dw_pcie_suspend_noirq);
int dw_pcie_resume_noirq(struct dw_pcie *pci)
{
+ struct dw_pcie_rp *pp = &pci->pp;
int ret;
if (!pci->suspended)
@@ -1234,23 +1236,28 @@ int dw_pcie_resume_noirq(struct dw_pcie *pci)
pci->suspended = false;
- if (pci->pp.ops->init) {
- ret = pci->pp.ops->init(&pci->pp);
+ if (pp->ops->init) {
+ ret = pp->ops->init(pp);
if (ret) {
dev_err(pci->dev, "Host init failed: %d\n", ret);
return ret;
}
}
- dw_pcie_setup_rc(&pci->pp);
+ dw_pcie_setup_rc(pp);
ret = dw_pcie_start_link(pci);
if (ret)
return ret;
ret = dw_pcie_wait_for_link(pci);
- if (ret)
- return ret;
+ /*
+ * Skip failure if there is no device attached to the bus now and before
+ * suspend. But the error should be returned if a device was attached
+ * before suspend and not available now.
+ */
+ if (ret == -ENODEV && !pci_root_ports_have_device(pp->bridge->bus))
+ return 0;
return ret;
}
--
2.48.1
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH v4 6/6] PCI: dwc: Skip failure during dw_pcie_resume_noirq() if no device is available
2026-01-07 8:11 ` [PATCH v4 6/6] PCI: dwc: Skip failure during dw_pcie_resume_noirq() if no device is available Manivannan Sadhasivam via B4 Relay
@ 2026-01-07 8:41 ` Shawn Lin
0 siblings, 0 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-07 8:41 UTC (permalink / raw)
To: manivannan.sadhasivam, Jingoo Han, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas
Cc: shawn.lin, linux-pci, linux-kernel, vincent.guittot,
zhangsenchuan, Richard Zhu
在 2026/01/07 星期三 16:11, Manivannan Sadhasivam via B4 Relay 写道:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> If there is no device attached to any of the Root Ports available under the
> Root bus before suspend and during resume, then there is no point in
> returning failure.
>
> So skip returning failure so that the resume succeeds and allow the device
> to get attached later.
>
> If there was a device before suspend and not available during resume, then
> propagate the error to indicate that the device got removed during suspend.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> drivers/pci/controller/dwc/pcie-designware-host.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index ccde12b85463..c30a2ed324cd 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -20,6 +20,7 @@
> #include <linux/platform_device.h>
>
> #include "../../pci.h"
> +#include "../pci-host-common.h"
> #include "pcie-designware.h"
>
> static struct pci_ops dw_pcie_ops;
> @@ -1227,6 +1228,7 @@ EXPORT_SYMBOL_GPL(dw_pcie_suspend_noirq);
>
> int dw_pcie_resume_noirq(struct dw_pcie *pci)
> {
> + struct dw_pcie_rp *pp = &pci->pp;
> int ret;
>
> if (!pci->suspended)
> @@ -1234,23 +1236,28 @@ int dw_pcie_resume_noirq(struct dw_pcie *pci)
>
> pci->suspended = false;
>
> - if (pci->pp.ops->init) {
> - ret = pci->pp.ops->init(&pci->pp);
> + if (pp->ops->init) {
> + ret = pp->ops->init(pp);
> if (ret) {
> dev_err(pci->dev, "Host init failed: %d\n", ret);
> return ret;
> }
> }
>
> - dw_pcie_setup_rc(&pci->pp);
> + dw_pcie_setup_rc(pp);
>
> ret = dw_pcie_start_link(pci);
> if (ret)
> return ret;
>
> ret = dw_pcie_wait_for_link(pci);
> - if (ret)
> - return ret;
> + /*
> + * Skip failure if there is no device attached to the bus now and before
> + * suspend. But the error should be returned if a device was attached
> + * before suspend and not available now.
> + */
> + if (ret == -ENODEV && !pci_root_ports_have_device(pp->bridge->bus))
> + return 0;
>
> return ret;
> }
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
` (5 preceding siblings ...)
2026-01-07 8:11 ` [PATCH v4 6/6] PCI: dwc: Skip failure during dw_pcie_resume_noirq() if no device is available Manivannan Sadhasivam via B4 Relay
@ 2026-01-13 17:53 ` Vincent Guittot
2026-01-16 1:36 ` Hongxing Zhu
2026-10-13 9:15 ` Franz Schnyder
8 siblings, 0 replies; 18+ messages in thread
From: Vincent Guittot @ 2026-01-13 17:53 UTC (permalink / raw)
To: manivannan.sadhasivam
Cc: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, linux-pci,
linux-kernel, zhangsenchuan, Shawn Lin, Richard Zhu, Frank Li
On Wed, 7 Jan 2026 at 09:12, Manivannan Sadhasivam via B4 Relay
<devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org> wrote:
>
> Hi,
>
> This series reworks the dw_pcie_wait_for_link() API to allow the callers to
> detect the absence of the device on the bus and skip the failure.
>
> Compared to v2, I've reworked the patch 2 to improve the API further and
> dropped the patch 1 that got applied (hence changed the subject). I've also
> modified the error code based on the feedback in v2 to return -ENODEV if device
> is not detected on the bus and -ETIMEDOUT otherwise. This allows the callers to
> skip the failure if device is not detected and handle error for other failure.
>
> Testing
> =======
>
> Tested this series on Rb3Gen2 board without powering on the PCIe switch. Now the
> dw_pcie_wait_for_link() API prints:
>
> qcom-pcie 1c08000.pcie: Device not found
>
> Instead of the previous log:
>
> qcom-pcie 1c08000.pcie: Phy link never came up
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
FWIW I tested it on s32g399a-rdb3 with a ssd on pcie0 and nothing on pcie1
Tested-By: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> Changes in v4:
> - Skipped returning failure during resume as well if no device is found
> - Link to v3: https://lore.kernel.org/r/20251230-pci-dwc-suspend-rework-v3-0-40cd485714f5@oss.qualcomm.com
>
> Changes in v3:
> - Dropped patch 1 that got appplied
> - Reworked the error handling of dw_pcie_wait_for_link() API further
> - Link to v2: https://lore.kernel.org/r/20251218-pci-dwc-suspend-rework-v2-0-5a7778c6094a@oss.qualcomm.com
>
> Changes in v2:
> - Changed the logic to check for Detect.Quiet/Active states
> - Collected tags and rebased on top of v6.19-rc1
> - Link to v1: https://lore.kernel.org/r/20251119-pci-dwc-suspend-rework-v1-0-aad104828562@oss.qualcomm.com
>
> ---
> Manivannan Sadhasivam (6):
> PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found
> PCI: dwc: Rename and move ltssm_status_string() to pcie-designware.c
> PCI: dwc: Rework the error print of dw_pcie_wait_for_link()
> PCI: dwc: Only skip the dw_pcie_wait_for_link() failure if it returns -ENODEV
> PCI: host-common: Add an API to check for any device under the Root Ports
> PCI: dwc: Skip failure during dw_pcie_resume_noirq() if no device is available
>
> .../pci/controller/dwc/pcie-designware-debugfs.c | 54 +---------------
> drivers/pci/controller/dwc/pcie-designware-host.c | 23 +++++--
> drivers/pci/controller/dwc/pcie-designware.c | 75 +++++++++++++++++++++-
> drivers/pci/controller/dwc/pcie-designware.h | 2 +
> drivers/pci/controller/pci-host-common.c | 21 ++++++
> drivers/pci/controller/pci-host-common.h | 2 +
> 6 files changed, 115 insertions(+), 62 deletions(-)
> ---
> base-commit: 68ac85fb42cfeb081cf029acdd8aace55ed375a2
> change-id: 20251119-pci-dwc-suspend-rework-8b0515a38679
>
> Best regards,
> --
> Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread* RE: [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
` (6 preceding siblings ...)
2026-01-13 17:53 ` [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Vincent Guittot
@ 2026-01-16 1:36 ` Hongxing Zhu
2026-10-13 9:15 ` Franz Schnyder
8 siblings, 0 replies; 18+ messages in thread
From: Hongxing Zhu @ 2026-01-16 1:36 UTC (permalink / raw)
To: manivannan.sadhasivam, Jingoo Han, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczy��ski,
Rob Herring, Bjorn Helgaas
Cc: linux-pci, linux-kernel, vincent.guittot, zhangsenchuan,
Shawn Lin, Frank Li
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 5052 bytes --]
> -----Original Message-----
> From: Manivannan Sadhasivam via B4 Relay
> <devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org>
> Sent: 2026Äê1ÔÂ7ÈÕ 16:12
> To: Jingoo Han <jingoohan1@gmail.com>; Manivannan Sadhasivam
> <mani@kernel.org>; Lorenzo Pieralisi <lpieralisi@kernel.org>; Krzysztof
> Wilczy¨½ski <kwilczynski@kernel.org>; Rob Herring <robh@kernel.org>; Bjorn
> Helgaas <bhelgaas@google.com>
> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> vincent.guittot@linaro.org; zhangsenchuan@eswincomputing.com; Shawn
> Lin <shawn.lin@rock-chips.com>; Hongxing Zhu <hongxing.zhu@nxp.com>;
> Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>;
> Frank Li <frank.li@nxp.com>
> Subject: [PATCH v4 0/6] PCI: dwc: Rework the error handling of
> dw_pcie_wait_for_link() API
>
> Hi,
>
> This series reworks the dw_pcie_wait_for_link() API to allow the callers to
> detect the absence of the device on the bus and skip the failure.
>
> Compared to v2, I've reworked the patch 2 to improve the API further and
> dropped the patch 1 that got applied (hence changed the subject). I've also
> modified the error code based on the feedback in v2 to return -ENODEV if
> device is not detected on the bus and -ETIMEDOUT otherwise. This allows
> the callers to skip the failure if device is not detected and handle error for
> other failure.
>
> Testing
> =======
>
> Tested this series on Rb3Gen2 board without powering on the PCIe switch.
> Now the
> dw_pcie_wait_for_link() API prints:
>
> qcom-pcie 1c08000.pcie: Device not found
>
> Instead of the previous log:
>
> qcom-pcie 1c08000.pcie: Phy link never came up
>
> Signed-off-by: Manivannan Sadhasivam
> <manivannan.sadhasivam@oss.qualcomm.com>
Hi Mani:
Tested on i.MX platforms, no error return anymore. Only "Device not found" is
dumped out when no endpoint device is connected. Thanks.
Tested-by: Richard Zhu <hongxing.zhu@nxp.com>
Best Regards
Richard Zhu
> ---
> Changes in v4:
> - Skipped returning failure during resume as well if no device is found
> - Link to v3:
> https://lore.ke/
> rnel.org%2Fr%2F20251230-pci-dwc-suspend-rework-v3-0-40cd485714f5%40o
> ss.qualcomm.com&data=05%7C02%7Chongxing.zhu%40nxp.com%7C21e8caa
> 708ac4b1e2b4c08de4dc46fd8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0
> %7C0%7C639033703253415993%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU
> 1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIl
> dUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=ZYKBkrUCWKi7hraUSORtiDHwslQ
> Av0kdzyULONMJ7mI%3D&reserved=0
>
> Changes in v3:
> - Dropped patch 1 that got appplied
> - Reworked the error handling of dw_pcie_wait_for_link() API further
> - Link to v2:
> https://lore.ke/
> rnel.org%2Fr%2F20251218-pci-dwc-suspend-rework-v2-0-5a7778c6094a%40o
> ss.qualcomm.com&data=05%7C02%7Chongxing.zhu%40nxp.com%7C21e8caa
> 708ac4b1e2b4c08de4dc46fd8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0
> %7C0%7C639033703253445304%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU
> 1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIl
> dUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=drliZMCiwPAb2nJCKTXPcsRgLa4ex
> sCKGzc2tcK8HSA%3D&reserved=0
>
> Changes in v2:
> - Changed the logic to check for Detect.Quiet/Active states
> - Collected tags and rebased on top of v6.19-rc1
> - Link to v1:
> https://lore.ke/
> rnel.org%2Fr%2F20251119-pci-dwc-suspend-rework-v1-0-aad104828562%40o
> ss.qualcomm.com&data=05%7C02%7Chongxing.zhu%40nxp.com%7C21e8caa
> 708ac4b1e2b4c08de4dc46fd8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0
> %7C0%7C639033703253464634%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU
> 1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIl
> dUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=atzlRIAvDCuQJnIRFaJyYaRA3OQ1n
> d4epPJBNeff6hU%3D&reserved=0
>
> ---
> Manivannan Sadhasivam (6):
> PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is
> not found
> PCI: dwc: Rename and move ltssm_status_string() to
> pcie-designware.c
> PCI: dwc: Rework the error print of dw_pcie_wait_for_link()
> PCI: dwc: Only skip the dw_pcie_wait_for_link() failure if it returns
> -ENODEV
> PCI: host-common: Add an API to check for any device under the Root
> Ports
> PCI: dwc: Skip failure during dw_pcie_resume_noirq() if no device is
> available
>
> .../pci/controller/dwc/pcie-designware-debugfs.c | 54 +---------------
> drivers/pci/controller/dwc/pcie-designware-host.c | 23 +++++--
> drivers/pci/controller/dwc/pcie-designware.c | 75
> +++++++++++++++++++++-
> drivers/pci/controller/dwc/pcie-designware.h | 2 +
> drivers/pci/controller/pci-host-common.c | 21 ++++++
> drivers/pci/controller/pci-host-common.h | 2 +
> 6 files changed, 115 insertions(+), 62 deletions(-)
> ---
> base-commit: 68ac85fb42cfeb081cf029acdd8aace55ed375a2
> change-id: 20251119-pci-dwc-suspend-rework-8b0515a38679
>
> Best regards,
> --
> Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API
2026-01-07 8:11 [PATCH v4 0/6] PCI: dwc: Rework the error handling of dw_pcie_wait_for_link() API Manivannan Sadhasivam via B4 Relay
` (7 preceding siblings ...)
2026-01-16 1:36 ` Hongxing Zhu
@ 2026-10-13 9:15 ` Franz Schnyder
8 siblings, 0 replies; 18+ messages in thread
From: Franz Schnyder @ 2026-10-13 9:15 UTC (permalink / raw)
To: manivannan.sadhasivam
Cc: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, linux-pci,
linux-kernel, vincent.guittot, zhangsenchuan, Shawn Lin,
Richard Zhu, Frank Li
On Wed, Jan 07, 2026 at 01:41:53PM +0530, Manivannan Sadhasivam via B4 Relay wrote:
> Hi,
>
> This series reworks the dw_pcie_wait_for_link() API to allow the callers to
> detect the absence of the device on the bus and skip the failure.
>
> Compared to v2, I've reworked the patch 2 to improve the API further and
> dropped the patch 1 that got applied (hence changed the subject). I've also
> modified the error code based on the feedback in v2 to return -ENODEV if device
> is not detected on the bus and -ETIMEDOUT otherwise. This allows the callers to
> skip the failure if device is not detected and handle error for other failure.
>
> Testing
> =======
>
> Tested this series on Rb3Gen2 board without powering on the PCIe switch. Now the
> dw_pcie_wait_for_link() API prints:
>
> qcom-pcie 1c08000.pcie: Device not found
>
> Instead of the previous log:
>
> qcom-pcie 1c08000.pcie: Phy link never came up
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> Changes in v4:
> - Skipped returning failure during resume as well if no device is found
> - Link to v3: https://lore.kernel.org/r/20251230-pci-dwc-suspend-rework-v3-0-40cd485714f5@oss.qualcomm.com
>
> Changes in v3:
> - Dropped patch 1 that got appplied
> - Reworked the error handling of dw_pcie_wait_for_link() API further
> - Link to v2: https://lore.kernel.org/r/20251218-pci-dwc-suspend-rework-v2-0-5a7778c6094a@oss.qualcomm.com
>
> Changes in v2:
> - Changed the logic to check for Detect.Quiet/Active states
> - Collected tags and rebased on top of v6.19-rc1
> - Link to v1: https://lore.kernel.org/r/20251119-pci-dwc-suspend-rework-v1-0-aad104828562@oss.qualcomm.com
>
> ---
> Manivannan Sadhasivam (6):
> PCI: dwc: Return -ENODEV from dw_pcie_wait_for_link() if device is not found
> PCI: dwc: Rename and move ltssm_status_string() to pcie-designware.c
> PCI: dwc: Rework the error print of dw_pcie_wait_for_link()
> PCI: dwc: Only skip the dw_pcie_wait_for_link() failure if it returns -ENODEV
> PCI: host-common: Add an API to check for any device under the Root Ports
> PCI: dwc: Skip failure during dw_pcie_resume_noirq() if no device is available
>
> .../pci/controller/dwc/pcie-designware-debugfs.c | 54 +---------------
> drivers/pci/controller/dwc/pcie-designware-host.c | 23 +++++--
> drivers/pci/controller/dwc/pcie-designware.c | 75 +++++++++++++++++++++-
> drivers/pci/controller/dwc/pcie-designware.h | 2 +
> drivers/pci/controller/pci-host-common.c | 21 ++++++
> drivers/pci/controller/pci-host-common.h | 2 +
> 6 files changed, 115 insertions(+), 62 deletions(-)
> ---
> base-commit: 68ac85fb42cfeb081cf029acdd8aace55ed375a2
> change-id: 20251119-pci-dwc-suspend-rework-8b0515a38679
>
> Best regards,
> --
> Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
Hi Mani,
Is there any reason patches 5 and 6 were never applied?
kind regards
Franz
^ permalink raw reply [flat|nested] 18+ messages in thread