diff options
Diffstat (limited to 'src/devices')
-rw-r--r-- | src/devices/hypertransport.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/devices/hypertransport.c b/src/devices/hypertransport.c index 6d4836b87a..d1e3468874 100644 --- a/src/devices/hypertransport.c +++ b/src/devices/hypertransport.c @@ -383,6 +383,8 @@ unsigned int hypertransport_scan_chain(struct bus *bus, struct ht_link prev; device_t last_func = 0; int ht_dev_num = 0; + unsigned temp_unitid; + unsigned not_use_count; #if HT_CHAIN_END_UNITID_BASE < HT_CHAIN_UNITID_BASE //let't record the device of last ht device, So we can set the Unitid to HT_CHAIN_END_UNITID_BASE @@ -473,39 +475,53 @@ unsigned int hypertransport_scan_chain(struct bus *bus, if (flags & 0x1f) { break; } - flags &= ~0x1f; /* mask out base Unit ID */ - flags |= next_unitid & 0x1f; + + count = (flags >> 5) & 0x1f; /* get unit count */ + not_use_count = 0; + temp_unitid = next_unitid; +#if HT_CHAIN_END_UNITID_BASE < HT_CHAIN_UNITID_BASE + if(offset_unitid) { + if((next_unitid+count)>=0x20) { + temp_unitid = HT_CHAIN_END_UNITID_BASE; + //still use the old next_unitid + not_use_count = 1; + } + + } +#endif + + flags |= temp_unitid & 0x1f; pci_write_config16(dev, pos + PCI_CAP_FLAGS, flags); /* Update the Unitd id in the device structure */ static_count = 1; for(func = dev; func; func = func->sibling) { - func->path.u.pci.devfn += (next_unitid << 3); + func->path.u.pci.devfn += (temp_unitid << 3); static_count = (func->path.u.pci.devfn >> 3) - (dev->path.u.pci.devfn >> 3) + 1; last_func = func; } - /* Compute the number of unitids consumed */ - count = (flags >> 5) & 0x1f; /* get unit count */ printk_spew("%s count: %04x static_count: %04x\n", dev_path(dev), count, static_count); if (count < static_count) { count = static_count; } + if(!not_use_count) + next_unitid += count; /* Update the Unitid of the next device */ - ht_unitid_base[ht_dev_num] = next_unitid; + ht_unitid_base[ht_dev_num] = temp_unitid; ht_dev_num++; + #if HT_CHAIN_END_UNITID_BASE < HT_CHAIN_UNITID_BASE if(offset_unitid) { - real_last_unitid = next_unitid; real_last_pos = pos; + real_last_unitid = temp_unitid; real_last_dev = dev; } #endif - next_unitid += count; /* Setup the hypetransport link */ bus->reset_needed |= ht_setup_link(&prev, dev, pos); @@ -515,7 +531,7 @@ unsigned int hypertransport_scan_chain(struct bus *bus, dev->vendor, dev->device, (dev->enabled? "enabled": "disabled"), next_unitid); - } while((last_unitid != next_unitid) && (next_unitid <= (max_devfn >> 3))); + } while((last_unitid != next_unitid) && (next_unitid <= 0x1f /*(max_devfn >> 3)*/ )); end_of_chain: #if OPT_HT_LINK == 1 if(bus->reset_needed) { @@ -527,7 +543,7 @@ unsigned int hypertransport_scan_chain(struct bus *bus, #endif #if HT_CHAIN_END_UNITID_BASE < HT_CHAIN_UNITID_BASE - if(offset_unitid && (ht_dev_num>0)) { + if(offset_unitid && (ht_dev_num>1) && (real_last_unitid != HT_CHAIN_END_UNITID_BASE) ) { uint16_t flags; int i; device_t last_func = 0; @@ -540,7 +556,7 @@ unsigned int hypertransport_scan_chain(struct bus *bus, func->path.u.pci.devfn -= ((real_last_unitid - HT_CHAIN_END_UNITID_BASE) << 3); last_func = func; } - + ht_unitid_base[ht_dev_num-1] = HT_CHAIN_END_UNITID_BASE; // update last one next_unitid = real_last_unitid; @@ -550,6 +566,9 @@ unsigned int hypertransport_scan_chain(struct bus *bus, if (next_unitid > 0x1f) { next_unitid = 0x1f; } + if( (bus->secondary == 0) && (next_unitid > 0x17)) { + next_unitid = 0x17; /* avoid K8 on bus 0 */ + } /* Die if any leftover Static devices are are found. * There's probably a problem in the Config.lb. @@ -567,7 +586,7 @@ unsigned int hypertransport_scan_chain(struct bus *bus, /* Now that nothing is overlapping it is safe to scan the * children. */ - max = pci_scan_bus(bus, 0x00, (next_unitid << 3)|7, max); + max = pci_scan_bus(bus, 0x00, ((next_unitid-1) << 3)|7, max); return max; } |