Commit 904967c6 authored by John Keeping's avatar John Keeping Committed by Felipe Balbi

usb: gadget: u_audio: Fix high-speed max packet size

Prior to commit eb9fecb9 ("usb: gadget: f_uac2: split out audio
core") the maximum packet size was calculated only from the high-speed
descriptor but now we use the largest of the full-speed and high-speed
descriptors.

This is correct, but the full-speed value is likely to be higher than
that for high-speed and this leads to submitting requests for OUT
transfers (received by the gadget) which are larger than the endpoint's
maximum packet size.  These are rightly rejected by the gadget core.

config_ep_by_speed() already sets up the correct maximum packet size for
the enumerated speed in the usb_ep structure, so we can simply use this
instead of the overall value that has been used to allocate buffers for
requests.

Note that the minimum period for ALSA is still set from the largest
value, and this is unavoidable because it's possible to open the audio
device before the gadget has been enumerated.
Tested-by: default avatarPavel Hofman  <pavel.hofman@ivitera.com>
Signed-off-by: default avatarJohn Keeping <john@metanate.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent 5ee85897
...@@ -361,7 +361,7 @@ int u_audio_start_capture(struct g_audio *audio_dev) ...@@ -361,7 +361,7 @@ int u_audio_start_capture(struct g_audio *audio_dev)
ep = audio_dev->out_ep; ep = audio_dev->out_ep;
prm = &uac->c_prm; prm = &uac->c_prm;
config_ep_by_speed(gadget, &audio_dev->func, ep); config_ep_by_speed(gadget, &audio_dev->func, ep);
req_len = prm->max_psize; req_len = ep->maxpacket;
prm->ep_enabled = true; prm->ep_enabled = true;
usb_ep_enable(ep); usb_ep_enable(ep);
...@@ -379,7 +379,7 @@ int u_audio_start_capture(struct g_audio *audio_dev) ...@@ -379,7 +379,7 @@ int u_audio_start_capture(struct g_audio *audio_dev)
req->context = &prm->ureq[i]; req->context = &prm->ureq[i];
req->length = req_len; req->length = req_len;
req->complete = u_audio_iso_complete; req->complete = u_audio_iso_complete;
req->buf = prm->rbuf + i * prm->max_psize; req->buf = prm->rbuf + i * ep->maxpacket;
} }
if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC)) if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC))
...@@ -430,9 +430,9 @@ int u_audio_start_playback(struct g_audio *audio_dev) ...@@ -430,9 +430,9 @@ int u_audio_start_playback(struct g_audio *audio_dev)
uac->p_pktsize = min_t(unsigned int, uac->p_pktsize = min_t(unsigned int,
uac->p_framesize * uac->p_framesize *
(params->p_srate / uac->p_interval), (params->p_srate / uac->p_interval),
prm->max_psize); ep->maxpacket);
if (uac->p_pktsize < prm->max_psize) if (uac->p_pktsize < ep->maxpacket)
uac->p_pktsize_residue = uac->p_framesize * uac->p_pktsize_residue = uac->p_framesize *
(params->p_srate % uac->p_interval); (params->p_srate % uac->p_interval);
else else
...@@ -457,7 +457,7 @@ int u_audio_start_playback(struct g_audio *audio_dev) ...@@ -457,7 +457,7 @@ int u_audio_start_playback(struct g_audio *audio_dev)
req->context = &prm->ureq[i]; req->context = &prm->ureq[i];
req->length = req_len; req->length = req_len;
req->complete = u_audio_iso_complete; req->complete = u_audio_iso_complete;
req->buf = prm->rbuf + i * prm->max_psize; req->buf = prm->rbuf + i * ep->maxpacket;
} }
if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC)) if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment