* [PATCH v5 0/1] PCI: hotplug: Add support for synthesizing slot uevents @ 2026-07-06 20:02 Ramesh Errabolu 2026-07-06 20:02 ` [PATCH v5 1/1] PCI: hotplug: Add 'uevent' sysfs attribute to trigger slot events Ramesh Errabolu 0 siblings, 1 reply; 3+ messages in thread From: Ramesh Errabolu @ 2026-07-06 20:02 UTC (permalink / raw) To: linux-pci Cc: linux-kernel, linux-s390, driver-core, Bjorn Helgaas, Lukas Wunner, Krzysztof Wilczyński, Leon Romanovsky, Niklas Schnelle, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Farhan Ali, Ramesh Errabolu Hi all, This patch adds support for synthesizing PCI hotplug slot uevents via a sysfs attribute. The patch has been rebased on top of the current upstream/devel branch and includes the feedback received during previous review rounds. The Reviewed-by and Tested-by tags from the previous revision have been retained. I'd appreciate feedback on the next steps in the review and merge process. Please let me know if any further changes are needed. Thanks, Ramesh Errabolu Ramesh Errabolu (1): PCI: hotplug: Add 'uevent' sysfs attribute to trigger slot events drivers/pci/hotplug/pci_hotplug_core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) -- 2.43.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v5 1/1] PCI: hotplug: Add 'uevent' sysfs attribute to trigger slot events 2026-07-06 20:02 [PATCH v5 0/1] PCI: hotplug: Add support for synthesizing slot uevents Ramesh Errabolu @ 2026-07-06 20:02 ` Ramesh Errabolu 2026-07-07 9:15 ` Niklas Schnelle 0 siblings, 1 reply; 3+ messages in thread From: Ramesh Errabolu @ 2026-07-06 20:02 UTC (permalink / raw) To: linux-pci Cc: linux-kernel, linux-s390, driver-core, Bjorn Helgaas, Lukas Wunner, Krzysztof Wilczyński, Leon Romanovsky, Niklas Schnelle, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Farhan Ali, Ramesh Errabolu 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@linux.ibm.com> Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> Tested-by: Niklas Schnelle <schnelle@linux.ibm.com> --- 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, + .store = uevent_write_file +}; + static ssize_t test_write_file(struct pci_slot *pci_slot, const char *buf, size_t count) { struct hotplug_slot *slot = pci_slot->hotplug; unsigned long ltest; u32 test; @@ -251,12 +266,17 @@ static int fs_add_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot) if (retval) dev_err(&pci_slot->bus->dev, "Error creating sysfs link (%d)\n", retval); kobject_put(kobj); } + retval = sysfs_create_file(&pci_slot->kobj, + &hotplug_slot_attr_uevent.attr); + if (retval) + goto exit_uevent; + if (has_power_file(slot)) { retval = sysfs_create_file(&pci_slot->kobj, &hotplug_slot_attr_power.attr); if (retval) goto exit_power; } @@ -303,19 +323,24 @@ static int fs_add_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot) sysfs_remove_file(&pci_slot->kobj, &hotplug_slot_attr_attention.attr); exit_attention: if (has_power_file(slot)) sysfs_remove_file(&pci_slot->kobj, &hotplug_slot_attr_power.attr); exit_power: + sysfs_remove_file(&pci_slot->kobj, + &hotplug_slot_attr_uevent.attr); +exit_uevent: sysfs_remove_link(&pci_slot->kobj, "module"); exit: return retval; } static void fs_remove_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot) { + sysfs_remove_file(&pci_slot->kobj, &hotplug_slot_attr_uevent.attr); + if (has_power_file(slot)) sysfs_remove_file(&pci_slot->kobj, &hotplug_slot_attr_power.attr); if (has_attention_file(slot)) sysfs_remove_file(&pci_slot->kobj, &hotplug_slot_attr_attention.attr); -- 2.43.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v5 1/1] PCI: hotplug: Add 'uevent' sysfs attribute to trigger slot events 2026-07-06 20:02 ` [PATCH v5 1/1] PCI: hotplug: Add 'uevent' sysfs attribute to trigger slot events Ramesh Errabolu @ 2026-07-07 9:15 ` Niklas Schnelle 0 siblings, 0 replies; 3+ messages in thread From: Niklas Schnelle @ 2026-07-07 9:15 UTC (permalink / raw) To: Ramesh Errabolu, linux-pci Cc: linux-kernel, linux-s390, driver-core, Bjorn Helgaas, Lukas Wunner, Krzysztof Wilczyński, Leon Romanovsky, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Farhan Ali 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@linux.ibm.com> > Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> > Tested-by: Niklas Schnelle <schnelle@linux.ibm.com> > --- > 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/ ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-07 9:16 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-06 20:02 [PATCH v5 0/1] PCI: hotplug: Add support for synthesizing slot uevents Ramesh Errabolu 2026-07-06 20:02 ` [PATCH v5 1/1] PCI: hotplug: Add 'uevent' sysfs attribute to trigger slot events Ramesh Errabolu 2026-07-07 9:15 ` Niklas Schnelle
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox