google/chromeec: Drain all MKBP events while clearing host events

EC maintains a FIFO of all MKBP events and sets host event whenever
a new entry is added to the FIFO. Clearing only the host event for
MKBP creates an inconsistent state where there are pending MKBP events
in the FIFO but host event for MKBP is cleared. In order to maintain a
consistent view, host should clear all MKBP events in the FIFO if host
event is being cleared.

This change drains out all the MKBP events in the FIFO when
clear_pending_events is called.

TEST=Verified by adding debug logs in EC to verify that all the MKBP
events that occur before clear_pending_events is called get cleared
from the FIFO.

Change-Id: I131722dc01608dff30230fe341e6b23ae4cc409e
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://review.coreboot.org/22005
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
This commit is contained in:
Furquan Shaikh 2017-10-13 11:06:37 -07:00 committed by Furquan Shaikh
parent e01bf6452f
commit c1ca65df3f
1 changed files with 5 additions and 0 deletions

View File

@ -48,8 +48,13 @@ void chromeec_smi_process_events(void)
static void clear_pending_events(void)
{
struct ec_response_get_next_event mkbp_event;
while (google_chromeec_get_event() != 0)
;
while (google_chromeec_get_mkbp_event(&mkbp_event) == 0)
;
}
void chromeec_smi_sleep(int slp_type, uint32_t s3_mask, uint32_t s5_mask)