]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[usb] Move usbio driver to end of USB driver list
authorMichael Brown <mcb30@ipxe.org>
Tue, 13 Oct 2020 14:29:23 +0000 (15:29 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 13 Oct 2020 14:56:38 +0000 (15:56 +0100)
iPXE will often have multiple drivers available for a USB device.  For
example: some USB network devices will support both RNDIS and CDC-ECM,
and any device may be consumed by the fallback "usbio" driver under
UEFI in order to expose an EFI_USB_IO_PROTOCOL instance.

The driver scoring mechanism is used to select a device configuration
based on the availability of drivers for the interfaces exposed in
each configuration.

For the case of RNDIS versus CDC-ECM, this mechanism will always
produce the correct result since RNDIS and CDC-ECM will not exist
within the same configuration and so each configuration will receive a
score based on the relevant driver.

This guarantee does not hold for the "usbio" driver, which will match
against any device.  It is a surprising coincidence that the "usbio"
driver seems to usually end up at the tail end of the USB drivers
list, thereby resulting in the expected behaviour.

Guarantee the expected behaviour by explicitly placing the "usbio"
driver at the end of the USB drivers list.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/usb.h
src/interface/efi/efi_usb.c

index 70d6daf333b80e0e23184ab478252a27fe89c627..f41f4c35574e0f7472028e79242004605b868f80 100644 (file)
@@ -1398,6 +1398,9 @@ struct usb_driver {
 /** Declare a USB driver */
 #define __usb_driver __table_entry ( USB_DRIVERS, 01 )
 
+/** Declare a USB fallback driver */
+#define __usb_fallback_driver __table_entry ( USB_DRIVERS, 02 )
+
 /** USB driver scores */
 enum usb_driver_score {
        /** Fallback driver (has no effect on overall score) */
index 7f761145fb5e40b1610f288f3bd6a3d966b8b3e3..4ddc14910cfbdf078c8697b5d12f554ec1ab3b4b 100644 (file)
@@ -1355,7 +1355,7 @@ static struct usb_device_id efi_usb_ids[] = {
 };
 
 /** USB I/O protocol driver */
-struct usb_driver usbio_driver __usb_driver = {
+struct usb_driver usbio_driver __usb_fallback_driver = {
        .ids = efi_usb_ids,
        .id_count = ( sizeof ( efi_usb_ids ) / sizeof ( efi_usb_ids[0] ) ),
        .class = USB_CLASS_ID ( USB_ANY_ID, USB_ANY_ID, USB_ANY_ID ),