Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 82302
b: refs/heads/master
c: 4348a2d
h: refs/heads/master
v: v3
  • Loading branch information
Shaohua Li authored and Greg Kroah-Hartman committed Feb 1, 2008
1 parent 15c8821 commit 13433f8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 39ec4561b3a9ccccbdab1dd88a045342be22f27b
refs/heads/master: 4348a2dc49f9baecd34a9b0904245488c6189398
21 changes: 21 additions & 0 deletions trunk/drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,24 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap)
}
EXPORT_SYMBOL_GPL(pci_find_ht_capability);

void pcie_wait_pending_transaction(struct pci_dev *dev)
{
int pos;
u16 reg16;

pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
if (!pos)
return;
while (1) {
pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &reg16);
if (!(reg16 & PCI_EXP_DEVSTA_TRPND))
break;
cpu_relax();
}

}
EXPORT_SYMBOL_GPL(pcie_wait_pending_transaction);

/**
* pci_find_parent_resource - return resource region of parent bus of given region
* @dev: PCI device structure contains resources to be searched
Expand Down Expand Up @@ -884,6 +902,9 @@ pci_disable_device(struct pci_dev *dev)
if (atomic_sub_return(1, &dev->enable_cnt) != 0)
return;

/* Wait for all transactions are finished before disabling the device */
pcie_wait_pending_transaction(dev);

pci_read_config_word(dev, PCI_COMMAND, &pci_command);
if (pci_command & PCI_COMMAND_MASTER) {
pci_command &= ~PCI_COMMAND_MASTER;
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap);
int pci_find_ext_capability (struct pci_dev *dev, int cap);
int pci_find_ht_capability (struct pci_dev *dev, int ht_cap);
int pci_find_next_ht_capability (struct pci_dev *dev, int pos, int ht_cap);
void pcie_wait_pending_transaction(struct pci_dev *dev);
struct pci_bus *pci_find_next_bus(const struct pci_bus *from);

struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
Expand Down Expand Up @@ -759,6 +760,7 @@ static inline void pci_unregister_driver(struct pci_driver *drv) { }
static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; }
static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; }
static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; }
static inline void pcie_wait_pending_transaction(struct pci_dev *dev) {}

/* Power management related routines */
static inline int pci_save_state(struct pci_dev *dev) { return 0; }
Expand Down

0 comments on commit 13433f8

Please sign in to comment.