summaryrefslogtreecommitdiff
path: root/common/device_event.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-01-29 10:19:38 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-30 18:07:14 +0000
commit42eb485a06a851ebc3a7ea35dbb4498fcf3c61ac (patch)
tree60aca6262803df5b70622e5dcd2bc0cfd8911e8a /common/device_event.c
parent43a04f67d05d275d8e3927697965311eabe9357c (diff)
downloadchrome-ec-42eb485a06a851ebc3a7ea35dbb4498fcf3c61ac.tar.gz
device_event: Don't notify host of disabled events (2)
CL:2659684 made device_set_events skip notification for disabled flags and flags waiting to be consumed by the host. Resending notification for pending flags is redundant in most cases but we still need to do so in case the host didn't have a chance to consume the flag. Otherwise, the host would be never be notified thus the flag would never be consumed. BUG=b:36024430, b:178537669, b:177664326 BRANCH=Trogdor TEST=CoachZ. Verified host event isn't sent until powerd enables WLC. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I186c2ef0c4ffd3fc9c7fad1cba9e1478669735a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2660897 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/device_event.c')
-rw-r--r--common/device_event.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/common/device_event.c b/common/device_event.c
index 6ec764a3f6..0e86b00f32 100644
--- a/common/device_event.c
+++ b/common/device_event.c
@@ -40,18 +40,20 @@ void device_set_events(uint32_t mask)
/* Ignore events that are not enabled */
mask &= device_enabled_events;
- if ((device_current_events & mask) != mask)
+ if ((device_current_events & mask) != mask) {
CPRINTS("device event set 0x%08x", mask);
- else
+ } else {
/*
- * If no-op (1->1, 0->0), we don't notify the host. Host reads
- * & clears device_current_events atomically (by device_get_and
- * _clear_events). So, no-op means host has already been
- * notified but hasn't read it.
- * This API shouldn't be called for clear. So, it's ok to return
- * for 1->0 as well.
+ * We are here because there is no flag change (1->1, 0->0).
+ * For 0->0, we shouldn't notify the host because the flag is
+ * disabled. For 1->1, it's most likely redundant but we still
+ * need to notify the host in case the host didn't have a
+ * chance to read the flags. Otherwise, the flag would never be
+ * consumed because the host would never be notified.
*/
- return;
+ if (!mask)
+ return;
+ }
atomic_or(&device_current_events, mask);