From 78992e730bb663180e947650787b4c4c8253fc53 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Mon, 25 Nov 2013 17:14:58 -0800 Subject: lm4: Fix potential false over-temperature on entry to S0 This fixes a rare problem in which the EC could shutdown due to a false over-temperature when entering S0 on Haswell architectures. The fix involves requiring two valid reads of the temperature sensor (out of the last 4 readings) in order to report it. BUG=chrome-os-partner:24204 BRANCH=none TEST=See bug report for a patch that recreates the bug at a significantly higher rate then it would occur on its own. Using that patch, I implemented this fix, and made sure that there were no false over-temperatures reported. Change-Id: I0454eca1b96fd2fa1833b080026ed8f1caeeddc4 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/177963 Reviewed-by: Randall Spangler --- chip/lm4/peci.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chip/lm4/peci.c b/chip/lm4/peci.c index d3fbd30947..d66956202b 100644 --- a/chip/lm4/peci.c +++ b/chip/lm4/peci.c @@ -75,7 +75,15 @@ int peci_temp_sensor_get_val(int idx, int *temp_ptr) } } - if (!success_cnt) + /* + * Require at least two valid samples. When the AP transitions into S0, + * it is possible, depending on the timing of the PECI sample, to read + * an invalid temperature. This is very rare, but when it does happen + * the temperature returned is PECI_TJMAX. Requiring two valid samples + * here assures us that one bad maximum temperature reading when + * entering S0 won't cause us to trigger an over temperature. + */ + if (success_cnt < 2) return EC_ERROR_UNKNOWN; *temp_ptr = sum / success_cnt; -- cgit v1.2.1