aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBert Kenward <bkenward@solarflare.com>2018-07-26 11:21:29 -0400
committerBjorn Helgaas <bhelgaas@google.com>2018-08-14 17:04:46 -0400
commit6eaf2781137842429c447bb491402b231df8a0f1 (patch)
tree7028e521afae6241b3a1fc33d0ba2d5988357a5d
parentb72ae8cac0caff86fe414fceb940655c2d1371c9 (diff)
PCI/VPD: Check for VPD access completion before checking for timeout
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>
-rw-r--r--drivers/pci/vpd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
index 8617565ba561..4963c2e2bd4c 100644
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -146,7 +146,7 @@ static int pci_vpd_wait(struct pci_dev *dev)
146 if (!vpd->busy) 146 if (!vpd->busy)
147 return 0; 147 return 0;
148 148
149 while (time_before(jiffies, timeout)) { 149 do {
150 ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR, 150 ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR,
151 &status); 151 &status);
152 if (ret < 0) 152 if (ret < 0)
@@ -160,10 +160,13 @@ static int pci_vpd_wait(struct pci_dev *dev)
160 if (fatal_signal_pending(current)) 160 if (fatal_signal_pending(current))
161 return -EINTR; 161 return -EINTR;
162 162
163 if (time_after(jiffies, timeout))
164 break;
165
163 usleep_range(10, max_sleep); 166 usleep_range(10, max_sleep);
164 if (max_sleep < 1024) 167 if (max_sleep < 1024)
165 max_sleep *= 2; 168 max_sleep *= 2;
166 } 169 } while (true);
167 170
168 pci_warn(dev, "VPD access failed. This is likely a firmware bug on this device. Contact the card vendor for a firmware update\n"); 171 pci_warn(dev, "VPD access failed. This is likely a firmware bug on this device. Contact the card vendor for a firmware update\n");
169 return -ETIMEDOUT; 172 return -ETIMEDOUT;