|
@@ -23,18 +23,39 @@ unsigned int pci_max_bus = 0xff;
|
23
|
23
|
* Returns 1 if a device was found, 0 for no device present.
|
24
|
24
|
*/
|
25
|
25
|
static int fill_pci_device ( struct pci_device *pci ) {
|
|
26
|
+ static struct {
|
|
27
|
+ uint16_t devfn0;
|
|
28
|
+ int is_present;
|
|
29
|
+ } cache = { 0, 1 };
|
26
|
30
|
uint32_t l;
|
27
|
31
|
int reg;
|
28
|
32
|
|
29
|
33
|
/* Check bus is within range */
|
30
|
34
|
if ( PCI_BUS ( pci->busdevfn ) > pci_max_bus )
|
31
|
35
|
return 0;
|
|
36
|
+
|
|
37
|
+ /* Check to see if we've cached the result that this is a
|
|
38
|
+ * non-zero function on a non-existent card. This is done to
|
|
39
|
+ * increase scan speed by a factor of 8.
|
|
40
|
+ */
|
|
41
|
+ if ( ( PCI_FUNC ( pci->busdevfn ) != 0 ) &&
|
|
42
|
+ ( PCI_FN0 ( pci->busdevfn ) == cache.devfn0 ) &&
|
|
43
|
+ ( ! cache.is_present ) ) {
|
|
44
|
+ return 0;
|
|
45
|
+ }
|
32
|
46
|
|
33
|
47
|
/* Check to see if there's anything physically present.
|
34
|
48
|
*/
|
35
|
49
|
pci_read_config_dword ( pci, PCI_VENDOR_ID, &l );
|
36
|
50
|
/* some broken boards return 0 if a slot is empty: */
|
37
|
51
|
if ( ( l == 0xffffffff ) || ( l == 0x00000000 ) ) {
|
|
52
|
+ if ( PCI_FUNC ( pci->busdevfn ) == 0 ) {
|
|
53
|
+ /* Don't look for subsequent functions if the
|
|
54
|
+ * card itself is not present.
|
|
55
|
+ */
|
|
56
|
+ cache.devfn0 = pci->busdevfn;
|
|
57
|
+ cache.is_present = 0;
|
|
58
|
+ }
|
38
|
59
|
return 0;
|
39
|
60
|
}
|
40
|
61
|
pci->vendor = l & 0xffff;
|
|
@@ -47,7 +68,7 @@ static int fill_pci_device ( struct pci_device *pci ) {
|
47
|
68
|
uint16_t save_busdevfn = pci->busdevfn;
|
48
|
69
|
uint8_t header_type;
|
49
|
70
|
|
50
|
|
- pci->busdevfn &= ~PCI_FUNC ( 0xffff );
|
|
71
|
+ pci->busdevfn &= PCI_FN0 ( pci->busdevfn );
|
51
|
72
|
pci_read_config_byte ( pci, PCI_HEADER_TYPE, &header_type );
|
52
|
73
|
pci->busdevfn = save_busdevfn;
|
53
|
74
|
|