From 19aace4ec0cbf09debd3acde6848287ba6d524cd Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 15 May 2017 14:44:42 +0800 Subject: [PATCH] host_command: Throttle printing of "+" for repeated commands When AP boots and FW screen is shown (e.g. in developer mode), AP FW is querying MKBP status in a loop, leading to a lot of "+" being printed in the EC console. To avoid this issue, let's print "(++)" after a command is received 5 times in a row. BRANCH=none BUG=b:37925684 TEST=Set GBB flags to 0x4a38, reasonable number of "+" is printed on EC console on boot, which firmware screen is being shown. Change-Id: I8368c558b97e7a2513b979322bd4bba442626b27 Reviewed-on: https://chromium-review.googlesource.com/505948 Commit-Ready: Nicolas Boichat Tested-by: Nicolas Boichat Reviewed-by: Randall Spangler --- common/host_command.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/host_command.c b/common/host_command.c index 33eb813bda..e82887738e 100644 --- a/common/host_command.c +++ b/common/host_command.c @@ -26,6 +26,9 @@ /* Maximum delay to skip printing repeated host command debug output */ #define HCDEBUG_MAX_REPEAT_DELAY (50 * MSEC) +/* Stop printing repeated host commands "+" after this count */ +#define HCDEBUG_MAX_REPEAT_COUNT 5 + static struct host_cmd_handler_args *pending_args; /* Verify Boot Mode */ @@ -564,6 +567,7 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_CMD_VERSIONS, static void host_command_debug_request(struct host_cmd_handler_args *args) { static int hc_prev_cmd; + static int hc_prev_count; static uint64_t hc_prev_time; /* @@ -575,10 +579,15 @@ static void host_command_debug_request(struct host_cmd_handler_args *args) uint64_t t = get_time().val; if (args->command == hc_prev_cmd && t - hc_prev_time < HCDEBUG_MAX_REPEAT_DELAY) { + hc_prev_count++; hc_prev_time = t; - CPUTS("+"); + if (hc_prev_count < HCDEBUG_MAX_REPEAT_COUNT) + CPUTS("+"); + else if (hc_prev_count == HCDEBUG_MAX_REPEAT_COUNT) + CPUTS("(++)"); return; } + hc_prev_count = 1; hc_prev_time = t; hc_prev_cmd = args->command; }