mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Gruhlke <gruhlke@mailbox.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Lukas Wunner <lukas@wunner.de>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Alex Williamson <alex@shazbot.org>,
	Hui Wang <hui.wang@canonical.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	regressions@lists.linux.dev,
	Alexander Gruhlke <gruhlke@mailbox.org>
Subject: [PATCH 2/2] PCI: Wait for readiness after FLR even with Immediate Readiness
Date: Sat, 10 Oct 2026 18:05:29 +0200	[thread overview]
Message-ID: <20261010160529.27974-3-gruhlke@mailbox.org> (raw)
In-Reply-To: <20261010160529.27974-1-gruhlke@mailbox.org>

pcie_flr() and pci_af_flr() skip pci_dev_wait() if the device advertises
Immediate Readiness.  Since commit 10baa9b4df40 ("PCI: Drop unnecessary
retries when restoring BARs"), the subsequent config restore isn't
retried, so it is lost if the device isn't ready after all.

The Samsung 990 PRO [144d:a80c] advertises Immediate Readiness but
returns ~0 for 1-7 ms after FLR, which breaks VFIO passthrough.  Keep
skipping the 100 ms delay, but call pci_dev_wait().

Fixes: 10baa9b4df40 ("PCI: Drop unnecessary retries when restoring BARs")
Link: https://bbs.archlinux.org/viewtopic.php?id=314833
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Alexander Gruhlke <gruhlke@mailbox.org>
---
 drivers/pci/pci.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 26be5d1ca9..59856e3fdf 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4379,18 +4379,15 @@ int pcie_flr(struct pci_dev *dev)
 
 	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
 
-	if (dev->imm_ready)
-		goto done;
-
 	/*
 	 * Per PCIe r4.0, sec 6.6.2, a device must complete an FLR within
 	 * 100ms, but may silently discard requests while the FLR is in
 	 * progress.  Wait 100ms before trying to access the device.
 	 */
-	msleep(100);
+	if (!dev->imm_ready)
+		msleep(100);
 
 	ret = pci_dev_wait(dev, "FLR", PCIE_RESET_READY_POLL_MS);
-done:
 	pci_dev_reset_iommu_done(dev);
 	return ret;
 }
@@ -4456,19 +4453,16 @@ static int pci_af_flr(struct pci_dev *dev, bool probe)
 
 	pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
 
-	if (dev->imm_ready)
-		goto done;
-
 	/*
 	 * Per Advanced Capabilities for Conventional PCI ECN, 13 April 2006,
 	 * updated 27 July 2006; a device must complete an FLR within
 	 * 100ms, but may silently discard requests while the FLR is in
 	 * progress.  Wait 100ms before trying to access the device.
 	 */
-	msleep(100);
+	if (!dev->imm_ready)
+		msleep(100);
 
 	ret = pci_dev_wait(dev, "AF_FLR", PCIE_RESET_READY_POLL_MS);
-done:
 	pci_dev_reset_iommu_done(dev);
 	return ret;
 }
-- 
2.56.0


  parent reply	other threads:[~2026-10-10 16:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10 16:05 [PATCH 0/2] PCI: Wait after FLR for devices that don't honor " Alexander Gruhlke
2026-10-10 16:05 ` [PATCH 1/2] PCI: Don't treat ~0 as ready in pci_dev_wait() with RRS SV Alexander Gruhlke
2026-10-10 18:36   ` Lukas Wunner
2026-10-11  8:24     ` Alexander Gruhlke
2026-10-11 15:14       ` Lukas Wunner
2026-10-10 16:05 ` Alexander Gruhlke [this message]
2026-10-10 17:51   ` [PATCH 2/2] PCI: Wait for readiness after FLR even with Immediate Readiness Lukas Wunner
2026-10-11  8:25     ` Alexander Gruhlke
2026-10-11 16:38 ` [PATCH 0/2] PCI: Wait after FLR for devices that don't honor " Alexander Gruhlke

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=20261010160529.27974-3-gruhlke@mailbox.org \
    --to=gruhlke@mailbox.org \
    --cc=alex@shazbot.org \
    --cc=bhelgaas@google.com \
    --cc=hui.wang@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=rafael@kernel.org \
    --cc=regressions@lists.linux.dev \
    /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®