summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-11-01 15:22:02 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-11-04 18:31:37 -0700
commit1f6600fd344bb5eb5476206a05c2bc773252d788 (patch)
treed8caf368622dbfc5fe07788f591030dd24d5cc3e /common
parentf7d5360449aa3eead464c37d3ded19f582e6291e (diff)
downloadchrome-ec-1f6600fd344bb5eb5476206a05c2bc773252d788.tar.gz
mkbp_event: Properly queue events during host sleep
Don't queue non-wake events, and ensure wake events (and all subsequent events) always get queued. BUG=chrome-os-partner:59248, chrome-os-partner:59336 BRANCH=gru TEST=Manual on kevin, go to suspend, press volume keys dozens of times, press 'shift', verify device wakes. Place cursor on URL bar, go to suspend, type "google" quickly, verify device wakes and "google" appears on URL bar. Go to suspend, press 'VolUp' key 5 times, press keyboard, verify device wakes and no volume meter is seen on display. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ibe761187fbcefd686776a512786550970a6fc067 Reviewed-on: https://chromium-review.googlesource.com/405717 Commit-Queue: Douglas Anderson <dianders@chromium.org> Tested-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> (cherry picked from commit aa2f01566314604404e104d7975c6c755c22a601) Reviewed-on: https://chromium-review.googlesource.com/407958 Commit-Ready: Douglas Anderson <dianders@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/keyboard_mkbp.c20
-rw-r--r--common/mkbp_event.c16
2 files changed, 17 insertions, 19 deletions
diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c
index 08ec9d8c80..85e9a7b106 100644
--- a/common/keyboard_mkbp.c
+++ b/common/keyboard_mkbp.c
@@ -161,7 +161,6 @@ test_mockable int keyboard_fifo_add(const uint8_t *buffp)
test_mockable int mkbp_fifo_add(uint8_t event_type, const uint8_t *buffp)
{
- int ret = EC_SUCCESS;
uint8_t size;
/*
@@ -175,8 +174,8 @@ test_mockable int mkbp_fifo_add(uint8_t event_type, const uint8_t *buffp)
if (fifo_entries >= config.fifo_max_depth) {
CPRINTS("MKBP common FIFO depth %d reached",
config.fifo_max_depth);
- ret = EC_ERROR_OVERFLOW;
- goto fifo_push_done;
+
+ return EC_ERROR_OVERFLOW;
}
size = get_data_size(event_type);
@@ -185,14 +184,17 @@ test_mockable int mkbp_fifo_add(uint8_t event_type, const uint8_t *buffp)
memcpy(&fifo[fifo_end].data, buffp, size);
fifo_end = (fifo_end + 1) % FIFO_DEPTH;
atomic_add(&fifo_entries, 1);
- mutex_unlock(&fifo_mutex);
-fifo_push_done:
-
- if (ret == EC_SUCCESS)
- mkbp_send_event(event_type);
+ /*
+ * If our event didn't generate an interrupt then the host is still
+ * asleep. In this case, we don't want to queue our event, except if
+ * another event just woke the host (and wake is already in progress).
+ */
+ if (!mkbp_send_event(event_type) && fifo_entries == 1)
+ mkbp_clear_fifo();
- return ret;
+ mutex_unlock(&fifo_mutex);
+ return EC_SUCCESS;
}
void mkbp_update_switches(uint32_t sw, int state)
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index ec8aad35aa..6848bd2813 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -60,26 +60,22 @@ static inline int host_is_sleeping(void)
return is_sleeping;
}
-void mkbp_send_event(uint8_t event_type)
+int mkbp_send_event(uint8_t event_type)
{
set_event(event_type);
#ifdef CONFIG_MKBP_WAKEUP_MASK
/* Only assert interrupt for wake events if host is sleeping */
if (host_is_sleeping()) {
- /*
- * interrupt the AP if it is a wakeup event
- * which is defined in the white list.
- */
- if ((host_get_events() & CONFIG_MKBP_WAKEUP_MASK) ||
- (event_type == EC_MKBP_EVENT_KEY_MATRIX))
- set_host_interrupt(1);
-
- return;
+ /* Skip host wake if this isn't a wake event */
+ if (!(host_get_events() & CONFIG_MKBP_WAKEUP_MASK) &&
+ event_type != EC_MKBP_EVENT_KEY_MATRIX)
+ return 0;
}
#endif
set_host_interrupt(1);
+ return 1;
}
static int mkbp_get_next_event(struct host_cmd_handler_args *args)