Skip to content

Commit f406005

Browse files
geoffreybennetttiwai
authored andcommitted
ALSA: usb-audio: Add retry on -EPROTO from usb_set_interface()
During initialisation of Focusrite USB audio interfaces, -EPROTO is sometimes returned from usb_set_interface(), which sometimes prevents the device from working: subsequent usb_set_interface() and uac_clock_source_is_valid() calls fail. This patch adds up to 5 retries in endpoint_set_interface(), with a delay starting at 5ms and doubling each time. 5 retries was chosen to allow for longer than expected waits for the interface to start responding correctly; in testing, a single 5ms delay was sufficient to fix the issue. Closes: geoffreybennett/fcp-support#2 Cc: [email protected] Signed-off-by: Geoffrey D. Bennett <[email protected]> Link: https://patch.msgid.link/Z//[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 494d093 commit f406005

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sound/usb/endpoint.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,8 @@ static int endpoint_set_interface(struct snd_usb_audio *chip,
926926
{
927927
int altset = set ? ep->altsetting : 0;
928928
int err;
929+
int retries = 0;
930+
const int max_retries = 5;
929931

930932
if (ep->iface_ref->altset == altset)
931933
return 0;
@@ -935,8 +937,13 @@ static int endpoint_set_interface(struct snd_usb_audio *chip,
935937

936938
usb_audio_dbg(chip, "Setting usb interface %d:%d for EP 0x%x\n",
937939
ep->iface, altset, ep->ep_num);
940+
retry:
938941
err = usb_set_interface(chip->dev, ep->iface, altset);
939942
if (err < 0) {
943+
if (err == -EPROTO && ++retries <= max_retries) {
944+
msleep(5 * (1 << (retries - 1)));
945+
goto retry;
946+
}
940947
usb_audio_err_ratelimited(
941948
chip, "%d:%d: usb_set_interface failed (%d)\n",
942949
ep->iface, altset, err);

0 commit comments

Comments
 (0)