summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-05-29 11:12:42 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-30 01:04:52 +0000
commitebc3b8b93c43f09d39a6273fffa5e65b231724b8 (patch)
treed2d5c13a204707d060d4dae8a8fdb6fd3e8fca46
parent61ee1d732368da2e3c6e51ebf9102969273c11a8 (diff)
downloadchrome-ec-ebc3b8b93c43f09d39a6273fffa5e65b231724b8.tar.gz
keyboard_mkbp: fix interrupt handling with MKBP_EVENT
When CONFIG_MKBP_EVENT is enabled, the current code is incorrect because we have a race condition when sending a new event (we force first the interrupt, then send the actual event content to the mkbp event framework which forces again the interrupt level). If the software still called EC_CMD_MKBP_STATE while CONFIG_MKBP_EVENT is enabled, this will kill the interrupt as soon as the FIFO is empty even though other events are pending in order to be backward compatible with firmware using the interrupt has a hint when polling the keyboard. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:33194 TEST=make buildall fiddle with keyboard on Oak. Change-Id: Iafaf4174124934328c4a0172adeca651e5551f28 Reviewed-on: https://chromium-review.googlesource.com/274070 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/keyboard_mkbp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c
index 82fc93bdf2..443f2b47fc 100644
--- a/common/keyboard_mkbp.c
+++ b/common/keyboard_mkbp.c
@@ -148,9 +148,10 @@ test_mockable int keyboard_fifo_add(const uint8_t *buffp)
kb_fifo_push_done:
if (ret == EC_SUCCESS) {
- set_host_interrupt(1);
#ifdef CONFIG_MKBP_EVENT
mkbp_send_event(EC_MKBP_EVENT_KEY_MATRIX);
+#else
+ set_host_interrupt(1);
#endif
}
@@ -193,6 +194,12 @@ void keyboard_send_battery_key(void)
static int keyboard_get_scan(struct host_cmd_handler_args *args)
{
kb_fifo_remove(args->response);
+ /* if CONFIG_MKBP_EVENT is enabled, we still reset the interrupt
+ * (even if there is an another pending event)
+ * to be backward compatible with firmware using the old API to poll
+ * the keyboard, other software should use EC_CMD_GET_NEXT_EVENT
+ * instead of this command
+ */
if (!kb_fifo_entries)
set_host_interrupt(0);