* [PATCH v2 0/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events
@ 2026-04-16 21:39 Ramesh Errabolu
2026-04-16 21:39 ` [PATCH v2 1/1] " Ramesh Errabolu
0 siblings, 1 reply; 8+ messages in thread
From: Ramesh Errabolu @ 2026-04-16 21:39 UTC (permalink / raw)
To: linux-pci
Cc: linux-kernel, linux-s390, Bjorn Helgaas, Lukas Wunner,
Niklas Schnelle, Peter Oberparleiter, Matthew Rosato, Gerd Bayer,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Ramesh Errabolu
Hi all,
This is v2 of the patch adding write-only uevent
support for PCI slots. The original v1 was posted
in February 2026 and received valuable feedback from
Leon Romanovsky and others. This v2 addresses the feedback
and is rebased onto the current kernel tree.
Link to v1:
https://lore.kernel.org/all/20260225150815.81268-1-ramesh@linux.ibm.com/
Testing: Tested on s390x with multiple PCI slots
- Write-only uevent attribute is created for each slot
- Writing "add" triggers proper uevent generation
- udevadm-trigger successfully generates slot uevents
- Events are properly received by udev monitoring tools
Changes since v1 (February 2026):
- Improved commit message clarity, per reviewer feedback
- Rebased onto current kernel tree (v7.x)
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] 8+ messages in thread* [PATCH v2 1/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events 2026-04-16 21:39 [PATCH v2 0/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events Ramesh Errabolu @ 2026-04-16 21:39 ` Ramesh Errabolu 2026-04-17 9:53 ` Niklas Schnelle 2026-04-21 17:13 ` Krzysztof Wilczyński 0 siblings, 2 replies; 8+ messages in thread From: Ramesh Errabolu @ 2026-04-16 21:39 UTC (permalink / raw) To: linux-pci Cc: linux-kernel, linux-s390, Bjorn Helgaas, Lukas Wunner, Niklas Schnelle, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, 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> --- 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 @@ -176,6 +176,21 @@ static struct pci_slot_attribute hotplug_slot_attr_presence = { .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) { @@ -254,6 +269,11 @@ static int fs_add_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot) 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); @@ -306,6 +326,9 @@ static int fs_add_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot) 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; @@ -313,6 +336,8 @@ static int fs_add_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot) 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); -- 2.43.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events 2026-04-16 21:39 ` [PATCH v2 1/1] " Ramesh Errabolu @ 2026-04-17 9:53 ` Niklas Schnelle 2026-04-20 19:37 ` Ramesh Errabolu 2026-04-21 17:13 ` Krzysztof Wilczyński 1 sibling, 1 reply; 8+ messages in thread From: Niklas Schnelle @ 2026-04-17 9:53 UTC (permalink / raw) To: Ramesh Errabolu, linux-pci Cc: linux-kernel, linux-s390, Bjorn Helgaas, Lukas Wunner, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev On Thu, 2026-04-16 at 16:39 -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> > --- > drivers/pci/hotplug/pci_hotplug_core.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > Sorry for the review delay. This looks good to me and will really help with udev rule execution for devices which are discovered in standby state during boot and thus currently don't create any uevents. Of course to work by default this still requires a systemd/udev addition that I know you're also working on. Consequently, I tested the uevent synthesization with both slots with a configured (slot powered on) and standby (slot powered off) PCI function. Feel free to add: Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> Tested-by: Niklas Schnelle <schnelle@linux.ibm.com> Thanks, Niklas ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events 2026-04-17 9:53 ` Niklas Schnelle @ 2026-04-20 19:37 ` Ramesh Errabolu 0 siblings, 0 replies; 8+ messages in thread From: Ramesh Errabolu @ 2026-04-20 19:37 UTC (permalink / raw) To: Niklas Schnelle, linux-pci Cc: linux-kernel, linux-s390, Bjorn Helgaas, Lukas Wunner, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev Thanks for testing and also giving me the review-by Regards, Ramesh On 4/17/2026 4:53 AM, Niklas Schnelle wrote: > On Thu, 2026-04-16 at 16:39 -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> >> --- >> drivers/pci/hotplug/pci_hotplug_core.c | 25 +++++++++++++++++++++++++ >> 1 file changed, 25 insertions(+) >> > Sorry for the review delay. This looks good to me and will really help > with udev rule execution for devices which are discovered in standby > state during boot and thus currently don't create any uevents. Of > course to work by default this still requires a systemd/udev addition > that I know you're also working on. > > Consequently, I tested the uevent synthesization with both slots with a > configured (slot powered on) and standby (slot powered off) PCI > function. > > Feel free to add: > > Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> > Tested-by: Niklas Schnelle <schnelle@linux.ibm.com> > > Thanks, > Niklas ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events 2026-04-16 21:39 ` [PATCH v2 1/1] " Ramesh Errabolu 2026-04-17 9:53 ` Niklas Schnelle @ 2026-04-21 17:13 ` Krzysztof Wilczyński 2026-04-21 21:38 ` Ramesh Errabolu 1 sibling, 1 reply; 8+ messages in thread From: Krzysztof Wilczyński @ 2026-04-21 17:13 UTC (permalink / raw) To: Ramesh Errabolu Cc: linux-pci, linux-kernel, linux-s390, Bjorn Helgaas, Lukas Wunner, Niklas Schnelle, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev Hello, > +static struct pci_slot_attribute hotplug_slot_attr_uevent = { > + .attr = {.name = "uevent", .mode = S_IFREG | 0200}, > + .show = NULL, > + .store = uevent_write_file > +}; I think, you could use the __ATTR_WO() macro here. Thank you! Krzysztof ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events 2026-04-21 17:13 ` Krzysztof Wilczyński @ 2026-04-21 21:38 ` Ramesh Errabolu 2026-04-22 4:44 ` Krzysztof Wilczyński 0 siblings, 1 reply; 8+ messages in thread From: Ramesh Errabolu @ 2026-04-21 21:38 UTC (permalink / raw) To: Krzysztof Wilczyński Cc: linux-pci, linux-kernel, linux-s390, Bjorn Helgaas, Lukas Wunner, Niklas Schnelle, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev On 4/21/2026 12:13 PM, Krzysztof Wilczyński wrote: > Hello, > >> +static struct pci_slot_attribute hotplug_slot_attr_uevent = { >> + .attr = {.name = "uevent", .mode = S_IFREG | 0200}, >> + .show = NULL, >> + .store = uevent_write_file >> +}; > I think, you could use the __ATTR_WO() macro here. Use of the suggested macro is not appropriate > > Thank you! > > Krzysztof ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events 2026-04-21 21:38 ` Ramesh Errabolu @ 2026-04-22 4:44 ` Krzysztof Wilczyński [not found] ` <742b8820-4bfe-40ef-85a9-5704af038ee1@linux.ibm.com> 0 siblings, 1 reply; 8+ messages in thread From: Krzysztof Wilczyński @ 2026-04-22 4:44 UTC (permalink / raw) To: Ramesh Errabolu Cc: linux-pci, linux-kernel, linux-s390, Bjorn Helgaas, Lukas Wunner, Niklas Schnelle, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev Hello, > > > +static struct pci_slot_attribute hotplug_slot_attr_uevent = { > > > + .attr = {.name = "uevent", .mode = S_IFREG | 0200}, > > > + .show = NULL, > > > + .store = uevent_write_file > > > +}; > > I think, you could use the __ATTR_WO() macro here. > Use of the suggested macro is not appropriate Just to expand on the "not appropriate" bit here. Not wanting to change the name to have the _store suffix would be fine. The __ATTR() would work here. But, this file is old and wanting to keep the style aligned with rest of it would be fine, too. So, both of these reasons would be fine, to avoid using any new macro. Thank you! Krzysztof ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <742b8820-4bfe-40ef-85a9-5704af038ee1@linux.ibm.com>]
* Re: [PATCH v2 1/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events [not found] ` <742b8820-4bfe-40ef-85a9-5704af038ee1@linux.ibm.com> @ 2026-04-22 17:13 ` Krzysztof Wilczyński 0 siblings, 0 replies; 8+ messages in thread From: Krzysztof Wilczyński @ 2026-04-22 17:13 UTC (permalink / raw) To: Ramesh Errabolu Cc: linux-pci, linux-kernel, linux-s390, Bjorn Helgaas, Lukas Wunner, Niklas Schnelle, Peter Oberparleiter, Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik, Alexander Gordeev Hello, > > > > > +static struct pci_slot_attribute hotplug_slot_attr_uevent = { > > > > > + .attr = {.name = "uevent", .mode = S_IFREG | 0200}, > > > > > + .show = NULL, > > > > > + .store = uevent_write_file > > > > > +}; > > > > I think, you could use the __ATTR_WO() macro here. > > > Use of the suggested macro is not appropriate > > Just to expand on the "not appropriate" bit here. > > > > Not wanting to change the name to have the _store suffix would be fine. > > > > The __ATTR() would work here. But, this file is old and wanting to > > keep the style aligned with rest of it would be fine, too. > > > > So, both of these reasons would be fine, to avoid using any new macro. [...] > > Hello Krzysztof, let me first apologize to you in the way I said it. I > should have elaborated the reasoning the way you did. I am open to making > the changing if anyone else feels it is a better way. Oh, no worries. No hard feelings. :) I just wanted to add a little bit more details for posterity. Thank you! Krzysztof ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-04-22 17:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 21:39 [PATCH v2 0/1] PCI/hotplug: Add 'uevent' sysfs attribute to trigger slot events Ramesh Errabolu
2026-04-16 21:39 ` [PATCH v2 1/1] " Ramesh Errabolu
2026-04-17 9:53 ` Niklas Schnelle
2026-04-20 19:37 ` Ramesh Errabolu
2026-04-21 17:13 ` Krzysztof Wilczyński
2026-04-21 21:38 ` Ramesh Errabolu
2026-04-22 4:44 ` Krzysztof Wilczyński
[not found] ` <742b8820-4bfe-40ef-85a9-5704af038ee1@linux.ibm.com>
2026-04-22 17:13 ` Krzysztof Wilczyński
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox