mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] xhci: Fix HIK camera control timeout on Etron hosts
@ 2026-09-14  1:30 Kuangyi Chiang
  2026-09-14 11:09 ` Michal Pecio
  0 siblings, 1 reply; 4+ messages in thread
From: Kuangyi Chiang @ 2026-09-14  1:30 UTC (permalink / raw)
  To: mathias.nyman, gregkh; +Cc: linux-usb, linux-kernel, ki.chiang65

Control transfers to the HIK 1080P Camera (2bdf:0280) can time out when
the device is connected through an Etron xHCI host:

[   48.363671] uvcvideo: Found UVC 1.00 device HIK 1080P Camera (2bdf:0280)
[   53.465662] uvcvideo: Failed to set UVC probe control : -110 (exp. 26).
[   58.585653] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
[   58.592967] uvcvideo: Failed to initialize the device (-5).

Testing shows that at least 125 us between control transfers is required
to avoid the timeout. Limit the workaround to the affected Etron host and
USB device combination to avoid changing control-transfer timing for other
devices.

Perform the delay before taking xhci->lock so the existing state validation
and TD queueing remain in the same critical section. Use udelay() because
urb_enqueue() may be called from atomic context and cannot use a sleeping
delay.

Signed-off-by: Kuangyi Chiang <ki.chiang65@gmail.com>
---
 drivers/usb/host/xhci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 5c759ad..925716a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1648,6 +1648,16 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 
 	trace_xhci_urb_enqueue(urb);
 
+	/*
+	 * This camera needs at least 125 us between control transfers
+	 * when used with an Etron xHCI host.
+	 */
+	if ((xhci->quirks & XHCI_ETRON_HOST) &&
+	    usb_endpoint_xfer_control(&urb->ep->desc) &&
+	    le16_to_cpu(urb->dev->descriptor.idVendor) == 0x2bdf &&
+	    le16_to_cpu(urb->dev->descriptor.idProduct) == 0x0280)
+		udelay(125);
+
 	spin_lock_irqsave(&xhci->lock, flags);
 
 	ret = xhci_check_args(hcd, urb->dev, urb->ep,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xhci: Fix HIK camera control timeout on Etron hosts
  2026-09-14  1:30 [PATCH] xhci: Fix HIK camera control timeout on Etron hosts Kuangyi Chiang
@ 2026-09-14 11:09 ` Michal Pecio
  2026-09-16  1:33   ` Kuangyi Chiang
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Pecio @ 2026-09-14 11:09 UTC (permalink / raw)
  To: Kuangyi Chiang; +Cc: mathias.nyman, gregkh, linux-usb, linux-kernel

On Mon, 14 Sep 2026 09:30:33 +0800, Kuangyi Chiang wrote:
> Control transfers to the HIK 1080P Camera (2bdf:0280) can time out when
> the device is connected through an Etron xHCI host:
> 
> [   48.363671] uvcvideo: Found UVC 1.00 device HIK 1080P Camera (2bdf:0280)
> [   53.465662] uvcvideo: Failed to set UVC probe control : -110 (exp. 26).
> [   58.585653] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
> [   58.592967] uvcvideo: Failed to initialize the device (-5).
> 
> Testing shows that at least 125 us between control transfers is required
> to avoid the timeout. Limit the workaround to the affected Etron host and
> USB device combination to avoid changing control-transfer timing for other
> devices.

Any idea why it happens or why the delay helps?
How many other HCs did you test this camera with?
Does it help to reconnect and try again?

FWIW, I tried a few USB 2.0 cameras with my Etron and they mostly work,
except one. It passes probe just fine, but fails on streaming attempt.
Adding 125us delay doesn't help, but 1000 works sometimes and 4000 even
more often.

Probably a HW bug. Honestly, I never use Etron for anything serious.

> Perform the delay before taking xhci->lock so the existing state
> validation and TD queueing remain in the same critical section. Use
> udelay() because urb_enqueue() may be called from atomic context and
> cannot use a sleeping delay.

Actually, you would need to do that under lock if you want to ensure
that multiple callers can't submit URBs closely together. But that's
dodgy and we don't even know what exactly triggers it or whether this
solution really is the best one.

Regards,
Michal

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xhci: Fix HIK camera control timeout on Etron hosts
  2026-09-14 11:09 ` Michal Pecio
@ 2026-09-16  1:33   ` Kuangyi Chiang
  2026-09-16 12:18     ` Mathias Nyman
  0 siblings, 1 reply; 4+ messages in thread
From: Kuangyi Chiang @ 2026-09-16  1:33 UTC (permalink / raw)
  To: Michal Pecio; +Cc: mathias.nyman, gregkh, linux-usb, linux-kernel

Hi,

Thanks for the review.

Michal Pecio <michal.pecio@gmail.com> 於 2026年9月14日週一 下午7:09寫道:
>
> On Mon, 14 Sep 2026 09:30:33 +0800, Kuangyi Chiang wrote:
> > Control transfers to the HIK 1080P Camera (2bdf:0280) can time out when
> > the device is connected through an Etron xHCI host:
> >
> > [   48.363671] uvcvideo: Found UVC 1.00 device HIK 1080P Camera (2bdf:0280)
> > [   53.465662] uvcvideo: Failed to set UVC probe control : -110 (exp. 26).
> > [   58.585653] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
> > [   58.592967] uvcvideo: Failed to initialize the device (-5).
> >
> > Testing shows that at least 125 us between control transfers is required
> > to avoid the timeout. Limit the workaround to the affected Etron host and
> > USB device combination to avoid changing control-transfer timing for other
> > devices.
>
> Any idea why it happens or why the delay helps?

