Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8688
-gerrit
commit 901f0138ac556cfb6605177c2306d9b14caf22aa Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Thu Mar 12 05:56:22 2015 +0200
HyperTransport: Use subordinate property to track chain enumeration
For amdfam10, (ht_c_index > 3) never evaluates true as the code already has a return for this case above.
Change-Id: Ie90941671e1b2b4f42e2b1b0641ca59334fcf0f1 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/device/hypertransport.c | 4 ++-- src/northbridge/amd/agesa/family10/northbridge.c | 11 ++++++++--- src/northbridge/amd/agesa/family15/northbridge.c | 14 ++++++++++---- src/northbridge/amd/amdfam10/northbridge.c | 23 ++++++++++++----------- src/northbridge/amd/amdk8/northbridge.c | 20 ++++++++++++++------ 5 files changed, 46 insertions(+), 26 deletions(-)
diff --git a/src/device/hypertransport.c b/src/device/hypertransport.c index 1a2e7ff..84b1aa7 100644 --- a/src/device/hypertransport.c +++ b/src/device/hypertransport.c @@ -501,8 +501,8 @@ static unsigned int hypertransport_scan_chain_x(struct bus *bus, ht_unitid_base, offset_unitid);
/* Now that nothing is overlapping it is safe to scan the children. */ - max = pci_scan_bus(bus, 0x00, ((next_unitid - 1) << 3) | 7, max); - return max; + bus->subordinate = pci_scan_bus(bus, 0x00, ((next_unitid - 1) << 3) | 7, bus->secondary); + return bus->subordinate; }
unsigned int ht_scan_bridge(struct device *dev, unsigned int max) diff --git a/src/northbridge/amd/agesa/family10/northbridge.c b/src/northbridge/amd/agesa/family10/northbridge.c index 6d0b1b7..9f2555f 100644 --- a/src/northbridge/amd/agesa/family10/northbridge.c +++ b/src/northbridge/amd/agesa/family10/northbridge.c @@ -554,13 +554,14 @@ static void mcf0_control_init(struct device *dev) { }
-static unsigned amdfam10_scan_chains(device_t dev, unsigned max) +static unsigned amdfam10_scan_chains(device_t dev, unsigned unused) { unsigned nodeid; struct bus *link; unsigned sblink = sysconf.sblk; device_t io_hub = NULL; u32 next_unitid = 0xff; + unsigned int max = dev->bus->subordinate;
nodeid = amdfam10_nodeid(dev); if (nodeid == 0) { @@ -576,7 +577,9 @@ static unsigned amdfam10_scan_chains(device_t dev, unsigned max) } }
- return max; + dev->bus->subordinate = max; + + return unused; }
static struct device_operations northbridge_operations = { @@ -913,7 +916,9 @@ static u32 amdfam10_domain_scan_bus(device_t dev, u32 max) }
for (link = dev->link_list; link; link = link->next) { - max = pci_scan_bus(link, PCI_DEVFN(CONFIG_CDB, 0), 0xff, max); + link->secondary = dev->bus->subordinate; + link->subordinate = pci_scan_bus(link, PCI_DEVFN(CONFIG_CDB, 0), 0xff, link->secondary); + dev->bus->subordinate = link->subordinate; }
/* Tune the hypertransport transaction for best performance. diff --git a/src/northbridge/amd/agesa/family15/northbridge.c b/src/northbridge/amd/agesa/family15/northbridge.c index b2d8abd..a4f78f1 100644 --- a/src/northbridge/amd/agesa/family15/northbridge.c +++ b/src/northbridge/amd/agesa/family15/northbridge.c @@ -459,12 +459,14 @@ static void nb_set_resources(device_t dev) } }
-static unsigned scan_chains(device_t dev, unsigned max) +static unsigned scan_chains(device_t dev, unsigned unused) { unsigned nodeid; struct bus *link; device_t io_hub = NULL; u32 next_unitid = 0x18; + unsigned int max = dev->bus->subordinate; + nodeid = amdfam15_nodeid(dev); if (nodeid == 0) { for (link = dev->link_list; link; link = link->next) { @@ -479,7 +481,10 @@ static unsigned scan_chains(device_t dev, unsigned max) } } } - return max; + + dev->bus->subordinate = max; + + return unused; }
@@ -948,8 +953,9 @@ static void domain_set_resources(device_t dev) /* all family15's pci devices are under 0x18.0, so we search from dev 0x18 fun 0 */ static unsigned int f15_pci_domain_scan_bus(device_t dev, unsigned int max) { - max = pci_scan_bus(dev->link_list, PCI_DEVFN(0x18, 0), 0xff, max); - return max; + struct bus *link = dev->link_list; + link->subordinate = pci_scan_bus(link, PCI_DEVFN(0x18, 0), 0xff, link->secondary); + return link->subordinate; }
static struct device_operations pci_domain_ops = { diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c index a2124f0..c3473d8 100644 --- a/src/northbridge/amd/amdfam10/northbridge.c +++ b/src/northbridge/amd/amdfam10/northbridge.c @@ -263,16 +263,11 @@ static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool next_unitid = hypertransport_scan_chain(link, 0, max_devfn, ht_unitid_base, offset_unit_id(is_sblink));
/* Now that nothing is overlapping it is safe to scan the children. */ - max = pci_scan_bus(link, 0x00, ((next_unitid - 1) << 3) | 7, max); + link->subordinate = pci_scan_bus(link, 0x00, ((next_unitid - 1) << 3) | 7, link->secondary);
/* We know the number of busses behind this bridge. Set the * subordinate bus number to it's real value */ - if(ht_c_index>3) { // clear the extend reg - clear_config_map_reg(nodeid, link->link_num, ht_c_index, (max+1)>>sysconf.segbit, (link->subordinate)>>sysconf.segbit, sysconf.nodes); - } - - link->subordinate = max; set_config_map_reg(nodeid, link->link_num, ht_c_index, link->secondary, link->subordinate, sysconf.segbit, sysconf.nodes); sysconf.ht_c_num++;
@@ -286,15 +281,16 @@ static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool sysconf.hcdn_reg[ht_c_index] = temp;
} - store_ht_c_conf_bus(nodeid, link->link_num, ht_c_index, link->secondary, link->subordinate, &sysconf); - return max; + store_ht_c_conf_bus(nodeid, link->link_num, ht_c_index, link->secondary, link->subordinate, &sysconf); + return link->subordinate; }
-static unsigned amdfam10_scan_chains(device_t dev, unsigned max) +static unsigned amdfam10_scan_chains(device_t dev, unsigned unused) { unsigned nodeid; struct bus *link; unsigned sblink = sysconf.sblk; + unsigned int max = dev->bus->subordinate;
nodeid = amdfam10_nodeid(dev);
@@ -312,7 +308,10 @@ static unsigned amdfam10_scan_chains(device_t dev, unsigned max)
max = amdfam10_scan_chain(dev, nodeid, link, is_sblink, max); } - return max; + + dev->bus->subordinate = max; + + return unused; }
@@ -924,7 +923,9 @@ static u32 amdfam10_domain_scan_bus(device_t dev, u32 max) }
for(link = dev->link_list; link; link = link->next) { - max = pci_scan_bus(link, PCI_DEVFN(CONFIG_CDB, 0), 0xff, max); + link->secondary = dev->bus->subordinate; + link->subordinate = pci_scan_bus(link, PCI_DEVFN(CONFIG_CDB, 0), 0xff, link->secondary); + dev->bus->subordinate = link->subordinate; }
/* Tune the hypertransport transaction for best performance. diff --git a/src/northbridge/amd/amdk8/northbridge.c b/src/northbridge/amd/amdk8/northbridge.c index 29cc5ed..6b06f52 100644 --- a/src/northbridge/amd/amdk8/northbridge.c +++ b/src/northbridge/amd/amdk8/northbridge.c @@ -213,12 +213,11 @@ static u32 amdk8_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool is_ next_unitid = hypertransport_scan_chain(link, 0, max_devfn, ht_unitid_base, offset_unit_id(is_sblink));
/* Now that nothing is overlapping it is safe to scan the children. */ - max = pci_scan_bus(link, 0x00, ((next_unitid - 1) << 3) | 7, max); + link->subordinate = pci_scan_bus(link, 0x00, ((next_unitid - 1) << 3) | 7, link->secondary);
/* We know the number of busses behind this bridge. Set the * subordinate bus number to it's real value */ - link->subordinate = max; busses = (busses & 0xff00ffff) | ((unsigned int) (link->subordinate) << 16); pci_write_config32(dev, link->cap + 0x14, busses); @@ -239,14 +238,15 @@ static u32 amdk8_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool is_ sysconf.hcdn_reg[index] = temp;
} - return max; + return link->subordinate; }
-static unsigned amdk8_scan_chains(device_t dev, unsigned max) +static unsigned amdk8_scan_chains(device_t dev, unsigned unused) { unsigned nodeid; struct bus *link; unsigned sblink = 0; + unsigned int max = dev->bus->subordinate;
nodeid = amdk8_nodeid(dev); if (nodeid == 0) @@ -266,7 +266,10 @@ static unsigned amdk8_scan_chains(device_t dev, unsigned max)
max = amdk8_scan_chain(dev, nodeid, link, is_sblink, max); } - return max; + + dev->bus->subordinate = max; + + return unused; }
@@ -1096,11 +1099,16 @@ static u32 amdk8_domain_scan_bus(device_t dev, u32 max) { u32 reg; int i; + struct bus *link = dev->link_list; + /* Unmap all of the HT chains */ for(reg = 0xe0; reg <= 0xec; reg += 4) { f1_write_config32(reg, 0); } - max = pci_scan_bus(dev->link_list, PCI_DEVFN(0x18, 0), 0xff, max); + + link->secondary = dev->bus->subordinate; + link->subordinate = pci_scan_bus(link, PCI_DEVFN(0x18, 0), 0xff, link->secondary); + dev->bus->subordinate = link->subordinate;
/* Tune the hypertransport transaction for best performance. * Including enabling relaxed ordering if it is safe.