]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
PCI/sysfs: Ensure devices are powered for config reads
authorBrian Norris <briannorris@google.com>
Wed, 24 Sep 2025 16:57:11 +0000 (09:57 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 24 Sep 2025 19:02:39 +0000 (14:02 -0500)
commit48991e4935078b05f80616c75d1ee2ea3ae18e58
tree98e1deac5e1142e9e41b485f9c928c159c7ef4b2
parent299fad4133677b845ce962f78c9cf75bded63f61
PCI/sysfs: Ensure devices are powered for config reads

The "max_link_width", "current_link_speed", "current_link_width",
"secondary_bus_number", and "subordinate_bus_number" sysfs files all access
config registers, but they don't check the runtime PM state. If the device
is in D3cold or a parent bridge is suspended, we may see -EINVAL, bogus
values, or worse, depending on implementation details.

Wrap these access in pci_config_pm_runtime_{get,put}() like most of the
rest of the similar sysfs attributes.

Notably, "max_link_speed" does not access config registers; it returns a
cached value since d2bd39c0456b ("PCI: Store all PCIe Supported Link
Speeds").

Fixes: 56c1af4606f0 ("PCI: Add sysfs max_link_speed/width, current_link_speed/width, etc")
Signed-off-by: Brian Norris <briannorris@google.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250924095711.v2.1.Ibb5b6ca1e2c059e04ec53140cd98a44f2684c668@changeid
drivers/pci/pci-sysfs.c