From 88288407af0e24bebdc7a6cebe93a82285bbc4a1 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 13 Oct 2020 15:29:23 +0100 Subject: [PATCH] [usb] Move usbio driver to end of USB driver list 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 --- src/include/ipxe/usb.h | 3 +++ src/interface/efi/efi_usb.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/include/ipxe/usb.h b/src/include/ipxe/usb.h index 70d6daf33..f41f4c355 100644 --- a/src/include/ipxe/usb.h +++ b/src/include/ipxe/usb.h @@ -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) */ diff --git a/src/interface/efi/efi_usb.c b/src/interface/efi/efi_usb.c index 7f761145f..4ddc14910 100644 --- a/src/interface/efi/efi_usb.c +++ b/src/interface/efi/efi_usb.c @@ -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 ),