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 <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Nicolas Boichat
2017-05-15 14:44:42 +08:00
committed by chrome-bot
parent 8151b3f7e6
commit 19aace4ec0

View File

@@ -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;
}