[PATCH] usb: core: Notify through uevent when not enough bandwidth available
From: Nícolas F. R. A. Prado
Date: Mon Jun 15 2026 - 10:37:46 EST
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@xxxxxxxxxxxxx>
---
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@xxxxxxxxxxxxx>