* [PATCH] usb: gadget: f_uac2: prevent invalid bInterval auto-selection
@ 2026-10-28 22:28 Kyle Farrell
2026-10-28 22:31 ` sashiko-bot
2026-11-16 19:44 ` Neill Kapron
0 siblings, 2 replies; 4+ messages in thread
From: Kyle Farrell @ 2026-10-28 22:28 UTC (permalink / raw)
To: nkapron, gregkh; +Cc: pavel.hofman, linux-usb, Kyle Farrell
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.
Fixes: 355a05dc8367 ("usb: gadget: f_uac2: Optionally determine bInterval for HS and SS")
Signed-off-by: Kyle Farrell <kaf@nwlink.com>
---
drivers/usb/gadget/function/f_uac2.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index d8cf710085a0..9bd59ea5f7fb 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -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
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] usb: gadget: f_uac2: prevent invalid bInterval auto-selection
2026-10-28 22:28 [PATCH] usb: gadget: f_uac2: prevent invalid bInterval auto-selection Kyle Farrell
@ 2026-10-28 22:31 ` sashiko-bot
2026-11-16 19:44 ` Neill Kapron
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-10-28 22:31 UTC (permalink / raw)
To: Kyle Farrell; +Cc: linux-usb
> 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.
>
> Fixes: 355a05dc8367 ("usb: gadget: f_uac2: Optionally determine bInterval for HS and SS")
> Signed-off-by: Kyle Farrell <kaf@nwlink.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261028222800.782988-1-kaf@nwlink.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] usb: gadget: f_uac2: prevent invalid bInterval auto-selection
2026-10-28 22:28 [PATCH] usb: gadget: f_uac2: prevent invalid bInterval auto-selection Kyle Farrell
2026-10-28 22:31 ` sashiko-bot
@ 2026-11-16 19:44 ` Neill Kapron
2026-11-16 20:58 ` kaf
1 sibling, 1 reply; 4+ messages in thread
From: Neill Kapron @ 2026-11-16 19:44 UTC (permalink / raw)
To: Kyle Farrell; +Cc: nkapron, gregkh, pavel.hofman, linux-usb
> 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.
>
> Fixes: 355a05dc8367 ("usb: gadget: f_uac2: Optionally determine bInterval for HS and SS")
The change looks good to me but you're missing Cc: stable@vger.kernel.org
Reviewed-by: Neill Kapron <nkapron@google.com>
--
Neill Kapron <nkapron@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] usb: gadget: f_uac2: prevent invalid bInterval auto-selection
2026-11-16 19:44 ` Neill Kapron
@ 2026-11-16 20:58 ` kaf
0 siblings, 0 replies; 4+ messages in thread
From: kaf @ 2026-11-16 20:58 UTC (permalink / raw)
To: Neill Kapron; +Cc: gregkh, pavel.hofman, linux-usb
On 2026-11-16 11:44, Neill Kapron wrote:
>> 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.
>>
>> Fixes: 355a05dc8367 ("usb: gadget: f_uac2: Optionally determine
>> bInterval for HS and SS")
>
> The change looks good to me but you're missing Cc:
> stable@vger.kernel.org
>
> Reviewed-by: Neill Kapron <nkapron@google.com>
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?
Cc: stable@vger.kernel.org
Thanks,
Kyle Farrell
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-16 20:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28 22:28 [PATCH] usb: gadget: f_uac2: prevent invalid bInterval auto-selection Kyle Farrell
2026-10-28 22:31 ` sashiko-bot
2026-11-16 19:44 ` Neill Kapron
2026-11-16 20:58 ` kaf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox