From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Brian Norris <briannorris@chromium.org>,
Benson Leung <bleung@chromium.org>,
Guenter Roeck <groeck@chromium.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] platform/chrome: cros_ec_proto: ignore unnecessary wakeups on old ECs
Date: Mon, 17 Aug 2020 13:30:48 +0200 [thread overview]
Message-ID: <8a3b8af8-12d3-0566-49f2-cd763d7a2002@collabora.com> (raw)
In-Reply-To: <20200724190841.3112365-1-briannorris@chromium.org>
Hi Brian,
On 24/7/20 21:08, Brian Norris wrote:
> 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 <briannorris@chromium.org>
Sorry for late notice. The patch has been applied for 5.9.
> ---
> v2:
> * more notes in commit message
> ---
> drivers/platform/chrome/cros_ec_proto.c | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> index 3e745e0fe092..e93024b55ce8 100644
> --- a/drivers/platform/chrome/cros_ec_proto.c
> +++ b/drivers/platform/chrome/cros_ec_proto.c
> @@ -469,14 +469,26 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev)
> &ver_mask);
> ec_dev->host_sleep_v1 = (ret >= 0 && (ver_mask & EC_VER_MASK(1)));
>
> - /*
> - * Get host event wake mask, assume all events are wake events
> - * if unavailable.
> - */
> + /* Get host event wake mask. */
> ret = cros_ec_get_host_event_wake_mask(ec_dev, proto_msg,
> &ec_dev->host_event_wake_mask);
> - if (ret < 0)
> - ec_dev->host_event_wake_mask = U32_MAX;
> + if (ret < 0) {
> + /*
> + * If the EC doesn't support EC_CMD_HOST_EVENT_GET_WAKE_MASK,
> + * use a reasonable default. Note that we ignore various
> + * battery, AC status, and power-state events, because (a)
> + * those can be quite common (e.g., when sitting at full
> + * charge, on AC) and (b) these are not actionable wake events;
> + * if anything, we'd like to continue suspending (to save
> + * power), not wake up.
> + */
> + ec_dev->host_event_wake_mask = U32_MAX &
> + ~(BIT(EC_HOST_EVENT_AC_DISCONNECTED) |
> + BIT(EC_HOST_EVENT_BATTERY_LOW) |
> + BIT(EC_HOST_EVENT_BATTERY_CRITICAL) |
> + BIT(EC_HOST_EVENT_PD_MCU) |
> + BIT(EC_HOST_EVENT_BATTERY_STATUS));
> + }
>
> ret = 0;
>
>
prev parent reply other threads:[~2020-08-17 11:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 19:08 Brian Norris
2020-07-24 19:08 ` [PATCH v2 2/2] platform/chrome: cros_ec_proto: check for missing EC_CMD_HOST_EVENT_GET_WAKE_MASK Brian Norris
2020-08-17 11:31 ` Enric Balletbo i Serra
2020-08-17 11:30 ` Enric Balletbo i Serra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a3b8af8-12d3-0566-49f2-cd763d7a2002@collabora.com \
--to=enric.balletbo@collabora.com \
--cc=bleung@chromium.org \
--cc=briannorris@chromium.org \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®