[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 <mcb30@ipxe.org>
pull/158/head
Michael Brown 2020-10-13 15:29:23 +01:00
parent e30c26d01c
commit 88288407af
2 changed files with 4 additions and 1 deletions

View 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) */

View 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 ),