[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2026010733-robust-huntress-ce3a@gregkh>
Date: Wed, 7 Jan 2026 16:01:16 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Akshay Gujar <Akshay.Gujar@...man.com>
Cc: linux-usb@...r.kernel.org, stern@...land.harvard.edu, oneukum@...e.com,
linux-kernel@...r.kernel.org, naveen.v@...man.com,
sankarkumar.krishnasamy@...man.com
Subject: Re: [PATCH v2 1/3] driver core: add
device_enumeration_failure_notify() helper
On Wed, Dec 24, 2025 at 11:58:06AM +0000, Akshay Gujar wrote:
> Hotpluggable buses can detect that a device is physically present, but
> enumeration may still fail early due to protocol-level errors. Today,
> such failures are only reported via kernel log messages, with no
> structured userspace notification.
>
> Introduce device_enumeration_failure_notify(), a generic helper that
> emits a KOBJ_CHANGE uevent containing:
>
> DEVICE_ENUMERATION_FAILURE=<identifier>
>
> The <identifier> string is provided by the bus layer and identifies the
> failing port or device instance in a bus-defined format.
>
> This allows userspace to correlate repeated enumeration failures with
> specific ports or connectors without relying solely on kernel logs.
>
> Signed-off-by: Akshay Gujar <Akshay.Gujar@...man.com>
> ---
> drivers/base/core.c | 30 ++++++++++++++++++++++++++++++
> include/linux/device.h | 12 ++++++++++++
> 2 files changed, 42 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 40de2f51a1b1..4c70d9a6dc69 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -3747,6 +3747,36 @@ int device_add(struct device *dev)
> }
> EXPORT_SYMBOL_GPL(device_add);
>
> +/**
> + * device_enumeration_failure_notify - send uevent for enumeration failure
> + * @parent: the device to send the uevent from
> + * @id_name: textual identifier for the failing device
> + *
> + * Emits a KOBJ_CHANGE uevent with:
> + *
> + * DEVICE_ENUMERATION_FAILURE=<id_name>
> + *
> + * Buses such as USB/PCI may use this helper when hardware is detected
> + * but enumeration cannot proceed.
> + */
> +void device_enumeration_failure_notify(struct device *parent, const char *id_name)
> +{
> + char *envp[2] = { NULL, NULL };
> +
> + if (!parent || !id_name)
> + return;
> +
> + envp[0] = kasprintf(GFP_KERNEL,
> + "DEVICE_ENUMERATION_FAILURE=%s",
> + id_name);
> + if (!envp[0])
> + return;
> +
> + kobject_uevent_env(&parent->kobj, KOBJ_CHANGE, envp);
> + kfree(envp[0]);
> +}
> +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 0be95294b6e6..dedc5e9e0ade 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1197,4 +1197,16 @@ 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) "-*")
>
> +/**
> + * device_enumeration_failure_notify - notify userspace about enumeration failure
> + * @parent: device to emit the uevent from
Why is this called "parent"? SHouldn't this just be the device that
caused the failure?
> + * @id_name: textual identifier for the failed endpoint/device instance
Any hints on what this is going to contain? Should this be documented
somewhere?
thanks,
greg k-h
Powered by blists - more mailing lists