Skip to content

Commit 8a15ca0

Browse files
geoffreybennetttiwai
authored andcommitted
ALSA: scarlett2: Add retry on -EPROTO from scarlett2_usb_tx()
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: [email protected] Signed-off-by: Geoffrey D. Bennett <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent bd7814a commit 8a15ca0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sound/usb/mixer_scarlett2.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,6 +2351,8 @@ static int scarlett2_usb(
23512351
struct scarlett2_usb_packet *req, *resp = NULL;
23522352
size_t req_buf_size = struct_size(req, data, req_size);
23532353
size_t resp_buf_size = struct_size(resp, data, resp_size);
2354+
int retries = 0;
2355+
const int max_retries = 5;
23542356
int err;
23552357

23562358
req = kmalloc(req_buf_size, GFP_KERNEL);
@@ -2374,10 +2376,15 @@ static int scarlett2_usb(
23742376
if (req_size)
23752377
memcpy(req->data, req_data, req_size);
23762378

2379+
retry:
23772380
err = scarlett2_usb_tx(dev, private->bInterfaceNumber,
23782381
req, req_buf_size);
23792382

23802383
if (err != req_buf_size) {
2384+
if (err == -EPROTO && ++retries <= max_retries) {
2385+
msleep(5 * (1 << (retries - 1)));
2386+
goto retry;
2387+
}
23812388
usb_audio_err(
23822389
mixer->chip,
23832390
"%s USB request result cmd %x was %d\n",

0 commit comments

Comments
 (0)