From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A92C22425B; Tue, 12 Aug 2025 19:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755025257; cv=none; b=UGs/FLd/N2Fschh+l3pktCRsWOwYhmZSRQnr0w8eEropwKMl/OxQ2NFBwZNc4cb5YvPiFIg/R9L74VRXvc5KMiQ7OcrK+OVfRt+1geEAkewsqsmZMvotCIYBX3LXwqjj9BbXHkwC9g7l3MQV7uLVMxvlkI8sxFBdo9+ZjWW/rcc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755025257; c=relaxed/simple; bh=JRIffAVdCgC7NQvIR+1VsLIh1fpi0nRSU+U3jXCl/tU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gSjb3Gi2m2h29jTzbaXcyCYv6BURMy1GF1T6ywmJ+R6ScXy1YVi4pEPjToXqZgaQuxZbVNKpxCLj58UeiKxb2mNCn7kuzuKTAFKzcXIT7pUFrmt/7K99RVf3Rvz1yN4W5Bg50Hj68cYL+HxX5Vc3huAI/JbjvjGqrmRYn3EXLhs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=14ceKPcN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="14ceKPcN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D21F5C4CEF6; Tue, 12 Aug 2025 19:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755025257; bh=JRIffAVdCgC7NQvIR+1VsLIh1fpi0nRSU+U3jXCl/tU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=14ceKPcN8NP24x9DEYIJQw6ToPNE4OPE645BH04BXq8Fa7yl7WxoBM6+X+UFEYnx6 dn3FUHzQj4eeb2NbQKTgxjsDV1gxwlJHGg06YQEcDkziH+HIF388Pn5gwbPCE4QJju 9XYYG+Z5WYo5NtspBvu0vW9iH0H+kr9VU7Qy28j4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Geoffrey D. Bennett" , Takashi Iwai Subject: [PATCH 6.16 598/627] ALSA: scarlett2: Add retry on -EPROTO from scarlett2_usb_tx() Date: Tue, 12 Aug 2025 19:34:53 +0200 Message-ID: <20250812173454.619446431@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812173419.303046420@linuxfoundation.org> References: <20250812173419.303046420@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Geoffrey D. Bennett commit 8a15ca0ca51399b652b1bbb23b590b220cf03d62 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 f406005e162b ("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: 9e4d5c1be21f ("ALSA: usb-audio: Scarlett Gen 2 mixer interface") Closes: https://github.com/geoffreybennett/linux-fcp/issues/41 Cc: stable@vger.kernel.org Signed-off-by: Geoffrey D. Bennett Link: https://patch.msgid.link/aIdDO6ld50WQwNim@m.b4.vu Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/mixer_scarlett2.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/sound/usb/mixer_scarlett2.c +++ b/sound/usb/mixer_scarlett2.c @@ -2351,6 +2351,8 @@ static int scarlett2_usb( struct scarlett2_usb_packet *req, *resp = NULL; size_t req_buf_size = struct_size(req, data, req_size); size_t resp_buf_size = struct_size(resp, data, resp_size); + int retries = 0; + const int max_retries = 5; int err; req = kmalloc(req_buf_size, GFP_KERNEL); @@ -2374,10 +2376,15 @@ static int scarlett2_usb( if (req_size) memcpy(req->data, req_data, req_size); +retry: err = scarlett2_usb_tx(dev, private->bInterfaceNumber, req, req_buf_size); if (err != req_buf_size) { + if (err == -EPROTO && ++retries <= max_retries) { + msleep(5 * (1 << (retries - 1))); + goto retry; + } usb_audio_err( mixer->chip, "%s USB request result cmd %x was %d\n",