]> git.ipfire.org Git - thirdparty/linux.git/commit
PCI/sysfs: Limit BAR resize attribute scope to platforms with PCI mmap
authorKrzysztof Wilczyński <kwilczynski@kernel.org>
Fri, 8 May 2026 04:35:43 +0000 (04:35 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 20:19:09 +0000 (15:19 -0500)
commitc9b4bd6c0839c855b7cc221af0283c1900036fc6
tree7bc39760d3e451a3c49cf16c8123ea4925d28541
parent2800a911ced1540baa78de7494218aaf1c7dc4fa
PCI/sysfs: Limit BAR resize attribute scope to platforms with PCI mmap

Currently, __resource_resize_store() uses sysfs_remove_groups() and
sysfs_create_groups() on pci_dev_resource_attr_groups to tear down and
recreate the resourceN files after a BAR resize, so the updated BAR sizes
are visible in sysfs.

The resourceN files only exist on platforms that define HAVE_PCI_MMAP or
ARCH_GENERIC_PCI_MMAP_RESOURCE.  On platforms that define neither,
pci_dev_resource_attr_groups is NULL and the sysfs_remove_groups() and
sysfs_create_groups() calls in __resource_resize_store() become no-ops.

Resizable BAR (ReBAR) is a PCI Express Extended Capability
(PCI_EXT_CAP_ID_REBAR) that requires PCIe extended config space.  Every
PCIe-capable architecture defines HAVE_PCI_MMAP or
ARCH_GENERIC_PCI_MMAP_RESOURCE (via arch headers or the asm-generic/pci.h
fallback).  Architectures without either only support conventional PCI and
cannot have any ReBAR-capable devices.

Move the resize show and store helpers, the per-BAR attribute definitions,
and the attribute group behind the existing #ifdef HAVE_PCI_MMAP ||
ARCH_GENERIC_PCI_MMAP_RESOURCE guard, and fold the group reference in
pci_dev_groups[] into the existing #if block.

Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Link: https://patch.msgid.link/20260508043543.217179-25-kwilczynski@kernel.org
drivers/pci/pci-sysfs.c