Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294711
b: refs/heads/master
c: efdc87d
h: refs/heads/master
i:
  294709: 72a29e9
  294707: f1b4b80
  294703: dbd097e
v: v3
  • Loading branch information
Yinghai Lu authored and Jesse Barnes committed Feb 14, 2012
1 parent 0fc263e commit b2e0a52
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ac205b7bb72fa4227d2e79979bbe2b4687cdf44d
refs/heads/master: efdc87dab1cdf25ba631181ac0ead3fb2023dd10
2 changes: 2 additions & 0 deletions trunk/drivers/pci/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ enum pci_bar_type {
pci_bar_mem64, /* A 64-bit memory BAR */
};

bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl,
int crs_timeout);
extern int pci_setup_device(struct pci_dev *dev);
extern int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
struct resource *res, unsigned int reg);
Expand Down
48 changes: 31 additions & 17 deletions trunk/drivers/pci/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,40 +1118,54 @@ struct pci_dev *alloc_pci_dev(void)
}
EXPORT_SYMBOL(alloc_pci_dev);

/*
* Read the config data for a PCI device, sanity-check it
* and fill in the dev structure...
*/
static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
int crs_timeout)
{
struct pci_dev *dev;
u32 l;
int delay = 1;

if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l))
return NULL;
if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l))
return false;

/* some broken boards return 0 or ~0 if a slot is empty: */
if (l == 0xffffffff || l == 0x00000000 ||
l == 0x0000ffff || l == 0xffff0000)
return NULL;
if (*l == 0xffffffff || *l == 0x00000000 ||
*l == 0x0000ffff || *l == 0xffff0000)
return false;

/* Configuration request Retry Status */
while (l == 0xffff0001) {
while (*l == 0xffff0001) {
if (!crs_timeout)
return false;

msleep(delay);
delay *= 2;
if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l))
return NULL;
if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l))
return false;
/* Card hasn't responded in 60 seconds? Must be stuck. */
if (delay > 60 * 1000) {
if (delay > crs_timeout) {
printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not "
"responding\n", pci_domain_nr(bus),
bus->number, PCI_SLOT(devfn),
PCI_FUNC(devfn));
return NULL;
return false;
}
}

return true;
}
EXPORT_SYMBOL(pci_bus_read_dev_vendor_id);

/*
* Read the config data for a PCI device, sanity-check it
* and fill in the dev structure...
*/
static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
{
struct pci_dev *dev;
u32 l;

if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
return NULL;

dev = alloc_pci_dev();
if (!dev)
return NULL;
Expand Down

0 comments on commit b2e0a52

Please sign in to comment.