diff options
author | Furquan Shaikh <furquan@chromium.org> | 2017-09-11 14:07:33 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-12 16:17:08 -0700 |
commit | 1bece4ee08aa8505e9613e614fc75d254ad5cd40 (patch) | |
tree | 75813235b36991653228489a5b07297c01b21364 /common/port80.c | |
parent | 5ec58b35f1d7ee8284231bd4dc3d96b3d517b061 (diff) | |
download | chrome-ec-1bece4ee08aa8505e9613e614fc75d254ad5cd40.tar.gz |
port80: Disable default print of port80 messages in interrupt context
1. Add a new config option CONFIG_PORT80_PRINT_IN_INT which is
disabled by default to disable printing of port80 messages in
interrupt context.
2. If CONFIG_BRINGUP is defined, redefine CONFIG_PORT80_PRINT_IN_INT
to enable printing of port80 messages in interrupt context for boards
that are in bringup phase.
3. If print_in_int is disabled, add a deferred call to dump port80
buffer to EC console 4 seconds after the last port80 message is
received.
BUG=b:64196191
BRANCH=None
TEST=Verified following:
1. make -j buildall
2. Port80 messages are not printed by default on Soraka
3. Port80 buffer is dumped 4 seconds after last port80 message, if
BIOS is stuck for 4 seconds, in recovery mode and when reboot from AP
console.
4. Boot time on soraka went down from ~1.59seconds to ~1.45 seconds in
EC reboot case (savings of ~140ms).
Change-Id: I9aee0987765f905b4ac49d04ffc54d71ee3a04f9
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/661880
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'common/port80.c')
-rw-r--r-- | common/port80.c | 90 |
1 files changed, 60 insertions, 30 deletions
diff --git a/common/port80.c b/common/port80.c index a3de63bc79..b82a4d4b5b 100644 --- a/common/port80.c +++ b/common/port80.c @@ -23,16 +23,41 @@ static uint16_t __bss_slow history[HISTORY_LEN]; static int __bss_slow writes; /* Number of port 80 writes so far */ static int last_boot; /* Last code from previous boot */ static int __bss_slow scroll; -static int print_in_int = 1; + +#ifdef CONFIG_BRINGUP +#undef CONFIG_PORT80_PRINT_IN_INT +#define CONFIG_PORT80_PRINT_IN_INT 1 +#endif + +static int print_in_int = CONFIG_PORT80_PRINT_IN_INT; + +static void port80_dump_buffer(void); +DECLARE_DEFERRED(port80_dump_buffer); void port_80_write(int data) { /* - * Note that this currently prints from inside the LPC interrupt - * itself. If you're dropping events, turn print_in_int off. + * By default print_in_int is disabled if: + * 1. CONFIG_BRINGUP is not defined + * 2. CONFIG_PRINT_IN_INT is set to disable by default + * + * This is done to prevent printing in interrupt context. Boards can + * enable this by either defining CONFIG_BRINGUP or enabling + * CONFIG_PRINT_IN_INT in board configs. + * + * If at runtime, print_in_int is disabled, then this function will + * schedule a deferred call 4 seconds after the last port80 write to + * dump the current port80 buffer to EC console. This is to allow + * developers to help debug BIOS progress by tracing port80 messages. + * + * P.S.: Deferred call is not scheduled for special event codes (data >= + * 0x100). This is because only 8-bit port80 messages are assumed to be + * coming from the host. */ if (print_in_int) CPRINTF("%c[%T Port 80: 0x%02x]", scroll ? '\n' : '\r', data); + else if (data < 0x100) + hook_call_deferred(&port80_dump_buffer_data, 4 * SECOND); /* Save current port80 code if system is resetting */ if (data == PORT_80_EVENT_RESET && writes) { @@ -47,36 +72,11 @@ void port_80_write(int data) writes++; } -/*****************************************************************************/ -/* Console commands */ - -static int command_port80(int argc, char **argv) +static void port80_dump_buffer(void) { - int head, tail; int printed = 0; int i; - - /* - * 'port80 scroll' toggles whether port 80 output begins with a newline - * (scrolling) or CR (non-scrolling). - */ - if (argc > 1) { - if (!strcasecmp(argv[1], "scroll")) { - scroll = !scroll; - ccprintf("scroll %sabled\n", scroll ? "en" : "dis"); - return EC_SUCCESS; - } else if (!strcasecmp(argv[1], "intprint")) { - print_in_int = !print_in_int; - ccprintf("printing in interrupt %sabled\n", - print_in_int ? "en" : "dis"); - return EC_SUCCESS; - } else if (!strcasecmp(argv[1], "flush")) { - writes = 0; - return EC_SUCCESS; - } else { - return EC_ERROR_PARAM1; - } - } + int head, tail; /* * Print the port 80 writes so far, clipped to the length of our @@ -113,6 +113,36 @@ static int command_port80(int argc, char **argv) } } ccputs(" <--new\n"); +} + +/*****************************************************************************/ +/* Console commands */ + +static int command_port80(int argc, char **argv) +{ + /* + * 'port80 scroll' toggles whether port 80 output begins with a newline + * (scrolling) or CR (non-scrolling). + */ + if (argc > 1) { + if (!strcasecmp(argv[1], "scroll")) { + scroll = !scroll; + ccprintf("scroll %sabled\n", scroll ? "en" : "dis"); + return EC_SUCCESS; + } else if (!strcasecmp(argv[1], "intprint")) { + print_in_int = !print_in_int; + ccprintf("printing in interrupt %sabled\n", + print_in_int ? "en" : "dis"); + return EC_SUCCESS; + } else if (!strcasecmp(argv[1], "flush")) { + writes = 0; + return EC_SUCCESS; + } else { + return EC_ERROR_PARAM1; + } + } + + port80_dump_buffer(); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(port80, command_port80, |