Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8555
-gerrit
commit ac72f416365cb0dde210c12b7863760e7a196f2f
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Sat Feb 21 23:56:07 2015 +0200
AMD fam10: Fix add_more_links
One PCI function may contain upto 4 links, further links must
be added to PCI function 4 on the same device.
There is no requirement that in dev->link_list the last element
would have the highest link->link_num.
Also fix off-by-one error when allocating for more links.
Change-Id: If7ebdd1ad52653d3757b5930bd0a83e2cf2fcac6
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/northbridge/amd/amdfam10/northbridge.c | 41 +++++++++++++-----------------
1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c
index 4734522..424ecd7 100644
--- a/src/northbridge/amd/amdfam10/northbridge.c
+++ b/src/northbridge/amd/amdfam10/northbridge.c
@@ -176,18 +176,8 @@ static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool
#endif
u32 max_devfn;
- if (link->link_num > 3) {
- u32 regpos;
- u32 reg;
- regpos = 0x170 + 4 * (link->link_num & 3); // it is only on sublink0
- reg = pci_read_config32(dev, regpos);
- if(reg & 1) return max; // already ganged no sblink1
-
- dev = get_node_pci(nodeid, 4);
- }
-
/* Check for connected link. */
- link->cap = 0x80 + ((link->link_num & 3) * 0x20);
+ link->cap = 0x80 + (link->link_num * 0x20);
if (!is_non_coherent_link(dev, link))
return max;
@@ -1178,14 +1168,16 @@ static void sysconf_init(device_t dev) // first node
static void add_more_links(device_t dev, unsigned total_links)
{
struct bus *link, *last = NULL;
- int link_num;
+ int link_num = -1;
- for (link = dev->link_list; link; link = link->next)
+ for (link = dev->link_list; link; link = link->next) {
+ if (link_num < link->link_num)
+ link_num = link->link_num;
last = link;
+ }
if (last) {
- int links = total_links - last->link_num;
- link_num = last->link_num;
+ int links = total_links - (link_num + 1);
if (links > 0) {
link = malloc(links*sizeof(*link));
if (!link)
@@ -1195,7 +1187,6 @@ static void add_more_links(device_t dev, unsigned total_links)
}
}
else {
- link_num = -1;
link = malloc(total_links*sizeof(*link));
memset(link, 0, total_links*sizeof(*link));
dev->link_list = link;
@@ -1337,15 +1328,19 @@ static void cpu_bus_scan(device_t dev)
cdb_dev = pci_probe_dev(NULL, pbus,
PCI_DEVFN(devn, fn));
}
- cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 0));
- }
- if (cdb_dev) {
- /* Ok, We need to set the links for that device.
- * otherwise the device under it will not be scanned
- */
- add_more_links(cdb_dev, 8);
}
+ /* Ok, We need to set the links for that device.
+ * otherwise the device under it will not be scanned
+ */
+ cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 0));
+ if (cdb_dev)
+ add_more_links(cdb_dev, 4);
+
+ cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 4));
+ if (cdb_dev)
+ add_more_links(cdb_dev, 4);
+
cores_found = 0; // one core
cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 3));
int enable_node = cdb_dev && cdb_dev->enabled;
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8352
-gerrit
commit 6ffd034dab722bf7c4b3cdf7e00684bdb3c5b7ac
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Sun Feb 22 09:24:59 2015 +0200
AMD K8 fam10: Fix preprocessor use with SB_HT_CHAIN_ON_BUS0
Change-Id: I6bbd1b5eaa66a640e0a2e132c8d67f38f103caf5
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/northbridge/amd/amdfam10/northbridge.c | 36 +++++++++++++-----------------
src/northbridge/amd/amdk8/northbridge.c | 28 +++++++++--------------
2 files changed, 26 insertions(+), 38 deletions(-)
diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c
index fd134a2..caf5410 100644
--- a/src/northbridge/amd/amdfam10/northbridge.c
+++ b/src/northbridge/amd/amdfam10/northbridge.c
@@ -218,29 +218,25 @@ static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool
* We have no idea how many busses are behind this bridge yet,
* so we set the subordinate bus number to 0xff for the moment.
*/
-#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 0
- // first chain will on bus 0
- if (is_sblink) { // actually max is 0 here
- min_bus = max;
- }
- #if CONFIG_SB_HT_CHAIN_ON_BUS0 > 1
- // second chain will be on 0x40, third 0x80, forth 0xc0
- // i would refined that to 2, 3, 4 ==> 0, 0x, 40, 0x80, 0xc0
- // >4 will use more segments, We can have 16 segmment and every segment have 256 bus, For that case need the kernel support mmio pci config.
- else {
+
+ if (CONFIG_SB_HT_CHAIN_ON_BUS0 == 0) {
+ min_bus = ++max;
+ } else if (is_sblink) {
+ // first chain will on bus 0
+ min_bus = max; /* actually max is 0 here */
+ } else if (CONFIG_SB_HT_CHAIN_ON_BUS0 == 1) {
+ min_bus = ++max;
+ } else if (CONFIG_SB_HT_CHAIN_ON_BUS0 > 1) {
+ // second chain will be on 0x40, third 0x80, forth 0xc0
+ // i would refined that to 2, 3, 4 ==> 0, 0x, 40, 0x80, 0xc0
+ // >4 will use more segments,
+ // We can have 16 segmment and every segment have 256 bus,
+ // For that case need the kernel support mmio pci config.
+
/* One node can have 8 link and segn is the same. */
min_bus = (((max & 0xff) >> 3) + 1) << 3;
+ max = min_bus;
}
- max = min_bus;
- #else
- //other ...
- else {
- min_bus = ++max;
- }
- #endif
-#else
- min_bus = ++max;
-#endif
link->secondary = min_bus;
link->subordinate = link->secondary;
diff --git a/src/northbridge/amd/amdk8/northbridge.c b/src/northbridge/amd/amdk8/northbridge.c
index 018b68a..b27404e 100644
--- a/src/northbridge/amd/amdk8/northbridge.c
+++ b/src/northbridge/amd/amdk8/northbridge.c
@@ -179,26 +179,18 @@ static u32 amdk8_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool is_
* We have no idea how many busses are behind this bridge yet,
* so we set the subordinate bus number to 0xff for the moment.
*/
-#if CONFIG_SB_HT_CHAIN_ON_BUS0 > 0
- // first chain will on bus 0
- if(is_sblink) { // actually max is 0 here
- min_bus = max;
- }
- #if CONFIG_SB_HT_CHAIN_ON_BUS0 > 1
- // second chain will be on 0x40, third 0x80, forth 0xc0
- else {
- min_bus = ((max>>6) + 1) * 0x40;
- }
- max = min_bus;
- #else
- //other ...
- else {
+ if (CONFIG_SB_HT_CHAIN_ON_BUS0 == 0) {
+ min_bus = ++max;
+ } else if (is_sblink) {
+ // first chain will on bus 0
+ min_bus = max; /* actually max is 0 here */
+ } else if (CONFIG_SB_HT_CHAIN_ON_BUS0 == 1) {
min_bus = ++max;
+ } else if (CONFIG_SB_HT_CHAIN_ON_BUS0 > 1) {
+ /* Second chain will be on 0x40, third 0x80, forth 0xc0. */
+ min_bus = (max & ~0x3f) + 0x40;
+ max = min_bus;
}
- #endif
-#else
- min_bus = ++max;
-#endif
link->secondary = min_bus;
link->subordinate = link->secondary;
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8561
-gerrit
commit 2fd1f22bcc62af9dc4eac5254c368a0e1edd71a1
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Thu Feb 5 15:43:23 2015 +0200
AMD K8 fam10: Always have SB_HT_CHAIN_ON_BUS0
Change-Id: I65fad1cfba95f0ee1ed3f7f7a57d874144da1e40
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/northbridge/amd/amdfam10/Kconfig | 3 ---
src/northbridge/amd/amdfam10/northbridge.c | 5 +----
src/northbridge/amd/amdk8/Kconfig | 3 ---
src/northbridge/amd/amdk8/northbridge.c | 5 +----
4 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/src/northbridge/amd/amdfam10/Kconfig b/src/northbridge/amd/amdfam10/Kconfig
index fa8a26a..0987a1f 100644
--- a/src/northbridge/amd/amdfam10/Kconfig
+++ b/src/northbridge/amd/amdfam10/Kconfig
@@ -64,9 +64,6 @@ config SB_HT_CHAIN_UNITID_OFFSET_ONLY
bool
default n
-config SB_HT_CHAIN_ON_BUS0
- def_bool y
-
config HT_CHAIN_DISTRIBUTE
def_bool n
diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c
index e4d32f9..df0d712 100644
--- a/src/northbridge/amd/amdfam10/northbridge.c
+++ b/src/northbridge/amd/amdfam10/northbridge.c
@@ -216,7 +216,7 @@ static u32 amdfam10_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool
* so we set the subordinate bus number to 0xff for the moment.
*/
- if (!CONFIG_SB_HT_CHAIN_ON_BUS0 || !is_sblink)
+ if (!is_sblink)
max++;
/* One node can have 8 link and segn is the same. */
@@ -280,9 +280,6 @@ static void relocate_sb_ht_chain(void)
struct bus *link, *prev = NULL;
u8 sblink;
- if (!CONFIG_SB_HT_CHAIN_ON_BUS0)
- return;
-
dev = dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB, 0));
sblink = (pci_read_config32(dev, 0x64)>>8) & 7;
link = dev->link_list;
diff --git a/src/northbridge/amd/amdk8/Kconfig b/src/northbridge/amd/amdk8/Kconfig
index b293ce3..21d3c29 100644
--- a/src/northbridge/amd/amdk8/Kconfig
+++ b/src/northbridge/amd/amdk8/Kconfig
@@ -64,9 +64,6 @@ config SB_HT_CHAIN_UNITID_OFFSET_ONLY
bool
default n
-config SB_HT_CHAIN_ON_BUS0
- def_bool y
-
config HT_CHAIN_DISTRIBUTE
def_bool n
diff --git a/src/northbridge/amd/amdk8/northbridge.c b/src/northbridge/amd/amdk8/northbridge.c
index 3ac626d..84c1144 100644
--- a/src/northbridge/amd/amdk8/northbridge.c
+++ b/src/northbridge/amd/amdk8/northbridge.c
@@ -179,7 +179,7 @@ static u32 amdk8_scan_chain(device_t dev, u32 nodeid, struct bus *link, bool is_
* so we set the subordinate bus number to 0xff for the moment.
*/
- if (!CONFIG_SB_HT_CHAIN_ON_BUS0 || !is_sblink)
+ if (!is_sblink)
max++;
/* Second chain will be on 0x40, third 0x80, forth 0xc0. */
@@ -249,9 +249,6 @@ static void relocate_sb_ht_chain(void)
struct bus *link, *prev = NULL;
u8 sblink;
- if (!CONFIG_SB_HT_CHAIN_ON_BUS0)
- return;
-
dev = dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB, 0));
sblink = (pci_read_config32(dev, 0x64)>>8) & 3;
link = dev->link_list;