Re: [PATCH v5 1/1] PCI: hotplug: Add 'uevent' sysfs attribute to trigger slot events

From: Niklas Schnelle

Date: Tue Jul 07 2026 - 05:24:40 EST


On Mon, 2026-07-06 at 15:02 -0500, Ramesh Errabolu wrote:
> Add a write-only 'uevent' sysfs attribute for synthesizing
> uevents for a PCI slot. This extends the existing uevent
> support which emits a KOBJ_ADD uevent in pci_hp_add() with
> the ability to replay such uevents for cold plugged devices.
> As such events are only emitted by hotplug capable PCI slots
> so is the support for synthesizing them.
>
> The change was validated by manually triggering 'add' uevent
> for a specific hotplug PCI slot:
>
> $ echo "add $(uuidgen)" | sudo tee \
> /sys/bus/pci/slots/<slot-id>/uevent
>
> Signed-off-by: Ramesh Errabolu <ramesh@xxxxxxxxxxxxx>
> Reviewed-by: Niklas Schnelle <schnelle@xxxxxxxxxxxxx>
> Tested-by: Niklas Schnelle <schnelle@xxxxxxxxxxxxx>
> ---
> drivers/pci/hotplug/pci_hotplug_core.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
> index fadcf98a8a66..c3634b1cc7a8 100644
> --- a/drivers/pci/hotplug/pci_hotplug_core.c
> +++ b/drivers/pci/hotplug/pci_hotplug_core.c
> @@ -173,12 +173,27 @@ static ssize_t presence_read_file(struct pci_slot *pci_slot, char *buf)
>
> static struct pci_slot_attribute hotplug_slot_attr_presence = {
> .attr = {.name = "adapter", .mode = S_IFREG | S_IRUGO},
> .show = presence_read_file,
> };
>
> +static ssize_t uevent_write_file(struct pci_slot *slot,
> + const char *buf, size_t len)
> +{
> + int rc;
> +
> + rc = kobject_synth_uevent(&slot->kobj, buf, len);
> + return rc ? rc : len;
> +}
> +
> +static struct pci_slot_attribute hotplug_slot_attr_uevent = {
> + .attr = {.name = "uevent", .mode = S_IFREG | 0200},
> + .show = NULL,

As Bjorn Helgaas noted on v4 this ".show = NULL" is unnecessary. This
feedback should have been incorporated. And without that change there
is, as far as I can tell, no change vs v4 so this should have been
"[PATCH RESEND]" which Bjorn also told you in the same mail.

Thanks,
Niklas

[0] https://lore.kernel.org/linux-pci/20260521144853.GA163149@bhelgaas/