On Mon, Feb 01, 2021 at 10:16:37PM +0000, Mikolaj Kucharski wrote:

> On Mon, Feb 01, 2021 at 10:57:43PM +0100, Marcus Glocker wrote:
> > Ok.  Then it was the usbd_device2interface_handle() change.
> > Fixed one device (uaudio), broke the other device (umb) :-|
> > Now lets see if we can find something common to make both
> > work.  Can you please send an lsusb -v of your umb?
> 
> Working umb0 (kernel with revert diff), full lsusb -v output:

Sigh.  ugen(4) wants to cycle through all interfaces at one point,
and with our more strict check on the interface number fail soon.
Seems like in this case leaving the device back in some broken
status.

Since I don't want to break more things by trying to do the right
thing, I would propose that we re-introduce the loose behavior
of usbd_device2interface_handle(), and only execute the linear search
in case ifaceno >= bNumInterfaces.  I hope this keeps both devices
working.

Edd:
Can you please also double check if this still works with your
uaudio(4) device?


Index: dev/usb/usbdi.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/usbdi.c,v
retrieving revision 1.109
diff -u -p -u -p -r1.109 usbdi.c
--- dev/usb/usbdi.c     1 Feb 2021 09:21:51 -0000       1.109
+++ dev/usb/usbdi.c     2 Feb 2021 06:07:41 -0000
@@ -642,6 +642,10 @@ usbd_device2interface_handle(struct usbd
 
        if (dev->cdesc == NULL)
                return (USBD_NOT_CONFIGURED);
+       if (ifaceno < dev->cdesc->bNumInterfaces) {
+               *iface = &dev->ifaces[ifaceno];
+               return (USBD_NORMAL_COMPLETION);
+       }
        /*
         * The correct interface should be at dev->ifaces[ifaceno], but we've
         * seen non-compliant devices in the wild which present non-contiguous

Reply via email to