PCI: Do not wait for disconnected devices when resuming
[linux-2.6-block.git] / include / linux / pci.h
index 69b10f2fb6067bf4984f704c945e48c88a7c94cc..2151c7f9be864439436d37e0662dfea6b3e077b0 100644 (file)
@@ -2514,7 +2514,12 @@ static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
 
 static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
 {
-       return dev->error_state == pci_channel_io_perm_failure;
+       /*
+        * error_state is set in pci_dev_set_io_state() using xchg/cmpxchg()
+        * and read w/o common lock. READ_ONCE() ensures compiler cannot cache
+        * the value (e.g. inside the loop in pci_dev_wait()).
+        */
+       return READ_ONCE(dev->error_state) == pci_channel_io_perm_failure;
 }
 
 void pci_request_acs(void);