diff options
author | Boris Mittelberg <bmbm@google.com> | 2021-05-19 00:01:43 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-26 00:50:28 +0000 |
commit | 52b9dbb7d0ff0bf58bd3d2cedaeb9a21515bcff7 (patch) | |
tree | 183dd1eb2cd638308c05a8e87b39d4ff8efcecc8 /power/host_sleep.c | |
parent | b657c3e96d1809e82554f8c859afffba358a3567 (diff) | |
download | chrome-ec-52b9dbb7d0ff0bf58bd3d2cedaeb9a21515bcff7.tar.gz |
host sleep: add command to change sleep fail detection timeout
sleeptimeout is a new EC console command to change S3/S0ix sleep fail
detection timeout. Needed for debug only. The command is present only if
CONFIG_POWER_SLEEP_FAILURE_DETECTION is defined
BRANCH=none
BUG=b:187532888
TEST=manual
Signed-off-by: Boris Mittelberg <bmbm@google.com>
Change-Id: I9a2afbb89dbfb4bdaf8666e06cf810e7cace9aad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2904896
Reviewed-by: caveh jalali <caveh@chromium.org>
Diffstat (limited to 'power/host_sleep.c')
-rw-r--r-- | power/host_sleep.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/power/host_sleep.c b/power/host_sleep.c index 909999c7a9..2c62e1fb21 100644 --- a/power/host_sleep.c +++ b/power/host_sleep.c @@ -4,6 +4,7 @@ */ #include "config.h" +#include "console.h" #include "ec_commands.h" #include "hooks.h" #include "host_command.h" @@ -108,6 +109,7 @@ void sleep_notify_transition(int check_state, int hook_id) #ifdef CONFIG_POWER_SLEEP_FAILURE_DETECTION static uint16_t sleep_signal_timeout; +static uint16_t host_sleep_timeout_default = CONFIG_SLEEP_TIMEOUT_MS; static uint32_t sleep_signal_transitions; static void (*sleep_timeout_callback)(void); @@ -164,7 +166,7 @@ void sleep_start_suspend(struct host_sleep_event_context *ctx, /* Use zero internally to indicate no timeout. */ if (timeout == EC_HOST_SLEEP_TIMEOUT_DEFAULT) { - timeout = CONFIG_SLEEP_TIMEOUT_MS; + timeout = host_sleep_timeout_default; } else if (timeout == EC_HOST_SLEEP_TIMEOUT_INFINITE) { sleep_signal_timeout = 0; @@ -195,6 +197,49 @@ void sleep_reset_tracking(void) sleep_timeout_callback = NULL; } +static int command_sleep_fail_timeout(int argc, char **argv) +{ + if (argc < 2) { + /* no arguments - just print the current timeout */ + } else if (!strcasecmp(argv[1], "default")) { + host_sleep_timeout_default = CONFIG_SLEEP_TIMEOUT_MS; + } else if (!strcasecmp(argv[1], "infinite")) { + host_sleep_timeout_default = EC_HOST_SLEEP_TIMEOUT_INFINITE; + } else { + char *e; + int val; + + val = strtoi(argv[1], &e, 10); + if (*e) + return EC_ERROR_PARAM1; + + if (val <= 0 || val >= EC_HOST_SLEEP_TIMEOUT_INFINITE) { + ccprintf("Error: timeout range is 1..%d [msec]\n", + EC_HOST_SLEEP_TIMEOUT_INFINITE - 1); + return EC_ERROR_PARAM1; + } + + host_sleep_timeout_default = val; + } + + if (host_sleep_timeout_default == EC_HOST_SLEEP_TIMEOUT_INFINITE) + ccprintf("Sleep failure detection timeout is disabled\n"); + else + ccprintf("Sleep failure detection timeout is %d [msec]\n", + host_sleep_timeout_default); + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(sleeptimeout, command_sleep_fail_timeout, + "[default | infinite | <msec>]", + "Display or set host sleep failure detection timeout.\n" + "Valid arguments are:\n" + " default\n" + " infinite - disables the timeout\n" + " <msec> - custom length in milliseconds\n" + " <none> - prints the current setting"); + + #else /* !CONFIG_POWER_SLEEP_FAILURE_DETECTION */ /* No action */ |