All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb-host: reset the open retry count after a successful open
@ 2026-10-28 16:07 Junjie Cao
  0 siblings, 0 replies; only message in thread
From: Junjie Cao @ 2026-10-28 16:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: thuth, marcandre.lureau, sundayjiang, kraxel, fa1rid, qemu-stable,
	junjie.cao

usb_host_auto_check() gives up on a matching device once three opens
have failed, and clears the failure count only when a scan finds no
matching device at all. A device that re-enumerates, e.g. after a
firmware reboot, is closed on NO_DEVICE and usb_host_close() rescans at
once, while libusb still lists the old address: that open fails and
counts, the next 2 s scan opens the new address, and nothing clears the
count. After the third such cycle the device is skipped until a scan
finds it absent or the usb-host device is re-added.

Clear the count once an open succeeds. A device that cannot be opened at
all still stops after three attempts.

The source-level fixture attached to #4673 reproduces the same sequence;
its remaining cases expect a failure budget per enumerated device, which
this change does not add.

Fixes: 3ee886c5ba77 ("usb-host: limit open retries")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4631
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/4673
Cc: qemu-stable@nongnu.org
Reported-by: Farid <fa1rid@live.com>
Reported-by: Prateek Rungta <https://gitlab.com/prateek2>
Suggested-by: Farid <fa1rid@live.com>
Signed-off-by: Junjie Cao <junjie.cao@linux.dev>
---
The source-level fixture attached to #4673: 15 tests, 7 failures on
master d29412cca5, 5 with this change. The two reconnect scenarios pass
(repeated-reconnects, success-resets-own-budget). Of the other five,
four expect a failure budget per enumerated device and one expects a
libusb_get_device_list() error not to reset the count; both are outside
this change.

Farid's attached patch resets the count inside usb_host_open(); this one
keeps it next to the failure count in usb_host_auto_check().

 hw/usb/host-libusb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 8f7ced95cf..5a369e2ebf 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1924,6 +1924,7 @@ static void usb_host_auto_check(void *unused)
                     s->errcount++;
                     continue;
                 }
+                s->errcount = 0;
                 break;
             }
         }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-28 16:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28 16:07 [PATCH] usb-host: reset the open retry count after a successful open Junjie Cao

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.