We don't know the root cause yet, but we did some more testing.

We tested delays of 50us, 125us, and 200us. The issue was still
reproducible with 50us, while 125us and 200us passed our test.

Our pass criterion is 30 successful plug/unplug cycles on each port.
So 125us is the minimum delay we tested that consistently works.

We also tried USB_QUIRK_DELAY_CTRL_MSG, but its 200ms delay is too
long and causes UVC initialization to fail.

> How many other HCs did you test this camera with?

The camera works with the EHCI host we tested without any delay.
We can also reproduce a similar issue with an ASMedia ASM1142 xHCI
host (1b21:1242). This patch, however, is limited to the Etron/HIK
combination.

> Does it help to reconnect and try again?

No. The issue is still reproducible after reconnecting the camera.

>
> FWIW, I tried a few USB 2.0 cameras with my Etron and they mostly work,
> except one. It passes probe just fine, but fails on streaming attempt.
> Adding 125us delay doesn't help, but 1000 works sometimes and 4000 even
> more often.
>
> Probably a HW bug. Honestly, I never use Etron for anything serious.
>
> > Perform the delay before taking xhci->lock so the existing state
> > validation and TD queueing remain in the same critical section. Use
> > udelay() because urb_enqueue() may be called from atomic context and
> > cannot use a sleeping delay.
>
> Actually, you would need to do that under lock if you want to ensure
> that multiple callers can't submit URBs closely together. But that's
> dodgy and we don't even know what exactly triggers it or whether this
> solution really is the best one.

Agreed. For the UVC control transfers involved here, the next transfer
is submitted only after the previous one completes, so they are
serialized.

The delay before xhci->lock does not prevent other callers from
submitting control URBs close together. However, this workaround is
limited to control transfers for the affected Etron/HIK combination.

Regards,
Kuangyi

>
> Regards,
> Michal

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xhci: Fix HIK camera control timeout on Etron hosts
  2026-09-16  1:33   ` Kuangyi Chiang
@ 2026-09-16 12:18     ` Mathias Nyman
  0 siblings, 0 replies; 4+ messages in thread
From: Mathias Nyman @ 2026-09-16 12:18 UTC (permalink / raw)
  To: Kuangyi Chiang, Michal Pecio
  Cc: mathias.nyman, gregkh, linux-usb, linux-kernel

On 9/16/26 04:33, Kuangyi Chiang wrote:
> Hi,
> 
> Thanks for the review.
> 
> Michal Pecio <michal.pecio@gmail.com> 於 2026年9月14日週一 下午7:09寫道:
>>
>> On Mon, 14 Sep 2026 09:30:33 +0800, Kuangyi Chiang wrote:
>>> Control transfers to the HIK 1080P Camera (2bdf:0280) can time out when
>>> the device is connected through an Etron xHCI host:
>>>
>>> [   48.363671] uvcvideo: Found UVC 1.00 device HIK 1080P Camera (2bdf:0280)
>>> [   53.465662] uvcvideo: Failed to set UVC probe control : -110 (exp. 26).
>>> [   58.585653] uvcvideo: Failed to query (129) UVC probe control : -110 (exp. 26).
>>> [   58.592967] uvcvideo: Failed to initialize the device (-5).
>>>
>>> Testing shows that at least 125 us between control transfers is required
>>> to avoid the timeout. Limit the workaround to the affected Etron host and
>>> USB device combination to avoid changing control-transfer timing for other
>>> devices.
>>
>> Any idea why it happens or why the delay helps?
> 
> We don't know the root cause yet, but we did some more testing.
> 
> We tested delays of 50us, 125us, and 200us. The issue was still
> reproducible with 50us, while 125us and 200us passed our test.
> 
> Our pass criterion is 30 successful plug/unplug cycles on each port.
> So 125us is the minimum delay we tested that consistently works.
> 

Are there issues with the control transfers already during enumeration
of the device, when reading descriptors etc, or are these issues only
visible after uvc driver is controlling the device?


> We also tried USB_QUIRK_DELAY_CTRL_MSG, but its 200ms delay is too
> long and causes UVC initialization to fail.
> 

Does it help if you as a hack set udev->quirks |= USB_QUIRK_DELAY_CTRL_MSG
_after_ enumeration and uvc initialization?

>> How many other HCs did you test this camera with?
> 
> The camera works with the EHCI host we tested without any delay.
> We can also reproduce a similar issue with an ASMedia ASM1142 xHCI
> host (1b21:1242). This patch, however, is limited to the Etron/HIK
> combination.

I think we should avoid usb device specific quirks in the xhci driver,
especially now that we know it's not really tied to a specific xHC vendor.

If this is only an issue with the control transfers sent by uvc driver
then I think this device specific quirk should be in there.

Thanks
Mathias



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-16 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14  1:30 [PATCH] xhci: Fix HIK camera control timeout on Etron hosts Kuangyi Chiang
2026-09-14 11:09 ` Michal Pecio
2026-09-16  1:33   ` Kuangyi Chiang
2026-09-16 12:18     ` Mathias Nyman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®