Ignore:
Timestamp:
Dec 24, 2014, 3:27:25 AM (7 years ago)
Author:
Till Strauman <strauman@…>
Branches:
4.11, 5, master
Children:
2d5c486
Parents:
da10694
git-author:
Till Strauman <strauman@…> (12/24/14 03:27:25)
git-committer:
Gedare Bloom <gedare@…> (12/24/14 03:27:25)
Message:

pc386: scan all functions of multi-function PCI devices

The current algorithm scans all PCI busses (0..ff)
and all devices (0..31) on each bus for bridges
and determines the maximum of all subordinate
busses encountered.

However, the algorithm does not scan all functions
present in multi-function devices -- I have a PCI express
root complex (82801H) where multiple (non-zero index)
functions are 'PCI bridges' whose subordinate bus number is
missed by the original algorithm.

This commit makes sure that the scan
is extended to all functions of multi-function
devices.

See #2067

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/shared/pci/pcibios.c

    rda10694 r2573e69  
    229229    unsigned char bus;
    230230    unsigned char dev;
     231    unsigned char fun;
     232    unsigned char nfn;
    231233    unsigned char hd = 0;
    232234    uint32_t d = 0;
     
    240242        pcib_conf_read32(sig, PCI_VENDOR_ID, &d);
    241243
    242         if ( d != -1 ) {
    243            pcib_conf_read32(sig, PCI_CLASS_REVISION, &d);
    244 
    245            if ( (d >> 16) == PCI_CLASS_BRIDGE_PCI ) {
    246              pcib_conf_read8(sig, PCI_SUBORDINATE_BUS, &hd);
    247 
    248              if ( hd > ucBusCount )
    249                ucBusCount = hd;
    250            }
     244        if ( -1 == d ) {
     245          continue;
     246        }
     247
     248        pcib_conf_read8(sig, PCI_HEADER_TYPE, &hd);
     249        nfn = (hd & 0x80) ? PCI_MAX_FUNCTIONS : 1;
     250
     251        for ( fun=0; fun<nfn; fun++ ) {
     252
     253          sig = PCIB_DEVSIG_MAKE(bus,dev,fun);
     254          pcib_conf_read32(sig, PCI_VENDOR_ID, &d);
     255          if ( -1 == d )
     256            continue;
     257
     258          pcib_conf_read32(sig, PCI_CLASS_REVISION, &d);
     259
     260          if ( (d >> 16) == PCI_CLASS_BRIDGE_PCI ) {
     261            pcib_conf_read8(sig, PCI_SUBORDINATE_BUS, &hd);
     262
     263            if ( hd > ucBusCount )
     264              ucBusCount = hd;
     265          }
     266
    251267        }
    252268      }
Note: See TracChangeset for help on using the changeset viewer.