]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/pci: Fix stale function handles in error handling
authorNiklas Schnelle <schnelle@linux.ibm.com>
Wed, 25 Jun 2025 09:28:28 +0000 (11:28 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Sat, 28 Jun 2025 16:58:59 +0000 (18:58 +0200)
The error event information for PCI error events contains a function
handle for the respective function. This handle is generally captured at
the time the error event was recorded. Due to delays in processing or
cascading issues, it may happen that during firmware recovery multiple
events are generated. When processing these events in order Linux may
already have recovered an affected function making the event information
stale. Fix this by doing an unconditional CLP List PCI function
retrieving the current function handle with the zdev->state_lock held
and ignoring the event if its function handle is stale.

Cc: stable@vger.kernel.org
Fixes: 4cdf2f4e24ff ("s390/pci: implement minimal PCI error recovery")
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Reviewed-by: Gerd Bayer <gbayer@linux.ibm.com>
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/pci/pci_event.c

index 2fbee3887d13aa28e0621aa7b6d673f4517b5461..82ee2578279a114e6bbd199c6753ef82c575a5af 100644 (file)
@@ -273,6 +273,8 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf)
        struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid);
        struct pci_dev *pdev = NULL;
        pci_ers_result_t ers_res;
+       u32 fh = 0;
+       int rc;
 
        zpci_dbg(3, "err fid:%x, fh:%x, pec:%x\n",
                 ccdf->fid, ccdf->fh, ccdf->pec);
@@ -281,6 +283,15 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf)
 
        if (zdev) {
                mutex_lock(&zdev->state_lock);
+               rc = clp_refresh_fh(zdev->fid, &fh);
+               if (rc)
+                       goto no_pdev;
+               if (!fh || ccdf->fh != fh) {
+                       /* Ignore events with stale handles */
+                       zpci_dbg(3, "err fid:%x, fh:%x (stale %x)\n",
+                                ccdf->fid, fh, ccdf->fh);
+                       goto no_pdev;
+               }
                zpci_update_fh(zdev, ccdf->fh);
                if (zdev->zbus->bus)
                        pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);