From 067e4274dfac41e6c57b45fbeb3ed1032a94da7a Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Delgado Date: Tue, 20 Dec 2016 10:08:45 +0100 Subject: [PATCH] UPSTREAM: agesawrapper: Fix endless loop on bettong AGESA AmdInitEarly() reconfigures the lapic timer in a way that conflicts with lapic/apic_timer. This results in an endless loop when printk() is called after AmdInitEarly() and before the apic_timer is initialized. This patch forces a reconfiguration of the timer after AmdInitEarly() is called. Codepath of the endless loop: printk()-> (...)-> uart_tx_byte-> uart8250_mem_tx_byte-> udelay()-> start = lapic_read(LAPIC_TMCCT); do { value = lapic_read(LAPIC_TMCCT); } while ((start - value) < ticks); [lapic_read returns the same value after AmdInitEarly()] BUG=none BRANCH=none TEST=none Change-Id: I32003d5fc62bcd2a54a91dc536d0e43315642c28 Signed-off-by: Patrick Georgi Original-Commit-Id: b2bb6ad2a72a926796a7eaede06ef8acd556c472 Original-Change-Id: I1a08789c89401b2bf6d11846ad7c376bfc68801b Original-Signed-off-by: Ricardo Ribalda Delgado Original-Reviewed-on: https://review.coreboot.org/17924 Original-Tested-by: build bot (Jenkins) Original-Reviewed-by: Patrick Georgi Original-Reviewed-by: Marshall Dawson Original-Reviewed-by: Paul Menzel Reviewed-on: https://chromium-review.googlesource.com/450237 --- src/northbridge/amd/pi/agesawrapper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/northbridge/amd/pi/agesawrapper.c b/src/northbridge/amd/pi/agesawrapper.c index 0fe8eab01c..2e79f47ac6 100644 --- a/src/northbridge/amd/pi/agesawrapper.c +++ b/src/northbridge/amd/pi/agesawrapper.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -107,6 +108,12 @@ AGESA_STATUS agesawrapper_amdinitearly(void) AmdEarlyParamsPtr->GnbConfig.PsppPolicy = PsppDisabled; status = AmdInitEarly ((AMD_EARLY_PARAMS *)AmdParamStruct.NewStructPtr); + /* + * init_timer() needs to be called on CZ PI, because AGESA resets the LAPIC reload value + * on the AMD_INIT_EARLY call + */ + if (IS_ENABLED(CONFIG_CPU_AMD_PI_00660F01)) + init_timer(); if (status != AGESA_SUCCESS) agesawrapper_amdreadeventlog(AmdParamStruct.StdHeader.HeapStatus); AmdReleaseStruct (&AmdParamStruct);