Skip to contentSkip to conversation

ALSA: usb-audio: Evaluate packsize caps at the right place

PATCH Superseded [email protected] 2 participants 2 messages Aug 9 – Aug 10 Stable branch

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: usb-audio: Evaluate packsize caps at the right place

From: Takashi Iwai <[email protected]>

[ Upstream commit 52521e8398839105ef8eb22b3f0993f9b0d11a57 ]

We introduced the upper bound checks of the packet sizes by the ep->maxframesize for avoiding the URB submission errors. However, the check was applied at an incorrect place in the function snd_usb_endpoint_set_params() where ep->maxframesize isn't defined yet; the value is defined at a bit later position. So this ended up with a failure at the first run while the second run works.

For fixing it, move the check at the correct place, right after the calculation of ep->maxframesize in the same function.

Fixes 7fe8dec3f628 ("ALSA: usb-audio: Cap the packet size pre-calculations")
[Pzqqt: Backport to 5.10]
---
 sound/usb/endpoint.c | 3 ---
 sound/usb/pcm.c      | 7 +++++++
 2 files changed, 7 insertions(+), 3 deletions(-)
sound/usb/endpoint.c +0 -3
index 8e2b90cb5b95..21bcdc811a81 100644
@@ -1099,9 +1099,6 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
 		return -EINVAL;
 	}
 
-	ep->packsize[0] = min(ep->packsize[0], ep->maxframesize);
-	ep->packsize[1] = min(ep->packsize[1], ep->maxframesize);
-
 	/* calculate the frequency in 16.16 format */
 	ep->freqm = ep->freqn;
 	ep->freqshift = INT_MIN;
sound/usb/pcm.c +7 -0
index f4494d054917..802ed1dbd23b 100644
@@ -953,6 +953,13 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
 	subs->data_endpoint->curframesize =
 		bytes_to_frames(runtime, subs->data_endpoint->curpacksize);
 
+	subs->data_endpoint->packsize[0] = min(
+		subs->data_endpoint->packsize[0],
+		subs->data_endpoint->maxframesize);
+	subs->data_endpoint->packsize[1] = min(
+		subs->data_endpoint->packsize[1],
+		subs->data_endpoint->maxframesize);
+
 	/* reset the pointer */
 	subs->hwptr_done = 0;
 	subs->transfer_done = 0;
Signature · 1 line
2.43.0
maintainer
#1 lore raw

sound/usb/pcm.c static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) · line 955

Quoted 5 lines
sound/usb/pcm.c +3 -0
@@ -953,6 +953,13 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
+	subs->data_endpoint->packsize[0] = min(
+		subs->data_endpoint->packsize[0],
+		subs->data_endpoint->maxframesize);

Moving the cap into snd_usb_pcm_prepare() is the right call for 5.10 - that tree never computes ep->maxframesize inside snd_usb_endpoint_set_params(), so there is nowhere in that function to move it to - but nothing in the changelog says that. Please send a v2 that spells the relocation out in the commit message, since the diff no longer matches upstream.

Two other things before I can take it:

- The Signed-off-by needs your real name; a handle does not satisfy the DCO.
- An ack from Takashi on the 5.10 placement, he's already on Cc.

Signature · 2 lines
Thanks,
Sasha