Michał Żygowski has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/62100 )
Change subject: nb/amd/amdfam10/bootblock.c: Refactor HT link error ......................................................................
nb/amd/amdfam10/bootblock.c: Refactor HT link error
Signed-off-by: Michał Żygowski michal.zygowski@3mdeb.com Change-Id: I37d46f42e13fb398529da3d963f57e21165d1b59 --- M src/northbridge/amd/amdfam10/bootblock.c 1 file changed, 24 insertions(+), 17 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/62100/1
diff --git a/src/northbridge/amd/amdfam10/bootblock.c b/src/northbridge/amd/amdfam10/bootblock.c index 0fe2464..547eff6 100644 --- a/src/northbridge/amd/amdfam10/bootblock.c +++ b/src/northbridge/amd/amdfam10/bootblock.c @@ -67,6 +67,28 @@ return false; }
+static bool check_ht_link_error(pci_devfn_t dev, u8 offset) +{ + u16 ctrl = pci_read_config16(dev, offset); + + if (ctrl & (HT_LINK_CTRL_LINK_FAIL | HT_LINK_CTRL_CRC_UNRECOV_ERR)) { + /* + * Either the link has failed, or we have a CRC error. + * Sometimes this can happen due to link retrain, so lets knock + * it down and see if its transient + */ + ctrl |= (HT_LINK_CTRL_LINK_FAIL | HT_LINK_CTRL_CRC_UNRECOV_ERR); + pci_write_config16(dev, offset, ctrl); + ctrl = pci_read_config16(dev, offset); + if (ctrl & (HT_LINK_CTRL_LINK_FAIL | HT_LINK_CTRL_CRC_UNRECOV_ERR)) { + /* Can not clear the error */ + return true; + } + } + + return false; +} + static void enumerate_ht_chain(void) {
@@ -167,23 +189,8 @@ return; }
- if (ctrl & (HT_LINK_CTRL_LINK_FAIL | HT_LINK_CTRL_CRC_UNRECOV_ERR)) { - /* - * Either the link has failed, - * or we have a CRC error. - * Sometimes this can happen - * due to link retrain, so lets - * knock it down and see if its - * transient - */ - ctrl |= (HT_LINK_CTRL_LINK_FAIL | HT_LINK_CTRL_CRC_UNRECOV_ERR); - pci_write_config16(devx, pos + ctrl_off, ctrl); - ctrl = pci_read_config16(devx, pos + ctrl_off); - if (ctrl & (HT_LINK_CTRL_LINK_FAIL | HT_LINK_CTRL_CRC_UNRECOV_ERR)) { - /* Can not clear the error */ - break; - } - } + if (check_ht_link_error(devx, pos + ctrl_off)) + break; } while (!(ctrl & HT_LINK_CTRL_INIT_COMPLETE));
break;