]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[efi] Disconnect existing drivers on a per-protocol basis
authorMichael Brown <mcb30@ipxe.org>
Sat, 29 Mar 2025 14:57:16 +0000 (14:57 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sat, 29 Mar 2025 20:26:06 +0000 (20:26 +0000)
commit4bcaa3d380d2110445ac6501bf382d81a2ea49d0
tree4ada90f4870a6491095e1748eec40ebf72931a2b
parent7737fec5c63077aa8407f559dea0e3666d9abf70
[efi] Disconnect existing drivers on a per-protocol basis

UEFI does not provide a direct method to disconnect the existing
driver of a specific protocol from a handle.  We currently use
DisconnectController() to remove all drivers from a handle that we
want to drive ourselves, and then rely on recursion in the call to
ConnectController() to reconnect any drivers that did not need to be
disconnected in the first place.

Experience shows that OEMs tend not to ever test the disconnection
code paths in their UEFI drivers, and it is common to find drivers
that refuse to disconnect, fail to close opened handles, fail to
function correctly after reconnection, or lock up the entire system.

Implement a more selective form of disconnection, in which we use
OpenProtocolInformation() to identify the driver associated with a
specific protocol, and then disconnect only that driver.

Perform disconnections in reverse order of attachment priority, since
this is the order likely to minimise the number of cascaded implicit
disconnections.

This allows our MNP driver to avoid performing any disconnections at
all, since it does not require exclusive access to the MNP protocol.
It also avoids performing unnecessary disconnections and reconnections
of unrelated drivers such as the "UEFI WiFi Connection Manager" that
attaches to wireless network interfaces in order to manage wireless
network associations.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/efi/snp.c
src/drivers/net/efi/snponly.c
src/drivers/usb/usbio.c
src/include/ipxe/efi/efi_driver.h
src/interface/efi/efi_driver.c
src/interface/efi/efi_pci.c