diff options
author | Shaohua Li <shaohua.li@intel.com> | 2007-10-23 22:45:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 18:04:19 -0500 |
commit | 4348a2dc49f9baecd34a9b0904245488c6189398 (patch) | |
tree | cbe391c0f28ac367767c7427991cd9689c042458 | |
parent | 39ec4561b3a9ccccbdab1dd88a045342be22f27b (diff) |
pcie: utilize pcie transaction pending bit
PCIE has a mechanism to wait for Non-Posted request to complete. I think
pci_disable_device is a good place to do this.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/pci/pci.c | 21 | ||||
-rw-r--r-- | include/linux/pci.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 089184bc327d..d30e802d9a1a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -314,6 +314,24 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap) | |||
314 | } | 314 | } |
315 | EXPORT_SYMBOL_GPL(pci_find_ht_capability); | 315 | EXPORT_SYMBOL_GPL(pci_find_ht_capability); |
316 | 316 | ||
317 | void pcie_wait_pending_transaction(struct pci_dev *dev) | ||
318 | { | ||
319 | int pos; | ||
320 | u16 reg16; | ||
321 | |||
322 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); | ||
323 | if (!pos) | ||
324 | return; | ||
325 | while (1) { | ||
326 | pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, ®16); | ||
327 | if (!(reg16 & PCI_EXP_DEVSTA_TRPND)) | ||
328 | break; | ||
329 | cpu_relax(); | ||
330 | } | ||
331 | |||
332 | } | ||
333 | EXPORT_SYMBOL_GPL(pcie_wait_pending_transaction); | ||
334 | |||
317 | /** | 335 | /** |
318 | * pci_find_parent_resource - return resource region of parent bus of given region | 336 | * pci_find_parent_resource - return resource region of parent bus of given region |
319 | * @dev: PCI device structure contains resources to be searched | 337 | * @dev: PCI device structure contains resources to be searched |
@@ -884,6 +902,9 @@ pci_disable_device(struct pci_dev *dev) | |||
884 | if (atomic_sub_return(1, &dev->enable_cnt) != 0) | 902 | if (atomic_sub_return(1, &dev->enable_cnt) != 0) |
885 | return; | 903 | return; |
886 | 904 | ||
905 | /* Wait for all transactions are finished before disabling the device */ | ||
906 | pcie_wait_pending_transaction(dev); | ||
907 | |||
887 | pci_read_config_word(dev, PCI_COMMAND, &pci_command); | 908 | pci_read_config_word(dev, PCI_COMMAND, &pci_command); |
888 | if (pci_command & PCI_COMMAND_MASTER) { | 909 | if (pci_command & PCI_COMMAND_MASTER) { |
889 | pci_command &= ~PCI_COMMAND_MASTER; | 910 | pci_command &= ~PCI_COMMAND_MASTER; |
diff --git a/include/linux/pci.h b/include/linux/pci.h index d2cae79f3bea..bdff18b7fbc6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -498,6 +498,7 @@ int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap); | |||
498 | int pci_find_ext_capability (struct pci_dev *dev, int cap); | 498 | int pci_find_ext_capability (struct pci_dev *dev, int cap); |
499 | int pci_find_ht_capability (struct pci_dev *dev, int ht_cap); | 499 | int pci_find_ht_capability (struct pci_dev *dev, int ht_cap); |
500 | int pci_find_next_ht_capability (struct pci_dev *dev, int pos, int ht_cap); | 500 | int pci_find_next_ht_capability (struct pci_dev *dev, int pos, int ht_cap); |
501 | void pcie_wait_pending_transaction(struct pci_dev *dev); | ||
501 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); | 502 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); |
502 | 503 | ||
503 | struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, | 504 | struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, |
@@ -759,6 +760,7 @@ static inline void pci_unregister_driver(struct pci_driver *drv) { } | |||
759 | static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } | 760 | static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } |
760 | static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } | 761 | static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } |
761 | static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; } | 762 | static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; } |
763 | static inline void pcie_wait_pending_transaction(struct pci_dev *dev) {} | ||
762 | 764 | ||
763 | /* Power management related routines */ | 765 | /* Power management related routines */ |
764 | static inline int pci_save_state(struct pci_dev *dev) { return 0; } | 766 | static inline int pci_save_state(struct pci_dev *dev) { return 0; } |