From 26601a2a17716ec55ae1e619e5bcfaf460ccf1a2 Mon Sep 17 00:00:00 2001 From: Leonid Bloch Date: Mon, 2 Dec 2019 01:05:02 +0200 Subject: [PATCH] sd-boot: Add a 0.1 second delay before key-probing for showing menu If there is no boot menu timeout, pressing a key during boot should get the boot menu displayed. However, on some systems the keyboard is not initialized right away, which causes the menu to be inaccessible if no timeout is specified. To resolve this, if the error is "not ready" after the initial attempt of detection, wait for 0.1 second and retry. This solves the problem described above on all the tested systems. The reason for just a single retry, and not retrying while "not ready", is that some firmwares continue to return the "not ready" error on every probe attempt if no key is pressed. Signed-off-by: Leonid Bloch --- src/boot/efi/boot.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 849c3c63b6a..20ded3a6302 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -2453,6 +2453,12 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { UINT64 key; err = console_key_read(&key, FALSE); + + if (err == EFI_NOT_READY) { + uefi_call_wrapper(BS->Stall, 1, 100 * 1000); + err = console_key_read(&key, FALSE); + } + if (!EFI_ERROR(err)) { INT16 idx;