public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] PCI: Add write-only 'uevent' sysfs attribute for PCI slots
@ 2026-02-25 15:08 Ramesh Errabolu
  2026-02-26  8:34 ` Leon Romanovsky
  0 siblings, 1 reply; 10+ messages in thread
From: Ramesh Errabolu @ 2026-02-25 15:08 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, linux-s390, Bjorn Helgaas, Peter Oberparleiter,
	Matthew Rosato, Gerd Bayer, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Ramesh Errabolu

Add a new write-only 'uevent' attribute to PCI slot sysfs
entries. This provides a mechanism for userspace to explicitly
synthesize PCI slot uevents when needed.

For cold-plugged PCI devices, slots may be created before
udev is ready to receive events, causing the initial 'add'
uevents to be missed. As a result, slot specific udev
rules that define naming, permissions, and related policies,
are not applied at boot. Allowing userspace to resynthesize
the 'add' uevent ensures these rules are processed correctly.

The patch was validated by manually triggering PCI slot 'add'
uevents through the slot’s 'uevent' sysfs file and confirming
that udev received and processed those events. The following
command raises an 'add' uevent for a specific 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/slot.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 787311614e5b..cbc7cf6ab7ad 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -63,6 +63,15 @@ static ssize_t cur_speed_read_file(struct pci_slot *slot, char *buf)
 	return bus_speed_read(slot->bus->cur_bus_speed, buf);
 }
 
+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 void pci_slot_release(struct kobject *kobj)
 {
 	struct pci_dev *dev;
@@ -89,11 +98,14 @@ static struct pci_slot_attribute pci_slot_attr_max_speed =
 	__ATTR(max_bus_speed, S_IRUGO, max_speed_read_file, NULL);
 static struct pci_slot_attribute pci_slot_attr_cur_speed =
 	__ATTR(cur_bus_speed, S_IRUGO, cur_speed_read_file, NULL);
+static struct pci_slot_attribute pci_slot_attr_uevent =
+	__ATTR(uevent, S_IWUSR, NULL, uevent_write_file);
 
 static struct attribute *pci_slot_default_attrs[] = {
 	&pci_slot_attr_address.attr,
 	&pci_slot_attr_max_speed.attr,
 	&pci_slot_attr_cur_speed.attr,
+	&pci_slot_attr_uevent.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(pci_slot_default);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-03-06 15:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-25 15:08 [PATCH v1] PCI: Add write-only 'uevent' sysfs attribute for PCI slots Ramesh Errabolu
2026-02-26  8:34 ` Leon Romanovsky
2026-02-26 17:53   ` Ramesh Errabolu
2026-02-26 18:39     ` Leon Romanovsky
2026-02-26 19:31       ` Ramesh Errabolu
2026-02-26 19:51         ` Leon Romanovsky
2026-02-26 20:33           ` Ramesh Errabolu
2026-02-27 11:23       ` Peter Oberparleiter
2026-03-02 19:48         ` Leon Romanovsky
2026-03-06 15: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