usb: gadget: u_audio: Fix high-speed max packet size
authorJohn Keeping <john@metanate.com>
Fri, 17 Jan 2020 10:40:22 +0000 (10:40 +0000)
committerFelipe Balbi <balbi@kernel.org>
Tue, 11 Feb 2020 06:45:45 +0000 (08:45 +0200)
commit904967c60d87393a3708fed2324b684cdb79b1ee
tree726507b1a19e60c25bff7147761d7f35758efa11
parent5ee858975b13a9b40db00f456989a689fdbb296c
usb: gadget: u_audio: Fix high-speed max packet size

Prior to commit eb9fecb9e69b ("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: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/gadget/function/u_audio.c