usb: gadget: f_uac2: prevent invalid bInterval auto-selection
PATCH 1/1 usb: gadget: f_uac2: prevent invalid bInterval auto-selection
When p_hs_bint or c_hs_bint is 0, the driver selects the largest bInterval from 4 down to 1 for which the required bandwidth fits the maximum packet size. The original implementation intends to keep bInterval at 1 when required bandwidth exceeds the single-packet maximum, but the search loop instead decrements bInterval to 0 in that case.
A bInterval of 0 is invalid for an isochronous endpoint. A Linux host reports it and substitutes a default:
usb 3-8: ... endpoint 0x1 has an invalid bInterval 0, changing to 7
Stop the search at bInterval=1. Maintain existing clamping of wMaxPacketSize and warning about possible data loss when the required bandwidth cannot be accommodated.
--- drivers/usb/gadget/function/f_uac2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/gadget/function/f_uac2.c +3 -3
@@ -728,11 +728,11 @@ static int set_ep_max_packet_size_bint(struct device *dev, const struct f_uac2_o bint = opts_bint; max_size_bw =get_max_bw_for_bint (uac2_opts, bint,8000 , is_playback); }else { -/* checking bInterval from 4 to 1 whether the required bandwidth fits */ -for (bint =4 ; bint >0 ; --bint) { +/* select the largest bInterval that fits, or 1 if none fit */ +for (bint =4 ; ; --bint) { max_size_bw =get_max_bw_for_bint ( uac2_opts, bint,8000 , is_playback); -if (max_size_bw <= max_size_ep) +if (max_size_bw <= max_size_ep || bint ==1 )break ; } }
base-commit: bdf12cde30830d46a8ef1ba93986356f1164b4f1
Signature · 1 line
2.34.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 9 lines
When
p_hs_bintorc_hs_bintis 0, the driver selects the largest bInterval from 4 down to 1 for which the required bandwidth fits the maximum packet size. The original implementation intends to keep bInterval at 1 when required bandwidth exceeds the single-packet maximum, but the search loop instead decrements bInterval to 0 in that case.A bInterval of 0 is invalid for an isochronous endpoint. A Linux host reports it and substitutes a default:
Quoted 8 lines
usb 3-8: ... endpoint
0x1has an invalid bInterval 0, changing to 7Stop the search at bInterval=1. Maintain existing clamping of wMaxPacketSize and warning about possible data loss when the required bandwidth cannot be accommodated.
Fixes 355a05dc8367 ("usb: gadget: f_uac2: Optionally determine bInterval for HS and SS")Signed-off-by Kyle Farrell <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 9 lines
When
p_hs_bintorc_hs_bintis 0, the driver selects the largest bInterval from 4 down to 1 for which the required bandwidth fits the maximum packet size. The original implementation intends to keep bInterval at 1 when required bandwidth exceeds the single-packet maximum, but the search loop instead decrements bInterval to 0 in that case.A bInterval of 0 is invalid for an isochronous endpoint. A Linux host reports it and substitutes a default:
Quoted 7 lines
usb 3-8: ... endpoint
0x1has an invalid bInterval 0, changing to 7Stop the search at bInterval=1. Maintain existing clamping of wMaxPacketSize and warning about possible data loss when the required bandwidth cannot be accommodated.
Fixes 355a05dc8367 ("usb: gadget: f_uac2: Optionally determine bInterval for HS and SS")
The change looks good to me but you're missing Cc: [email protected]
Signature · 1 line
Neill Kapron <[email protected]>
Quoted 15 lines · Neill Kapron
Quoted 15 lines
When
p_hs_bintorc_hs_bintis 0, the driver selects the largest bInterval from 4 down to 1 for which the required bandwidth fits the maximum packet size. The original implementation intends to keep bInterval at 1 when required bandwidth exceeds the single-packet maximum, but the search loop instead decrements bInterval to 0 in that case.A bInterval of 0 is invalid for an isochronous endpoint. A Linux host reports it and substitutes a default:
usb 3-8: ... endpoint
0x1has an invalid bInterval 0, changing to 7Stop the search at bInterval=1. Maintain existing clamping of wMaxPacketSize and warning about possible data loss when the required bandwidth cannot be accommodated.
Quoted 5 lines
Quoted 1 line
Fixes 355a05dc8367 ("usb: gadget: f_uac2: Optionally determine bInterval for HS and SS")The change looks good to me but you're missing Cc: [email protected]
Reviewed-by Neill Kapron <[email protected]>
Thanks Neill. I'll make sure to include the stable Cc on applicable fixes going forward. Could I ask that you add the trailer when applying the patch?
Thanks,
Kyle Farrell
Greg KH
maintainerQuoted 23 lines · On Mon, Nov 16, 2026 at 12:58:57PM -0800, [email protected] wrote:
Quoted 22 lines · Neill Kapron
Quoted 10 lines
When
p_hs_bintorc_hs_bintis 0, the driver selects the largest bInterval from 4 down to 1 for which the required bandwidth fits the maximum packet size. The original implementation intends to keep bInterval at 1 when required bandwidth exceeds the single-packet maximum,
but the search loop instead decrements bInterval to 0 in that case.A bInterval of 0 is invalid for an isochronous endpoint. A Linux host reports it and substitutes a default:
Quoted 8 lines
usb 3-8: ... endpoint
0x1has an invalid bInterval 0, changing to 7Stop the search at bInterval=1. Maintain existing clamping of wMaxPacketSize and warning about possible data loss when the required bandwidth cannot be accommodated.
Fixes 355a05dc8367 ("usb: gadget: f_uac2: Optionally determinebInterval for HS and SS")
The change looks good to me but you're missing Cc:
[email protected]
Quoted 7 lines
Quoted 1 line
Reviewed-by Neill Kapron <[email protected]>Thanks Neill. I'll make sure to include the stable Cc on applicable fixes going forward.
Could I ask that you add the trailer when applying the patch?
I can do so, thanks.