* [PATCH] usb: gadget: f_uac2: prevent invalid bInterval auto-selection
@ 2026-10-28 22:28 Kyle Farrell
2026-10-28 22:31 ` sashiko-bot
0 siblings, 1 reply; 2+ 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] 2+ 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
0 siblings, 0 replies; 2+ 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] 2+ messages in thread
end of thread, other threads:[~2026-10-28 22:31 UTC | newest]
Thread overview: 2+ 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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.