public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Akshay Gujar <Akshay.Gujar@harman.com>
Cc: linux-usb@vger.kernel.org, stern@rowland.harvard.edu,
	oneukum@suse.com, linux-kernel@vger.kernel.org,
	naveen.v@harman.com, sankarkumar.krishnasamy@harman.com
Subject: Re: [PATCH v2 1/3] driver core: add device_enumeration_failure_notify() helper
Date: Wed, 7 Jan 2026 16:01:16 +0100	[thread overview]
Message-ID: <2026010733-robust-huntress-ce3a@gregkh> (raw)
In-Reply-To: <20251224115808.415753-2-Akshay.Gujar@harman.com>

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@harman.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

  parent reply	other threads:[~2026-01-07 15:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250221102949.1135849-1-Akshay.Gujar@harman.com>
2025-02-21 10:53 ` [PATCH] usb: core: notify unrecognized usb device Greg KH
     [not found]   ` <20250826165244.22283-1-Akshay.Gujar@harman.com>
2025-09-06 12:28     ` Greg KH
2025-09-08  8:58       ` Oliver Neukum
2025-09-08  9:04         ` Greg KH
     [not found]       ` <20250918172355.5118-1-Akshay.Gujar@harman.com>
2025-10-08 11:08         ` Greg KH
     [not found]           ` <20251224115808.415753-1-Akshay.Gujar@harman.com>
     [not found]             ` <20251224115808.415753-2-Akshay.Gujar@harman.com>
2026-01-07 15:01               ` Greg KH [this message]
2026-01-07 15:01             ` [PATCH v2 0/3] Generic device enumeration failure notification Greg KH
     [not found]             ` <20251224115808.415753-3-Akshay.Gujar@harman.com>
2026-01-07 15:02               ` [PATCH v2 2/3] Documentation: ABI: document DEVICE_ENUMERATION_FAILURE uevent Greg KH
     [not found]             ` <20251224115808.415753-4-Akshay.Gujar@harman.com>
2026-01-07 15:03               ` [PATCH v2 3/3] usb: hub: send enumeration failure uevent Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2026010733-robust-huntress-ce3a@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Akshay.Gujar@harman.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=naveen.v@harman.com \
    --cc=oneukum@suse.com \
    --cc=sankarkumar.krishnasamy@harman.com \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox