]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
PCI/VPD: Check for VPD access completion before checking for timeout
authorBert Kenward <bkenward@solarflare.com>
Thu, 26 Jul 2018 15:21:29 +0000 (16:21 +0100)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 14 Aug 2018 21:04:46 +0000 (16:04 -0500)
Previously we checked the timeout before checking the VPD access completion
bit.  On a very heavily loaded system this can cause VPD access to timeout.
Check the completion bit before checking the timeout.

Signed-off-by: Bert Kenward <bkenward@solarflare.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/vpd.c

index 8617565ba561abb3801cbf1aa9b5ad5d68a6bfad..4963c2e2bd4ce292654c1445470aeff50ed808b5 100644 (file)
@@ -146,7 +146,7 @@ static int pci_vpd_wait(struct pci_dev *dev)
        if (!vpd->busy)
                return 0;
 
-       while (time_before(jiffies, timeout)) {
+       do {
                ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR,
                                                &status);
                if (ret < 0)
@@ -160,10 +160,13 @@ static int pci_vpd_wait(struct pci_dev *dev)
                if (fatal_signal_pending(current))
                        return -EINTR;
 
+               if (time_after(jiffies, timeout))
+                       break;
+
                usleep_range(10, max_sleep);
                if (max_sleep < 1024)
                        max_sleep *= 2;
-       }
+       } while (true);
 
        pci_warn(dev, "VPD access failed.  This is likely a firmware bug on this device.  Contact the card vendor for a firmware update\n");
        return -ETIMEDOUT;