Linux USB
 help / color / mirror / Atom feed
* Missing uevents after successful USBDEVFS_RESET
@ 2026-09-15 21:48 Fabien Sanglard
  2026-09-16  2:37 ` Alan Stern
  0 siblings, 1 reply; 8+ messages in thread
From: Fabien Sanglard @ 2026-09-15 21:48 UTC (permalink / raw)
  To: linux-usb; +Cc: gregkh, stern

Hi,

I am investigating an issue where userspace processes using usbfs (such as
ADB) cannot reliably track device state across a USBDEVFS_RESET ioctl by
monitoring netlink uevents.

Repro steps: (Lenovo P620, kernel 7.1.6)
1. Plug an ADB device into your computer.
2. Open a console to monitor netlink events: udevadm monitor -p -u.
3. Send USBDEVFS_RESET a couple of times (i used adb_usbreset).
4. 50% of the time the event sequence is UNBIND/REMOVE/ADD/BIND. 50%
of the time, the event sequence is just UNBIND.

When USBDEVFS_RESET is issued via drivers/usb/core/devio.c, it calls
usb_reset_device() -> usb_reset_and_verify_device() in drivers/usb/core/hub.c.
Depending on the reset outcome, userspace sees inconsistent uevents:

Case 1: Full re-enumeration (descriptors changed or reset/verify failed)
The device is torn down and reprobed. Userspace receives:
  UNBIND -> REMOVE -> ADD -> BIND
Userspace processes monitoring uevents immediately detect that the device
is available again and re-open it.

Case 2: Reset succeeds without re-enumeration (descriptors unchanged)
The kernel unbinds usbfs/interface drivers before reset, generating a
KOBJ_UNBIND uevent. Because the usb_device structure is preserved and
usbfs does not re-probe, no subsequent KOBJ_BIND, KOBJ_ADD, or KOBJ_CHANGE
event is ever emitted.

As a result of Case 2, userspace receives an UNBIND ("disconnect") signal
and assumes the device went away, but never receives an event indicating
that the reset finished and the device is ready for reuse. This forces
daemons like adb to fall back to polling /dev/bus/usb instead of relying
on netlink/udev events.

Is the omission of a completion uevent after a successful reset without
re-enumeration intentional?

If not, would a patch emitting KOBJ_CHANGE (or re-binding/notifying userspace)
upon completion of usb_reset_device() be acceptable here?

Thanks,
Fab

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

end of thread, other threads:[~2026-10-13 16:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 21:48 Missing uevents after successful USBDEVFS_RESET Fabien Sanglard
2026-09-16  2:37 ` Alan Stern
2026-09-20  6:00   ` Fabien Sanglard
2026-09-20 14:58     ` Alan Stern
2026-10-12 17:16       ` [PATCH] usb: core: Emit KOBJ_CHANGE on unbound interface Fabien Sanglard
2026-10-12 17:28         ` sashiko-bot
2026-10-13  9:34         ` Oliver Neukum
2026-10-13 16:48           ` Fabien Sanglard

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