From 830456a6e3b6ac92d10f9261177722a308652a1a Mon Sep 17 00:00:00 2001 From: Riku Viitanen Date: Sun, 23 Apr 2023 09:59:34 +0000 Subject: [PATCH] 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 --- grub-core/term/at_keyboard.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 -- 2.47.3