summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-07-23 18:31:27 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-12 21:00:19 +0000
commitd097611506bb7d854eb0d951a143b2438638d7be (patch)
treeb2f47b133d1ee7cfef67ea540d0ed71588ab9e00
parent140225eafd8f40d517c6191148855f9226cce089 (diff)
downloadchrome-ec-firmware-eve-9584.B.tar.gz
keyboard_8042: Clear buffer before adding command bytefirmware-eve-9584.B
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,b:199820376,b:172214981 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> (cherry picked from commit 30b2d3917316970182c8ada8ac6d95f8ae631838) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4159231 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
-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 41729266f0..a99416aa04 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;