All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: core: Notify through uevent when not enough bandwidth available
@ 2026-06-15 14:35 Nícolas F. R. A. Prado
  2026-07-10 13:01 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Nícolas F. R. A. Prado @ 2026-06-15 14:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: kernel, linux-usb, linux-kernel, Nícolas F. R. A. Prado

Currently, when a new device is plugged in and the host controller can't
find enough bandwidth for it, an error message is printed:

  usb 1-3: Not enough bandwidth for new device state.

In order to allow userspace to react to this and suggest the user to use
a different host controller, send a uevent with
'USB_NOT_ENOUGH_BANDWIDTH=1' to the root hub device.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
 drivers/usb/core/hcd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8e8a5f59b319..a71605398540 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1825,6 +1825,13 @@ void usb_hcd_flush_endpoint(struct usb_device *udev,
 	}
 }
 
+static void not_enough_bandwidth_notify(struct usb_hcd *hcd)
+{
+	static char *envp[2] = { "USB_NOT_ENOUGH_BANDWIDTH=1", NULL };
+
+	kobject_uevent_env(&hcd->self.root_hub->dev.kobj, KOBJ_CHANGE, envp);
+}
+
 /**
  * usb_hcd_alloc_bandwidth - check whether a new bandwidth setting exceeds
  *				the bus bandwidth
@@ -1954,6 +1961,8 @@ int usb_hcd_alloc_bandwidth(struct usb_device *udev,
 		}
 	}
 	ret = hcd->driver->check_bandwidth(hcd, udev);
+	if (ret == -ENOSPC)
+		not_enough_bandwidth_notify(hcd);
 reset:
 	if (ret < 0)
 		hcd->driver->reset_bandwidth(hcd, udev);

---
base-commit: c425609d6ac4012c8bbf01ec2e10e801b1923a7b
change-id: 20260615-usb-notify-not-enough-bandwidth-5f39ccf6754b

Best regards,
-- 
Nícolas F. R. A. Prado <nfraprado@collabora.com>


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

end of thread, other threads:[~2026-07-21 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 14:35 [PATCH] usb: core: Notify through uevent when not enough bandwidth available Nícolas F. R. A. Prado
2026-07-10 13:01 ` Greg Kroah-Hartman
2026-07-21 13:14   ` Nícolas F. R. A. Prado

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.