Skip to content

Commit c214e56

Browse files
computersforpeaceEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec_proto: ignore unnecessary wakeups on old ECs
ECs that don't implement EC_CMD_HOST_EVENT_GET_WAKE_MASK should still have some reasonable default mask -- otherwise, they'll treat a variety of EC signals as spurious wakeups. Battery and AC events can be especially common, for devices that have been sitting at full charge plugged into AC for a long time, as they may cycle their charging off and on, or their battery may start reporting failures as it ages. Treating these as wakeups does not serve a useful purpose, and is instead often counterproductive. And indeed, later ECs (that implement the mask) don't include these events in their wake-mask. Note that this patch doesn't do anything without the subsequent patch ("platform/chrome: cros_ec_proto: check for missing EC_CMD_HOST_EVENT_GET_WAKE_MASK"), because cros_ec_get_host_event_wake_mask() currently does not return an error if EC_CMD_HOST_EVENT_GET_WAKE_MASK is not implemented. Some additional notes: While the EC typically knows not to wake the CPU for these unimportant events once the CPU reaches a sleep state, it doesn't really have a way to know that the CPU is "almost" asleep, unless it has support for EC_CMD_HOST_SLEEP_EVENT. Alas, these older ECs do not support that command either, so this solution is not 100% complete. Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent 7f4784f commit c214e56

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,26 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev)
469469
&ver_mask);
470470
ec_dev->host_sleep_v1 = (ret >= 0 && (ver_mask & EC_VER_MASK(1)));
471471

472-
/*
473-
* Get host event wake mask, assume all events are wake events
474-
* if unavailable.
475-
*/
472+
/* Get host event wake mask. */
476473
ret = cros_ec_get_host_event_wake_mask(ec_dev, proto_msg,
477474
&ec_dev->host_event_wake_mask);
478-
if (ret < 0)
479-
ec_dev->host_event_wake_mask = U32_MAX;
475+
if (ret < 0) {
476+
/*
477+
* If the EC doesn't support EC_CMD_HOST_EVENT_GET_WAKE_MASK,
478+
* use a reasonable default. Note that we ignore various
479+
* battery, AC status, and power-state events, because (a)
480+
* those can be quite common (e.g., when sitting at full
481+
* charge, on AC) and (b) these are not actionable wake events;
482+
* if anything, we'd like to continue suspending (to save
483+
* power), not wake up.
484+
*/
485+
ec_dev->host_event_wake_mask = U32_MAX &
486+
~(BIT(EC_HOST_EVENT_AC_DISCONNECTED) |
487+
BIT(EC_HOST_EVENT_BATTERY_LOW) |
488+
BIT(EC_HOST_EVENT_BATTERY_CRITICAL) |
489+
BIT(EC_HOST_EVENT_PD_MCU) |
490+
BIT(EC_HOST_EVENT_BATTERY_STATUS));
491+
}
480492

481493
ret = 0;
482494

0 commit comments

Comments
 (0)