From: Fabien Sanglard <sanglardf@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Fabien Sanglard <sanglardf@google.com>
Subject: [PATCH] usb: core: Emit KOBJ_CHANGE on unbound interface
Date: Mon, 12 Oct 2026 10:16:09 -0700 [thread overview]
Message-ID: <20261012171609.88273-1-sanglardf@google.com> (raw)
In-Reply-To: <b7c2f7d1-40fd-4d83-8ced-5fc27e3be051@rowland.harvard.edu>
When an interface driver is forcibly unbound before a device reset,
usb_rebind_intf() attempts to re-attach a driver once the reset
completes in-place. Normal kernel drivers rebind and emit UNBIND
followed by BIND. However, usbfs only binds on explicit userspace
requests (e.g., USBDEVFS_CLAIMINTERFACE), so device_attach() returns 0
and no uevent is emitted.
As a result, userspace clients like adb only see UNBIND and must poll
/dev/bus/usb to detect when the interface is ready again. Emit a
KOBJ_CHANGE uevent when device_attach() finds no matching driver so
userspace is notified that the interface can be reclaimed.
Link: https://lore.kernel.org/linux-usb/CAA92w6k-LA4tVXyX1mFNOR3e+_mC43F_BXqhXeWqQyFx2D4_Mg@mail.gmail.com/
Signed-off-by: Fabien Sanglard <sanglardf@google.com>
---
drivers/usb/core/driver.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 7f33fe5ba03b..25057423fda0 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1182,8 +1182,15 @@ static void usb_rebind_intf(struct usb_interface *intf)
if (!intf->dev.power.is_prepared) {
intf->needs_binding = 0;
rc = device_attach(&intf->dev);
- if (rc < 0 && rc != -EPROBE_DEFER)
+ if (rc < 0 && rc != -EPROBE_DEFER) {
dev_warn(&intf->dev, "rebind failed: %d\n", rc);
+ } else if (rc == 0) {
+ /*
+ * Emit a KOBJ_CHANGE uevent to notify userspace
+ * that the interface could not be rebound.
+ */
+ kobject_uevent(&intf->dev.kobj, KOBJ_CHANGE);
+ }
}
}
--
2.55.0.1082.g2b9226bbc0-goog
next prev parent reply other threads:[~2026-10-12 17:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Fabien Sanglard [this message]
2026-10-12 17:28 ` [PATCH] usb: core: Emit KOBJ_CHANGE on unbound interface sashiko-bot
2026-10-13 9:34 ` Oliver Neukum
2026-10-13 16:48 ` Fabien Sanglard
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=20261012171609.88273-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=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