mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ziyou Wang (Lenovo)" <ziyou.dev@foxmail.com>
To: lukas@wunner.de
Cc: bhelgaas@google.com, brett.creeley@amd.com,
	linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
	sathyanarayanan.kuppuswamy@linux.intel.com,
	stable@vger.kernel.org, ziyou.dev@foxmail.com
Subject: [PATCH v3] PCI/DPC: Increase recovery timeout to 60 seconds
Date: Sat,  5 Dec 2026 20:19:49 +0800	[thread overview]
Message-ID: <tencent_646202B910D8DCC6ADF5705708D37A8EA20A@qq.com> (raw)
In-Reply-To: <axKZk6YJzi-gvlIR@wunner.de>

Some NVMe devices need more than 5 seconds to recover after DPC
containment, but pci_dpc_recovered() waits only 4 seconds.  If the device
hasn't recovered by then, pciehp reports "device recovery failed" and
the device is re-enumerated.

Move PCIE_RESET_READY_POLL_MS definition from pci.c to pci.h so it can be
used in dpc.c.  Use PCIE_RESET_READY_POLL_MS (60 seconds) as the timeout
so pciehp waits as long as pci_bridge_wait_for_secondary_bus() does,
which is sufficient for all known devices.

Tested with INNOGRIT NVMe SSD [1dbe:5668] with ACS Fatal error
injection:

Upstream kernel (7.3.0-master+, 4s timeout):
  [123.018691] nvme: not ready 1023ms after DPC; waiting
  [124.106690] nvme: not ready 2047ms after DPC; waiting
  [125.642703] pciehp: Slot(64): Link Down
  [126.218696] AER: subordinate device reset failed
  [126.218700] AER: device recovery failed
  Device re-enumerated as nvme1

With this patch (60s timeout):
  [74.894811] nvme: not ready 1023ms after DPC; waiting
  [75.982813] nvme: not ready 2047ms after DPC; waiting
  [78.094810] nvme: ready 4095ms after DPC
  [78.094816] nvme: restart after slot reset
  [78.111620] AER: device recovery successful
  Device works normally

Fixes: a97396c6eb13 ("PCI: pciehp: Ignore Link Down/Up caused by DPC")
Cc: stable@vger.kernel.org
Cc: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Ziyou Wang (Lenovo) <ziyou.dev@foxmail.com>
---
v3: remove stale comment in pci.c, update comment in dpc.c,
    reference pci_bridge_wait_for_secondary_bus() in commit message

 drivers/pci/pci.c      | 8 --------
 drivers/pci/pci.h      | 8 ++++++++
 drivers/pci/pcie/dpc.c | 4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c6f2aba8144..eaa985e250af 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -74,14 +74,6 @@ struct pci_pme_device {
  */
 #define PCI_RESET_WAIT 1000 /* msec */
 
-/*
- * Devices may extend the 1 sec period through Request Retry Status
- * completions (PCIe r6.0 sec 2.3.1).  The spec does not provide an upper
- * limit, but 60 sec ought to be enough for any device to become
- * responsive.
- */
-#define PCIE_RESET_READY_POLL_MS 60000 /* msec */
-
 static void pci_dev_d3_sleep(struct pci_dev *dev)
 {
 	unsigned int delay_ms = max(dev->d3hot_delay, pci_pm_d3hot_delay);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 77efa4c5c960..bac130508348 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -70,6 +70,14 @@ struct pcie_tlp_log;
  */
 #define PCIE_RESET_CONFIG_WAIT_MS	100
 
+/*
+ * Devices may extend the 1 sec period through Request Retry Status
+ * completions (PCIe r6.0 sec 2.3.1).  The spec does not provide an upper
+ * limit, but 60 sec ought to be enough for any device to become
+ * responsive.
+ */
+#define PCIE_RESET_READY_POLL_MS	60000 /* msec */
+
 /* Parameters for the waiting for link up routine */
 #define PCIE_LINK_WAIT_MAX_RETRIES	10
 #define PCIE_LINK_WAIT_SLEEP_MS		90
diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index 2b779bd1d861..4cad4de74a9e 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -118,10 +118,10 @@ bool pci_dpc_recovered(struct pci_dev *pdev)
 	/*
 	 * Need a timeout in case DPC never completes due to failure of
 	 * dpc_wait_rp_inactive().  The spec doesn't mandate a time limit,
-	 * but reports indicate that DPC completes within 4 seconds.
+	 * so use the same timeout as pci_bridge_wait_for_secondary_bus().
 	 */
 	wait_event_timeout(dpc_completed_waitqueue, dpc_completed(pdev),
-			   msecs_to_jiffies(4000));
+			   msecs_to_jiffies(PCIE_RESET_READY_POLL_MS));
 
 	return test_and_clear_bit(PCI_DPC_RECOVERED, &pdev->priv_flags);
 }
-- 
2.53.0


      parent reply	other threads:[~2026-12-05 12:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261106082612.1840817-1-ziyou.dev@foxmail.com>
2026-11-06  8:56 ` [PATCH v2] " Ziyou Wang (Lenovo)
2026-11-06 15:21   ` Bjorn Helgaas
2026-11-19  3:30     ` Ziyou Wang (Lenovo)
2026-11-19  9:01       ` Lukas Wunner
2026-11-20  3:22         ` Ziyou Wang (Lenovo)
2026-12-04  2:14           ` Ziyou Wang (Lenovo)
2026-12-04 10:44   ` Lukas Wunner
2026-12-04 17:19     ` Creeley, Brett
2026-12-05 12:19     ` Ziyou Wang (Lenovo) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_646202B910D8DCC6ADF5705708D37A8EA20A@qq.com \
    --to=ziyou.dev@foxmail.com \
    --cc=bhelgaas@google.com \
    --cc=brett.creeley@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®