summaryrefslogtreecommitdiff
path: root/common/keyboard_8042.c
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-07-23 18:31:27 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-07-25 00:14:48 -0700
commit30b2d3917316970182c8ada8ac6d95f8ae631838 (patch)
tree42afab9ef2a5202e264efa191f4bc3f2258ac5e5 /common/keyboard_8042.c
parent1a7c1210fba8a0aee04a4f2ea3a931be415c78f3 (diff)
downloadchrome-ec-30b2d3917316970182c8ada8ac6d95f8ae631838.tar.gz
keyboard_8042: Clear buffer before adding command byte
When the host attempts to read CTR, first clear the keyboard buffer to ensure that we do not have any stale data in it. If the buffered data is not cleared, host could end up interpreting the keypress data as CTR thus resulting in unwanted side-effects. Reason for putting in this change is because Linux kernel does not disable keyboard scanning when doing a reboot or poweroff. Now, if user keeps pressing keys while the system is booting up, kernel could end up reading key press data as CTR thus resulting in keyboard being disabled on boot-up. This change ensures that keyboard buffer is cleared before adding CTR data to it. BUG=b:111228655 BRANCH=poppy,eve,nami TEST=Verified on nautilus that keyboard is still functional after doing a reboot from AP shell and continuously pressing keys while system is booting up in normal mode. Change-Id: I5cbc904629fbd40b39625e37abccb80c83447d39 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1147866 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/keyboard_8042.c')
-rw-r--r--common/keyboard_8042.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index 91d640fde8..08ebeb43b1 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -667,6 +667,13 @@ static int handle_keyboard_command(uint8_t command, uint8_t *output)
switch (command) {
case I8042_READ_CMD_BYTE:
+ /*
+ * Ensure that the keyboard buffer is cleared before adding
+ * command byte to it. Since the host is asking for command
+ * byte, sending it buffered key press data can confuse the
+ * host and result in it taking incorrect action.
+ */
+ keyboard_clear_buffer();
output[out_len++] = read_ctl_ram(0);
break;