kernel 5.4.11: problems with usb sound cards
Hello, list, I hope this is the right place to post this problem.
Changes introduced in 5.4.11 (seemingly, in drivers/usb/core/config.c) cause problems with at least some models of USB sound cards.
I have a Sound Devices USBPre2, a high quality sound card that until 5.4.10 always worked perfectly out of the box as a standard USB audio device.
Beginning with 5.4.11 and up to 5.5.0, when the sound card is connected, dmesg shows:
[ 1310.743135] usb 3-10.3: new high-speed USB device number 6 using xhci_hcd [ 1310.755472] usb 3-10.3: config 1 interface 2 altsetting 1 has a duplicate endpoint with address 0x85, skipping [ 1310.755474] usb 3-10.3: config 1 interface 2 altsetting 2 has a duplicate endpoint with address 0x85, skipping [ 1310.755852] usb 3-10.3: New USB device found, idVendor=0926, idProduct=0202, bcdDevice= 1.00 [ 1310.755853] usb 3-10.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 1310.755854] usb 3-10.3: Product: USBPre2 [ 1310.755855] usb 3-10.3: Manufacturer: Sound Devices [ 1310.755855] usb 3-10.3: SerialNumber: HB1116132005 [ 1310.756803] usb 3-10.3: 1:3 : UAC_AS_GENERAL descriptor not found [ 1310.757550] hid-generic 0003:0926:0202.0005: hiddev96: USB HID v1.01 Device [Sound Devices USBPre2] on usb-0000:00:14.0-10.3/input3 [ 1310.773161] systemd-udevd[3856]: controlC0: Process '/usr/sbin/alsactl
restore 0' failed with exit code 99.
No capture device is created under /dev/snd, and the card works only as a playback device.
ls -l /dev/snd
total 0
drwxr-xr-x 2 root root 60 feb 1 10:36 by-id drwxr-xr-x 2 root root 60 feb 1 10:36 by-path crw-rw----+ 1 root audio 116, 0 feb 1 10:36 controlC0 crw-rw----+ 1 root audio 116, 16 feb 1 10:36 pcmC0D0p crw-rw----+ 1 root audio 116, 1 feb 1 10:14 seq crw-rw----+ 1 root audio 116, 33 feb 1 10:14 timer
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: USBPre2 [USBPre2], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
arecord -l
**** List of CAPTURE Hardware Devices ****
--
Quoted 30 lines · edes
Hello, list, I hope this is the right place to post this problem.
Changes introduced in 5.4.11 (seemingly, in
drivers/usb/core/config.c) cause problems with at least some models of USB sound cards.I have a Sound Devices USBPre2, a high quality sound card that until 5.4.10 always worked perfectly out of the box as a standard USB audio device.
Beginning with 5.4.11 and up to 5.5.0, when the sound card is connected, dmesg shows:
[ 1310.743135] usb 3-10.3: new high-speed USB device number 6 using xhci_hcd [ 1310.755472] usb 3-10.3: config 1 interface 2 altsetting 1 has a duplicate endpoint with address 0x85, skipping [ 1310.755474] usb 3-10.3: config 1 interface 2 altsetting 2 has a duplicate endpoint with address 0x85, skipping [ 1310.755852] usb 3-10.3: New USB device found, idVendor=0926, idProduct=0202, bcdDevice= 1.00 [ 1310.755853] usb 3-10.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 1310.755854] usb 3-10.3: Product: USBPre2 [ 1310.755855] usb 3-10.3: Manufacturer: Sound Devices [ 1310.755855] usb 3-10.3: SerialNumber: HB1116132005 [ 1310.756803] usb 3-10.3: 1:3 : UAC_AS_GENERAL descriptor not found [ 1310.757550] hid-generic 0003:0926:0202.0005: hiddev96: USB HID v1.01 Device [Sound Devices USBPre2] on usb-0000:00:14.0-10.3/input3 [ 1310.773161] systemd-udevd[3856]: controlC0: Process '/usr/sbin/alsactl
Quoted 4 lines
restore 0' failed with exit code 99.
No capture device is created under
/dev/snd, and the card works only as a playback device.
Can you please post the output of "lsusb -v" for this device on 5.4.10 and 5.4.11, respectively?
Johan
Quoted 3 lines
Can you please post the output of "lsusb -v" for this device on 5.4.10 and 5.4.11, respectively?
Hello, thanks for your prompt response. Please see attached (I hope that is OK) the output of lsusb -v on both 5.4.10 and 5.4.11.
The device in question is the Sound Devices USBPre2, Bus 003 Device 004:
ID 0926:0202, beginning at line 808.
--
[ +CC: Takashi ]
Quoted 10 lines · edes
Quoted 3 lines
Can you please post the output of "lsusb -v" for this device on 5.4.10 and 5.4.11, respectively?
Hello, thanks for your prompt response. Please see attached (I hope that is OK) the output of lsusb -v on both 5.4.10 and 5.4.11.
The device in question is the Sound Devices USBPre2, Bus 003 Device 004:
ID 0926:0202, beginning at line 808.
Ok, so the device has a broken altsetting 3 for interface 1, where endpoint 0x85 is declared as an isochronous endpoint, despite being used by interface 2 as an audio endpoint:
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 3
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0126 1x 294 bytes
bInterval 1
...
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 4
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 26
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 6 Discrete
tSamFreq[ 0] 8000
tSamFreq[ 1] 16000
tSamFreq[ 2] 24000
tSamFreq[ 3] 32000
tSamFreq[ 4] 44100
tSamFreq[ 5] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0126 1x 294 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 2 Decoded PCM samples
wLockDelay 0x0000
Since commit 3e4f8e21c4f2 ("USB: core: fix check for duplicate endpoints") USB core ignores any duplicate endpoints, but in this case we really want to ignore the first instance.
Can you try the below patch, which adds a blacklist quirk for the broken endpoint descriptor?
Note that the broken altsetting probably should be using endpoint 0x81 just like the other altsettings for that interface, but hopefully you don't really use this setting so that simply ignoring the endpoint will make the device work again.
Interestingly enough, in your lsusb output from 5.4.11, the device reports a second configuration in which this broken altsetting doesn't exist. Switching to that config should also make the problem go away.
Johan
From c8980be317939eb7fae73960b0c6fa641c45bd7d Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Sun, 2 Feb 2020 10:39:05 +0100
Subject: [PATCH] USB: core: add endpoint blacklist quirk
Add a new device quirk that can be used to blacklist endpoints.
Since commit 3e4f8e21c4f2 ("USB: core: fix check for duplicate endpoints") USB core ignores any duplicate endpoints found during descriptor parsing.
In order to handle devices where the first interfaces with duplicate endpoints are the ones that should have their endpoints ignored, we need to add a blacklist.
--- drivers/usb/core/config.c | 11 +++++++++++ drivers/usb/core/quirks.c | 32 ++++++++++++++++++++++++++++++++ drivers/usb/core/usb.h | 3 +++ include/linux/usb/quirks.h | 3 +++ 4 files changed, 49 insertions(+)
drivers/usb/core/config.c +11 -0
@@ -256,6 +256,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, struct usb_host_interface *ifp, int num_ep, unsigned char *buffer, int size) { + struct usb_device *udev = to_usb_device(ddev);unsigned char *buffer0 = buffer;struct usb_endpoint_descriptor *d;struct usb_host_endpoint *endpoint;
@@ -297,6 +298,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, goto skip_to_next_endpoint_or_interface_descriptor; } +/* Ignore blacklisted endpoints */ +if (udev->quirks &USB_QUIRK_ENDPOINT_BLACKLIST ) { +if (usb_endpoint_is_blacklisted (udev, ifp, d)) { +dev_warn (ddev,"config %d interface %d altsetting %d has a blacklisted endpoint with address 0x%X, skipping\n" , + cfgno, inum, asnum, + d->bEndpointAddress); + goto skip_to_next_endpoint_or_interface_descriptor; + } + } + endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; ++ifp->desc.bNumEndpoints;
drivers/usb/core/quirks.c +32 -0
@@ -354,6 +354,9 @@ static const struct usb_device_id usb_quirk_list[] = { { USB_DEVICE(0x0904, 0x6103), .driver_info = USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + /* Sound Devices USBPre2 */ + { USB_DEVICE(0x0926, 0x0202), .driver_info = USB_QUIRK_ENDPOINT_BLACKLIST }, + /* Keytouch QWERTY Panel keyboard */ { USB_DEVICE(0x0926, 0x3333), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
@@ -472,6 +475,35 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = { { }/* terminating entry must be last */ }; +/* +* Entries for blacklisted endpoints. +* +* Matched for devices with USB_QUIRK_ENDPOINT_BLACKLIST. +*/ +static const struct usb_device_id usb_endpoint_blacklist_quirk_list[] = { + {USB_DEVICE_INTERFACE_NUMBER (0x0926 ,0x0202 ,1 ), .driver_info =0x85 }, + { }, +}; + +bool usb_endpoint_is_blacklisted (struct usb_device *udev, +struct usb_host_interface *intf, +struct usb_endpoint_descriptor *epd) +{ +const struct usb_device_id *id; +unsigned int address; + +for (id = usb_endpoint_blacklist_quirk_list; id->match_flags; ++id) { +if (usb_match_one_id_intf (udev, intf, id)) { + address = id->driver_info; + +if (address == epd->bEndpointAddress) +return true; + } + } + +return false; +} +static bool usb_match_any_interface (struct usb_device *udev,const struct usb_device_id *id) {
drivers/usb/core/usb.h +3 -0
@@ -37,6 +37,9 @@ extern void usb_authorize_interface(struct usb_interface *);extern void usb_detect_quirks (struct usb_device *udev);extern void usb_detect_interface_quirks (struct usb_device *udev);extern void usb_release_quirk_list (void ); +extern bool usb_endpoint_is_blacklisted (struct usb_device *udev, +struct usb_host_interface *intf, +struct usb_endpoint_descriptor *epd);extern int usb_remove_device (struct usb_device *udev); extern int usb_get_device_descriptor(struct usb_device *dev,
include/linux/usb/quirks.h +3 -0
@@ -69,4 +69,7 @@/* Hub needs extra delay after resetting its port. */ #define USB_QUIRK_HUB_SLOW_RESET BIT(14) +/* device has blacklisted endpoints */ +#define USB_QUIRK_ENDPOINT_BLACKLIST BIT(15) +#endif /* __LINUX_USB_QUIRKS_H */
Signature · 1 line
2.24.1
Quoted 6 lines · Johan Hovold
Since commit
3e4f8e21c4f2("USB: core: fix check for duplicate endpoints") USB core ignores any duplicate endpoints, but in this case we really want to ignore the first instance.Can you try the below patch, which adds a blacklist quirk for the broken endpoint descriptor?
I realised I forgot the test to match on the device descriptor when applying the blacklist. It doesn't matter currently since I only enable the quirk for your device, but if you haven't tested the patch already, would you mind testing the below patch instead?
Johan
From c01e64edf751b2079c30d57f57c9a2d20d00b80a Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Sun, 2 Feb 2020 10:39:05 +0100
Subject: [PATCH] USB: core: add endpoint blacklist quirk
Add a new device quirk that can be used to blacklist endpoints.
Since commit 3e4f8e21c4f2 ("USB: core: fix check for duplicate endpoints") USB core ignores any duplicate endpoints found during descriptor parsing.
In order to handle devices where the first interfaces with duplicate endpoints are the ones that should have their endpoints ignored, we need to add a blacklist.
--- drivers/usb/core/config.c | 11 +++++++++++ drivers/usb/core/quirks.c | 35 +++++++++++++++++++++++++++++++++++ drivers/usb/core/usb.h | 3 +++ include/linux/usb/quirks.h | 3 +++ 4 files changed, 52 insertions(+)
drivers/usb/core/config.c +11 -0
@@ -256,6 +256,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, struct usb_host_interface *ifp, int num_ep, unsigned char *buffer, int size) { + struct usb_device *udev = to_usb_device(ddev);unsigned char *buffer0 = buffer;struct usb_endpoint_descriptor *d;struct usb_host_endpoint *endpoint;
@@ -297,6 +298,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, goto skip_to_next_endpoint_or_interface_descriptor; } +/* Ignore blacklisted endpoints */ +if (udev->quirks &USB_QUIRK_ENDPOINT_BLACKLIST ) { +if (usb_endpoint_is_blacklisted (udev, ifp, d)) { +dev_warn (ddev,"config %d interface %d altsetting %d has a blacklisted endpoint with address 0x%X, skipping\n" , + cfgno, inum, asnum, + d->bEndpointAddress); + goto skip_to_next_endpoint_or_interface_descriptor; + } + } + endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints]; ++ifp->desc.bNumEndpoints;
drivers/usb/core/quirks.c +35 -0
@@ -354,6 +354,9 @@ static const struct usb_device_id usb_quirk_list[] = { { USB_DEVICE(0x0904, 0x6103), .driver_info = USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + /* Sound Devices USBPre2 */ + { USB_DEVICE(0x0926, 0x0202), .driver_info = USB_QUIRK_ENDPOINT_BLACKLIST }, + /* Keytouch QWERTY Panel keyboard */ { USB_DEVICE(0x0926, 0x3333), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
@@ -472,6 +475,38 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = { { }/* terminating entry must be last */ }; +/* +* Entries for blacklisted endpoints. +* +* Matched for devices with USB_QUIRK_ENDPOINT_BLACKLIST. +*/ +static const struct usb_device_id usb_endpoint_blacklist_quirk_list[] = { + {USB_DEVICE_INTERFACE_NUMBER (0x0926 ,0x0202 ,1 ), .driver_info =0x85 }, + { }, +}; + +bool usb_endpoint_is_blacklisted (struct usb_device *udev, +struct usb_host_interface *intf, +struct usb_endpoint_descriptor *epd) +{ +const struct usb_device_id *id; +unsigned int address; + +for (id = usb_endpoint_blacklist_quirk_list; id->match_flags; ++id) { +if (!usb_match_device (udev, id)) +continue ; + +if (!usb_match_one_id_intf (udev, intf, id)) +continue ; + + address = id->driver_info; +if (address == epd->bEndpointAddress) +return true; + } + +return false; +} +static bool usb_match_any_interface (struct usb_device *udev,const struct usb_device_id *id) {
drivers/usb/core/usb.h +3 -0
@@ -37,6 +37,9 @@ extern void usb_authorize_interface(struct usb_interface *);extern void usb_detect_quirks (struct usb_device *udev);extern void usb_detect_interface_quirks (struct usb_device *udev);extern void usb_release_quirk_list (void ); +extern bool usb_endpoint_is_blacklisted (struct usb_device *udev, +struct usb_host_interface *intf, +struct usb_endpoint_descriptor *epd);extern int usb_remove_device (struct usb_device *udev); extern int usb_get_device_descriptor(struct usb_device *dev,
include/linux/usb/quirks.h +3 -0
@@ -69,4 +69,7 @@/* Hub needs extra delay after resetting its port. */ #define USB_QUIRK_HUB_SLOW_RESET BIT(14) +/* device has blacklisted endpoints */ +#define USB_QUIRK_ENDPOINT_BLACKLIST BIT(15) +#endif /* __LINUX_USB_QUIRKS_H */
Signature · 1 line
2.24.1
Quoted 4 lines · el 2020-02-02 a las 14:41 Johan Hovold escribió:
I realised I forgot the test to match on the device descriptor when applying the blacklist. It doesn't matter currently since I only enable the quirk for your device, but if you haven't tested the patch already, would you mind testing the below patch instead?
Hi, Johan, thank you for looking into this. I tested your patch, and it works! (5.4.11 and 5.5.0).
I haven't performed extensive tests, but the card is again recognized as both playback and capture device. Thank you!
Is this and acceptable solution and will this patch be integrated into the kernel?
Quoted 3 lines · you
Ok, so the device has a broken altsetting 3 for interface 1, where endpoint
0x85is declared as an isochronous endpoint, despite being used by interface 2 as an audio endpoint:
[...]
Quoted 2 lines
Note that the broken altsetting probably should be using endpoint
0x81just like the other altsettings for that interface,
I can't say I understand exactly what you're saying, but do you think it could be worth contacting the company and see if they are willing to fix this with a new firmware?
Anyway, it's working now, thank you again.
--
Quoted 9 lines · edes
Quoted 4 lines · el 2020-02-02 a las 14:41 Johan Hovold escribió:
I realised I forgot the test to match on the device descriptor when applying the blacklist. It doesn't matter currently since I only enable the quirk for your device, but if you haven't tested the patch already, would you mind testing the below patch instead?
Quoted 8 lines
Hi, Johan, thank you for looking into this. I tested your patch, and it works! (5.4.11 and 5.5.0).
I haven't performed extensive tests, but the card is again recognized as both playback and capture device. Thank you!
Is this and acceptable solution and will this patch be integrated into the kernel?
I don't mind where to blacklist; we may add a similar quirk in USB-audio driver side, too.
thanks,
Takashi
Quoted 20 lines
Quoted 3 lines · you
Ok, so the device has a broken altsetting 3 for interface 1, where endpoint
0x85is declared as an isochronous endpoint, despite being used by interface 2 as an audio endpoint:[...]
Quoted 2 lines
Note that the broken altsetting probably should be using endpoint
0x81just like the other altsettings for that interface,I can't say I understand exactly what you're saying, but do you think it could be worth contacting the company and see if they are willing to fix this with a new firmware?
Anyway, it's working now, thank you again.
--
Quoted 14 lines · Takashi Iwai
Quoted 12 lines · edes
Quoted 4 lines · el 2020-02-02 a las 14:41 Johan Hovold escribió:
I realised I forgot the test to match on the device descriptor when applying the blacklist. It doesn't matter currently since I only enable the quirk for your device, but if you haven't tested the patch already, would you mind testing the below patch instead?
Hi, Johan, thank you for looking into this. I tested your patch, and it works! (5.4.11 and 5.5.0).
Quoted 8 lines
Quoted 5 lines
I haven't performed extensive tests, but the card is again recognized as both playback and capture device. Thank you!
Is this and acceptable solution and will this patch be integrated into the kernel?
I don't mind where to blacklist; we may add a similar quirk in USB-audio driver side, too.
I'm afraid it needs to be done in core since this info is needed while parsing the descriptors.
Johan
Quoted 19 lines · Johan Hovold
Quoted 17 lines · Takashi Iwai
Quoted 15 lines · edes
Quoted 4 lines · el 2020-02-02 a las 14:41 Johan Hovold escribió:
I realised I forgot the test to match on the device descriptor when applying the blacklist. It doesn't matter currently since I only enable the quirk for your device, but if you haven't tested the patch already, would you mind testing the below patch instead?
Hi, Johan, thank you for looking into this. I tested your patch, and it works! (5.4.11 and 5.5.0).
I haven't performed extensive tests, but the card is again recognized as both playback and capture device. Thank you!
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Is this and acceptable solution and will this patch be integrated into the kernel?
I don't mind where to blacklist; we may add a similar quirk in USB-audio driver side, too.
I'm afraid it needs to be done in core since this info is needed while parsing the descriptors.
OK, then let's go with your patch if there is no objection.
thanks,
Takashi
Quoted 8 lines · edes
Quoted 4 lines · el 2020-02-02 a las 14:41 Johan Hovold escribió:
I realised I forgot the test to match on the device descriptor when applying the blacklist. It doesn't matter currently since I only enable the quirk for your device, but if you haven't tested the patch already, would you mind testing the below patch instead?
Quoted 5 lines
Hi, Johan, thank you for looking into this. I tested your patch, and it works! (5.4.11 and 5.5.0).
I haven't performed extensive tests, but the card is again recognized as both playback and capture device. Thank you!
Perfect, thanks for testing.
Do you have a full name I can use to give you credit in the commit message for reporting and testing?
Quoted 2 lines
Is this and acceptable solution and will this patch be integrated into the kernel?
Yes, I think so. We've already had one related report so far, and the blacklist mechanism should be generic enough to handle any further devices like this.
Either way, we'll have this fixed in stable in one way or another in a couple of weeks.
Quoted 5 lines
Quoted 3 lines · you
Ok, so the device has a broken altsetting 3 for interface 1, where endpoint
0x85is declared as an isochronous endpoint, despite being used by interface 2 as an audio endpoint:
Quoted 7 lines
[...]
Quoted 2 lines
Note that the broken altsetting probably should be using endpoint
0x81just like the other altsettings for that interface,I can't say I understand exactly what you're saying, but do you think it could be worth contacting the company and see if they are willing to fix this with a new firmware?
Yes, I guess that wouldn't hurt.
The device used to work mostly by chance as two interfaces aren't allowed to claim the same endpoint. Fortunately, this would only ever be an issue in one particular configuration of the device (when altsetting 3 of interface 1 was selected) and that may be one that was never used on Linux.
Takashi may know more about how/if that third altsetting could ever end up being set.
Johan