From: Fabien Sanglard <sanglardf@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oneukum@suse.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Fabien Sanglard <sanglardf@google.com>
Subject: [PATCH] usb: core: Emit KOBJ_CHANGE when usb_reset_device() succeeds
Date: Tue, 3 Nov 2026 23:51:15 +0000 [thread overview]
Message-ID: <20261103235115.3991801-1-sanglardf@google.com> (raw)
When usb_reset_device() succeeds without re-enumerating the device,
userspace receives no device-level uevent indicating that the reset has
completed. For usbfs clients such as adb, usb_forced_unbind_intf()
unbinds the interface before the port reset, and device_attach() leaves
it unbound afterward because no kernel driver matches.
Since usbfs suppresses uevents on interface claim/release, userspace
receives UNBIND(intf) before the reset and no event when the device is
ready to be re-claimed, forcing it to fall back to polling /dev/bus/usb.
Emit KOBJ_CHANGE on &udev->dev.kobj in usb_reset_device() when the reset
succeeds, after usb_unbind_and_rebind_marked_interfaces(udev), so
userspace is notified (with DEVNAME) once the reset and all kernel
interface rebinding are complete.
Suggested-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Fabien Sanglard <sanglardf@google.com>
---
Tested across snd-usb-audio (no pre/post_reset), usbhid (with
pre/post_reset), and usbfs (adb) using udevadm monitor:
Interface driver Uevent sequence on reset (ret == 0)
--------------------------------------------------------------------------
Kernel (no pre/post_reset) UNBIND(intf) -> BIND(intf) -> CHANGE(dev)
Kernel (with pre/post_reset) CHANGE(dev)
Userspace (usbfs, e.g. adb) UNBIND(intf) -> CHANGE(dev)
Discussion: https://lore.kernel.org/linux-usb/20261012171609.88273-1-sanglardf@google.com/
drivers/usb/core/hub.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 199d3f535..9b3835ced 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -6447,8 +6447,10 @@ int usb_reset_device(struct usb_device *udev)
}
/* If the reset failed, hub_wq will unbind drivers later */
- if (ret == 0)
+ if (ret == 0) {
usb_unbind_and_rebind_marked_interfaces(udev);
+ kobject_uevent(&udev->dev.kobj, KOBJ_CHANGE);
+ }
}
usb_autosuspend_device(udev);
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.56.0.385.gac671c819a-goog
reply other threads:[~2026-11-03 23:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103235115.3991801-1-sanglardf@google.com \
--to=sanglardf@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®