From: Riku Viitanen Date: Sun, 23 Apr 2023 09:59:34 +0000 (+0000) Subject: term/at_keyboard: Add timeout to fix hang on HP EliteBooks X-Git-Tag: grub-2.12-rc1~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=830456a6e3b6ac92d10f9261177722a308652a1a;p=thirdparty%2Fgrub.git term/at_keyboard: Add timeout to fix hang on HP EliteBooks This fixes the GRUB on Coreboot on HP EliteBooks by implementing a 200 ms timeout. The GRUB used to hang. Fixes: https://ticket.coreboot.org/issues/141 Signed-off-by: Riku Viitanen Reviewed-by: Daniel Kiper --- diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index 597111077..f8a129eb7 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -40,9 +40,19 @@ grub_keyboard_controller_init (void); static void keyboard_controller_wait_until_ready (void) { + unsigned int i = 200; + /* 50 us would be enough but our current time resolution is 1ms. */ grub_millisleep (1); - while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); + + while (!KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) + { + grub_millisleep (1); + + /* Timeout. */ + if (!i--) + break; + } } static grub_uint8_t