summaryrefslogtreecommitdiff
path: root/common/keyboard_mkbp.c
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2017-11-15 17:18:20 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-11-21 15:58:42 -0800
commit0da531fae0099080b7dd472ade0788c18162cc19 (patch)
tree7aabf3e458e8da5ab72990e78344f52bb88c686a /common/keyboard_mkbp.c
parent267320bd477f9758bb7d16e32985c671cc92475a (diff)
downloadchrome-ec-0da531fae0099080b7dd472ade0788c18162cc19.tar.gz
coral: Fix corner case for battery_present_timer_started flag
With the SMP and Celxpert batteries for Robo systems, following battery cutoff, there is a race condition resulting from a failed sb_read operation when the battery status is read. If this read fails, then the flag battery_report_present is reset to 0. Since this flag gets set in a hook task deferred callback, if the sb_read fails after battery_report_present is set, but before batt_pres is set to BP_YES, then the deferred call would not be restarted. This results in the battery_is_present call returning BP_NO indefinitely. To fix this condition, this CL ensures that battery_report_present_timer_started is cleared for any case that could result in BP_NO. This addressed both this corner case and makes redundant a previous change that was put to handle the case where the battery is disconnected and reconnected while the system remains powered. The CL also adjusts the timer to 0.5 sec so that in the event it has to be called twice, it doesn't exceed the previous 1 second timer and delay boot time even longer. BUG=b:69151530 BRANCH=coral TEST=With the DUT powered, removed and reconnected the battery. Ensured that the battery again reports present. Bitland also verified that with this CL they can no longer reproduce the issue. For the corner case, had additional debug console prints. (Note this is with 1 second timer) The deferred call is started. [0.156135 battery timer hook call] This shows where the sb_read error happens in batt_init() [1.085627 Battery FET: reg 0x0018 mask 0x0010 disc 0x0000] [1.092251 battery: pres 0, prev_pres 0, cutoff 0, init 1, rep 0] [1.160969 battery will now report present] This shows where the batt_report present gets cleared [1.184993 ******** batt_report_present 1 -> 0 *****] [1.185840 Battery read status failed] [1.186540 report = 0, batt_init 1->0: stat = 0x200c6bea 1 get 1] [1.187544 battery: pres 0, prev_pres 0, cutoff 0, init 0, rep 0] [1.193796 Battery read status failed] [1.194886 battery: pres 0, prev_pres 0, cutoff 0, init 0, rep 0] batt_init() no longer returns 0, so deferred call is restarted [1.290559 Battery FET: reg 0x0018 mask 0x0010 disc 0x0000] [1.292942 battery timer hook call] battery reports present now [2.293436 battery will now report present] Change-Id: I89d69cf133365affc4cc538328daeaaf9ac05ed9 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/773623 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> (cherry picked from commit 535080115d20dc223dab6288c5fea02da67c8e9c) Reviewed-on: https://chromium-review.googlesource.com/782599 Commit-Ready: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'common/keyboard_mkbp.c')
0 files changed, 0 insertions, 0 deletions