Skip to content

Commit 57c0b84

Browse files
geoffreybennettgregkh
authored andcommitted
ALSA: scarlett2: Add retry on -EPROTO from scarlett2_usb_tx()
commit 8a15ca0 upstream. During communication with Focusrite Scarlett Gen 2/3/4 USB audio interfaces, -EPROTO is sometimes returned from scarlett2_usb_tx(), snd_usb_ctl_msg() which can cause initialisation and control operations to fail intermittently. This patch adds up to 5 retries in scarlett2_usb(), with a delay starting at 5ms and doubling each time. This follows the same approach as the fix for usb_set_interface() in endpoint.c (commit f406005 ("ALSA: usb-audio: Add retry on -EPROTO from usb_set_interface()")), which resolved similar -EPROTO issues during device initialisation, and is the same approach as in fcp.c:fcp_usb(). Fixes: 9e4d5c1 ("ALSA: usb-audio: Scarlett Gen 2 mixer interface") Closes: geoffreybennett/linux-fcp#41 Cc: stable@vger.kernel.org Signed-off-by: Geoffrey D. Bennett <g@b4.vu> Link: https://patch.msgid.link/aIdDO6ld50WQwNim@m.b4.vu Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d34479b commit 57c0b84

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

sound/usb/mixer_scarlett2.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,8 @@ static int scarlett2_usb(
12791279
struct scarlett2_usb_packet *req, *resp = NULL;
12801280
size_t req_buf_size = struct_size(req, data, req_size);
12811281
size_t resp_buf_size = struct_size(resp, data, resp_size);
1282+
int retries = 0;
1283+
const int max_retries = 5;
12821284
int err;
12831285

12841286
req = kmalloc(req_buf_size, GFP_KERNEL);
@@ -1302,10 +1304,15 @@ static int scarlett2_usb(
13021304
if (req_size)
13031305
memcpy(req->data, req_data, req_size);
13041306

1307+
retry:
13051308
err = scarlett2_usb_tx(dev, private->bInterfaceNumber,
13061309
req, req_buf_size);
13071310

13081311
if (err != req_buf_size) {
1312+
if (err == -EPROTO && ++retries <= max_retries) {
1313+
msleep(5 * (1 << (retries - 1)));
1314+
goto retry;
1315+
}
13091316
usb_audio_err(
13101317
mixer->chip,
13111318
"%s USB request result cmd %x was %d\n",

0 commit comments

Comments
 (0)