diff options
author | Raul E Rangel <rrangel@chromium.org> | 2020-02-25 16:20:23 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-27 19:42:24 +0000 |
commit | c70d0a3e25db1a687c09a392b5e43b7a95cf94a8 (patch) | |
tree | 3703597d8b25cb89e4df1926779c36f3d4489347 | |
parent | ce143d577fa85acae86ae372a7521d7def6c2391 (diff) | |
download | chrome-ec-c70d0a3e25db1a687c09a392b5e43b7a95cf94a8.tar.gz |
chip/nxcp/lpc: Fix race condition when reading 8042 data.
When reading NPCX_HIKMDI it deasserts the IBF status flag. This means
the AP is allowed to write to the input buffer. Because NPCX_HIKMDI is
read twice, that means the AP could have written to the input buffer
between reads. This results in losing one of the interrupts. This only
happens if DEBUG_LPC is enabled.
BUG=b:145575366
BRANCH=none
TEST=Verified we don't lose any writes by examining logs.
Change-Id: I2904c316fcad55001e8d297f4a0a73073b07702b
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2073280
Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r-- | chip/npcx/lpc.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/chip/npcx/lpc.c b/chip/npcx/lpc.c index 18b464f294..5162ff158d 100644 --- a/chip/npcx/lpc.c +++ b/chip/npcx/lpc.c @@ -511,11 +511,16 @@ static void handle_host_write(int is_cmd) /* KB controller input buffer full ISR */ void lpc_kbc_ibf_interrupt(void) { + uint8_t ibf; /* If "command" input 0, else 1*/ - if (lpc_keyboard_input_pending()) - keyboard_host_write(NPCX_HIKMDI, (NPCX_HIKMST & 0x08) ? 1 : 0); - CPRINTS("ibf isr %02x", NPCX_HIKMDI); - task_wake(TASK_ID_KEYPROTO); + if (lpc_keyboard_input_pending()) { + ibf = NPCX_HIKMDI; + keyboard_host_write(ibf, (NPCX_HIKMST & 0x08) ? 1 : 0); + CPRINTS("ibf isr %02x", ibf); + task_wake(TASK_ID_KEYPROTO); + } else { + CPRINTS("ibf isr spurious"); + } } DECLARE_IRQ(NPCX_IRQ_KBC_IBF, lpc_kbc_ibf_interrupt, 4); |