public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Farhan Ali <alifm@linux.ibm.com>
To: alifm@linux.ibm.com
Cc: stable@vger.kernel.org
Subject: [PATCH v9 4/9] PCI: Add additional checks for flr reset
Date: Tue, 17 Feb 2026 10:19:54 -0800	[thread overview]
Message-ID: <20260217181959.1536-5-alifm@linux.ibm.com> (raw)
In-Reply-To: <20260217181959.1536-1-alifm@linux.ibm.com>

If a device is in an error state, then any reads of device registers can
return error value. Add addtional checks to validate if a device is in an
error state before doing an flr reset.

Cc: stable@vger.kernel.org
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
---
 drivers/pci/pci.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2242b97e7d46..d867db7188d0 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4373,12 +4373,19 @@ EXPORT_SYMBOL_GPL(pcie_flr);
  */
 int pcie_reset_flr(struct pci_dev *dev, bool probe)
 {
+	u32 reg;
+
 	if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET)
 		return -ENOTTY;
 
 	if (!(dev->devcap & PCI_EXP_DEVCAP_FLR))
 		return -ENOTTY;
 
+	if (pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &reg)) {
+		pci_warn(dev, "Device unable to do an FLR\n");
+		return -ENOTTY;
+	}
+
 	if (probe)
 		return 0;
 
-- 
2.43.0


  parent reply	other threads:[~2026-02-17 18:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260217181959.1536-1-alifm@linux.ibm.com>
2026-02-17 18:19 ` [PATCH v9 1/9] PCI: Allow per function PCI slots Farhan Ali
2026-02-17 18:19 ` Farhan Ali [this message]
2026-02-17 18:22 [PATCH v9 0/9] Error recovery for vfio-pci devices on s390x Farhan Ali
2026-02-17 18:22 ` [PATCH v9 4/9] PCI: Add additional checks for flr reset Farhan Ali

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=20260217181959.1536-5-alifm@linux.ibm.com \
    --to=alifm@linux.ibm.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