* [PATCH v6 1/3] driver core: add device_enumeration_failure_notify() helper
2026-08-02 23:31 [PATCH v6 0/3] driver core: add enumeration failure uevent helper Akshay Gujar
@ 2026-08-02 23:31 ` Akshay Gujar
2026-08-02 23:31 ` [PATCH v6 2/3] Documentation: ABI: document DEVICE_ENUMERATION_FAILURE uevent Akshay Gujar
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Akshay Gujar @ 2026-08-02 23:31 UTC (permalink / raw)
To: gregkh; +Cc: Akshay.Gujar, linux-kernel, linux-usb, naveen.v, oneukum, stern
Hotpluggable buses may detect that a device is physically present, but
enumeration can fail early due to protocol-level errors. Such failures
are currently only visible via kernel log messages, with no structured
notification to userspace.
Introduce device_enumeration_failure_notify(), a helper in the driver
core that emits a KOBJ_CHANGE uevent with
DEVICE_ENUMERATION_FAILURE=<failed_id>
The emitting device and the identifier are separate arguments because
the device being enumerated usually does not exist yet. The event is
emitted from a device the bus driver has already registered, and the
identifier names the port or slot that failed.
Signed-off-by: Akshay Gujar <Akshay.Gujar@harman.com>
---
drivers/base/core.c | 35 +++++++++++++++++++++++++++++++++++
include/linux/device.h | 2 ++
2 files changed, 37 insertions(+)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 4d026682944f2..af6901799df58 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3830,6 +3830,41 @@ int device_add(struct device *dev)
}
EXPORT_SYMBOL_GPL(device_add);
+/**
+ * device_enumeration_failure_notify - notify userspace of enumeration failure
+ * @dev: device to emit the uevent from
+ * @failed_id: bus-specific identifier of the port or slot that failed to
+ * enumerate, e.g. the port device name for USB
+ *
+ * Emit a KOBJ_CHANGE uevent from @dev carrying
+ * DEVICE_ENUMERATION_FAILURE=@failed_id.
+ *
+ * Return: 0 on success, a negative error code otherwise.
+ *
+ * See Documentation/ABI/testing/sysfs-uevent for more details.
+ */
+int device_enumeration_failure_notify(struct device *dev,
+ const char *failed_id)
+{
+ char *envp[2] = { NULL, NULL };
+ int ret;
+
+ if (!failed_id || !*failed_id)
+ return -EINVAL;
+
+ envp[0] = kasprintf(GFP_KERNEL, "DEVICE_ENUMERATION_FAILURE=%s",
+ failed_id);
+
+ if (!envp[0])
+ return -ENOMEM;
+
+ ret = kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
+ kfree(envp[0]);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(device_enumeration_failure_notify);
+
/**
* device_register - register a device with the system.
* @dev: pointer to the device structure
diff --git a/include/linux/device.h b/include/linux/device.h
index 7b2baffdd2f55..7dc9b2316ea24 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1394,4 +1394,6 @@ static inline bool device_link_test(const struct device_link *link, u32 flags)
#define MODULE_ALIAS_CHARDEV_MAJOR(major) \
MODULE_ALIAS("char-major-" __stringify(major) "-*")
+int device_enumeration_failure_notify(struct device *dev, const char *failed_id);
+
#endif /* _DEVICE_H_ */
--
2.19.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v6 2/3] Documentation: ABI: document DEVICE_ENUMERATION_FAILURE uevent
2026-08-02 23:31 [PATCH v6 0/3] driver core: add enumeration failure uevent helper Akshay Gujar
2026-08-02 23:31 ` [PATCH v6 1/3] driver core: add device_enumeration_failure_notify() helper Akshay Gujar
@ 2026-08-02 23:31 ` Akshay Gujar
2026-08-02 23:31 ` [PATCH v6 3/3] usb: hub: send enumeration failure uevent Akshay Gujar
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Akshay Gujar @ 2026-08-02 23:31 UTC (permalink / raw)
To: gregkh; +Cc: Akshay.Gujar, linux-kernel, linux-usb, naveen.v, oneukum, stern
Document the DEVICE_ENUMERATION_FAILURE environment variable emitted
in KOBJ_CHANGE uevents when device enumeration fails.
Signed-off-by: Akshay Gujar <Akshay.Gujar@harman.com>
---
Documentation/ABI/testing/sysfs-uevent | 37 ++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-uevent b/Documentation/ABI/testing/sysfs-uevent
index 0b6227706b35e..6ace99f99daa3 100644
--- a/Documentation/ABI/testing/sysfs-uevent
+++ b/Documentation/ABI/testing/sysfs-uevent
@@ -49,3 +49,40 @@ Description:
Users:
udev, userspace tools generating synthetic uevents
+
+What: DEVICE_ENUMERATION_FAILURE
+Date: August 2026
+KernelVersion: 7.3
+Description:
+ Some devices are detected as physically present but fail
+ to enumerate, for example due to protocol-level errors or
+ invalid responses.
+
+ When this happens, a bus driver may emit a KOBJ_CHANGE
+ uevent containing:
+
+ DEVICE_ENUMERATION_FAILURE=<identifier>
+
+ The value is a bus-specific identifier of the port or slot
+ on which enumeration failed, not the name of the device
+ that emitted the event. For USB this is the port device
+ name, e.g. "usb1-port1".
+
+ Example (USB):
+
+ ACTION=change
+ SUBSYSTEM=usb
+ DEVTYPE=usb_interface
+ DEVPATH=/devices/.../usb1/1-0:1.0
+ DEVICE_ENUMERATION_FAILURE=usb1-port1
+
+ The event is emitted from the hub interface that owns the
+ port, so DEVPATH refers to the interface. Appending the
+ identifier to DEVPATH gives the failing port:
+
+ /sys/devices/.../usb1/1-0:1.0/usb1-port1/
+
+Users:
+ udev, userspace tools monitoring device enumeration
+ failures
+
--
2.19.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v6 3/3] usb: hub: send enumeration failure uevent
2026-08-02 23:31 [PATCH v6 0/3] driver core: add enumeration failure uevent helper Akshay Gujar
2026-08-02 23:31 ` [PATCH v6 1/3] driver core: add device_enumeration_failure_notify() helper Akshay Gujar
2026-08-02 23:31 ` [PATCH v6 2/3] Documentation: ABI: document DEVICE_ENUMERATION_FAILURE uevent Akshay Gujar
@ 2026-08-02 23:31 ` Akshay Gujar
2026-08-10 8:23 ` [PATCH v6 0/3] driver core: add enumeration failure uevent helper Akshay Gujar
2026-08-10 8:24 ` Akshay Gujar
4 siblings, 0 replies; 6+ messages in thread
From: Akshay Gujar @ 2026-08-02 23:31 UTC (permalink / raw)
To: gregkh; +Cc: Akshay.Gujar, linux-kernel, linux-usb, naveen.v, oneukum, stern
Emit a structured uevent when USB device enumeration fails in
hub_port_connect(), supplementing the existing error log with a
notification userspace can act on.
The event is emitted from the port's parent, the hub interface, because
usb_port devices have neither a bus nor a class and dev_uevent_filter()
drops any uevent sent from them. The failing port is named in the
payload.
Signed-off-by: Akshay Gujar <Akshay.Gujar@harman.com>
---
drivers/usb/core/hub.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5262e11c12cd3..78275dd702ceb 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5613,9 +5613,21 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
if (hub->hdev->parent ||
!hcd->driver->port_handed_over ||
!(hcd->driver->port_handed_over)(hcd, port1)) {
- if (status != -ENOTCONN && status != -ENODEV)
+ if (status != -ENOTCONN && status != -ENODEV) {
+ int ret;
dev_err(&port_dev->dev,
"unable to enumerate USB device\n");
+
+ /* usb_port has no bus or class, so uevents from it
+ * are dropped; emit from the hub interface instead.
+ */
+ ret = device_enumeration_failure_notify(port_dev->dev.parent,
+ dev_name(&port_dev->dev));
+ if (ret)
+ dev_warn(&port_dev->dev,
+ "failed to send enumeration failure uevent: %d\n",
+ ret);
+ }
}
done:
--
2.19.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v6 0/3] driver core: add enumeration failure uevent helper
2026-08-02 23:31 [PATCH v6 0/3] driver core: add enumeration failure uevent helper Akshay Gujar
` (2 preceding siblings ...)
2026-08-02 23:31 ` [PATCH v6 3/3] usb: hub: send enumeration failure uevent Akshay Gujar
@ 2026-08-10 8:23 ` Akshay Gujar
2026-08-10 8:24 ` Akshay Gujar
4 siblings, 0 replies; 6+ messages in thread
From: Akshay Gujar @ 2026-08-10 8:23 UTC (permalink / raw)
To: akshay.gujar; +Cc: gregkh, linux-kernel, linux-usb, naveen.v, oneukum, stern
Hi Greg,
Gentle ping on this patch series. Please let me know if any further changes are needed.
Thanks,
Akshay
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v6 0/3] driver core: add enumeration failure uevent helper
2026-08-02 23:31 [PATCH v6 0/3] driver core: add enumeration failure uevent helper Akshay Gujar
` (3 preceding siblings ...)
2026-08-10 8:23 ` [PATCH v6 0/3] driver core: add enumeration failure uevent helper Akshay Gujar
@ 2026-08-10 8:24 ` Akshay Gujar
4 siblings, 0 replies; 6+ messages in thread
From: Akshay Gujar @ 2026-08-10 8:24 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, linux-usb, naveen.v, oneukum, stern
Hi Greg,
Gentle ping on this patch series. Please let me know if any further changes are needed.
Thanks,
Akshay
^ permalink raw reply [flat|nested] 6+ messages in thread