From: Michael Brown Date: Tue, 29 Sep 2020 20:13:10 +0000 (+0100) Subject: [efi] Disconnect controllers before uninstalling EFI_USB_IO_PROTOCOL X-Git-Tag: v1.21.1~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8344803c934c71c7eebb6b706d73a8c00d57b713;p=thirdparty%2Fipxe.git [efi] Disconnect controllers before uninstalling EFI_USB_IO_PROTOCOL The call to UninstallMultipleProtocolInterfaces() will implicitly disconnect any relevant controllers, and there is no specified requirement to explicitly call DisconnectController() prior to callling UninstallMultipleProtocolInterfaces(). However, some UEFI implementations (observed with the USB keyboard driver on a Microsoft Surface Go) will fail to implicitly disconnect the controller and will consequently fail to uninstall the protocols. The net effect is that unplugging and replugging a USB keyboard may leave the keyboard in a non-functional state. Work around these broken UEFI implementations by including an unnecessary call to DisconnectController() before the call to UninstallMultipleProtocolInterfaces(). Signed-off-by: Michael Brown --- diff --git a/src/interface/efi/efi_usb.c b/src/interface/efi/efi_usb.c index f280a681b..bac2d053a 100644 --- a/src/interface/efi/efi_usb.c +++ b/src/interface/efi/efi_usb.c @@ -1193,6 +1193,12 @@ static void efi_usb_uninstall ( struct efi_usb_interface *usbintf ) { DBGC ( usbdev, "USBDEV %s uninstalling %s\n", usbintf->name, efi_handle_name ( usbintf->handle ) ); + /* Disconnect controllers. This should not be necessary, but + * seems to be required on some platforms to avoid failures + * when uninstalling protocols. + */ + bs->DisconnectController ( usbintf->handle, NULL, NULL ); + /* Uninstall protocols */ bs->UninstallMultipleProtocolInterfaces ( usbintf->handle,