mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: core: Emit KOBJ_CHANGE on unbound interface
       [not found] <b7c2f7d1-40fd-4d83-8ced-5fc27e3be051@rowland.harvard.edu>
@ 2026-10-12 17:16 ` Fabien Sanglard
  0 siblings, 0 replies; only message in thread
From: Fabien Sanglard @ 2026-10-12 17:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Alan Stern; +Cc: linux-usb, linux-kernel, Fabien Sanglard

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


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <b7c2f7d1-40fd-4d83-8ced-5fc27e3be051@rowland.harvard.edu>
2026-10-12 17:16 ` [PATCH] usb: core: Emit KOBJ_CHANGE on unbound interface Fabien Sanglard

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®