From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:35:58
Hello,
This series converts every dynamically allocated PCI sysfs attribute to
a static const definition. After the full series, pci_sysfs_init() and
sysfs_initialized are gone, and every sysfs file is created by the
driver model at device_add() time.
Currently, the PCI resource files (resourceN, resourceN_wc) and the
legacy bus files (legacy_io, legacy_mem) are created dynamically
from two unsynchronised paths:
Path A: late_initcall
pci_sysfs_init() (late_initcall)
sysfs_initialized = 1
for_each_pci_dev()
pci_create_sysfs_dev_files()
sysfs_create_bin_file() (resourceN, resourceN_wc)
pci_find_next_bus()
pci_create_legacy_files()
sysfs_create_bin_file() (legacy_io, legacy_mem)
Path B: device registration / hotplug
pci_bus_add_devices()
pci_bus_add_device()
pci_create_sysfs_dev_files()
if (!sysfs_initialized) <- only guard
return
sysfs_create_bin_file() (resourceN, resourceN_wc)
On most ACPI systems this does not race because PCI enumeration
completes at subsys_initcall time, before pci_sysfs_init() runs:
subsys_initcall (level 4):
acpi_pci_root_add()
pci_bus_add_device()
pci_create_sysfs_dev_files()
if (!sysfs_initialized) <- variable not yet set
return -EACCES
late_initcall (level 7):
pci_sysfs_init()
sysfs_initialized = 1
for_each_pci_dev()
pci_create_sysfs_dev_files() <- creates the files, no race
On Devicetree platforms the host controller is a platform driver that
probes via the driver model, often on a workqueue, and overlaps with the
late_initcall:
CPU 0 (late_initcall) CPU 1 (driver probe)
--------------------------- ----------------------------
pci_sysfs_init()
sysfs_initialized = 1
for_each_pci_dev() pci_bus_add_device()
pci_create_sysfs_dev_files() pci_create_sysfs_dev_files()
sysfs_create_bin_file() sysfs_create_bin_file()
-> "duplicate filename"
The same happens on ACPI when probing is asynchronous (hv_pci on
Azure, RISC-V with ACPI).
The duplicate causes sysfs_create_bin_file() to fail with -EEXIST.
pci_create_resource_files() then calls pci_remove_resource_files() in
its error unwind, tearing down files the other thread created and
still references through pdev->res_attr[]. This has caused kernel
panics on i.MX6 and boot failures on other platforms.
Several different fixes have been proposed over the years: reordering
the sysfs_initialized assignment, adding locks, checking
pci_dev_is_added(), setting pdev->res_attr[] to NULL after kfree
(which only prevents a double-free on the teardown path, not the
error unwind removing the other thread's files). None would address the
root cause.
This has been reported a few times:
- https://lore.kernel.org/linux-pci/20250702155112.40124-1-heshuan@bytedance.com/
- https://lore.kernel.org/linux-pci/b51519d6-ce45-4b6d-8135-c70169bd110e@h-partners.com/
- https://lore.kernel.org/linux-pci/1702093576-30405-1-git-send-email-ssengar@linux.microsoft.com/
- https://lore.kernel.org/linux-pci/SY0P300MB04687548090B73E40AF97D8897B82@SY0P300MB0468.AUSP300.PROD.OUTLOOK.COM/
- https://lore.kernel.org/linux-pci/20230105174736.GA1154719@bhelgaas/
- https://lore.kernel.org/linux-pci/m3eebg9puj.fsf@t19.piap.pl/
- https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/
- https://lore.kernel.org/linux-pci/1366196798-15929-1-git-send-email-artem.savkov@gmail.com/
- https://bugzilla.kernel.org/show_bug.cgi?id=215515
- https://bugzilla.kernel.org/show_bug.cgi?id=216888
With static attributes the driver model creates sysfs entries once per
device at device_add() time, under the device lock, eliminating the
late_initcall iteration and the race along with it.
Krzysztof
---
Changes in v7:
https://lore.kernel.org/linux-pci/20260422161407.118748-1-kwilczynski@kernel.org/
- Addded Alex Williamson (author of the resource resize sysfs
attributes) to the list of recipients for visibility.
- Split pci_llseek_resource() into pci_llseek_resource() and
pci_llseek_resource_legacy() since legacy attributes operate
on a struct pci_bus where to_pci_dev() would be invalid,
as per Bjorn Helgaas' feedback.
- Moved each llseek variant inside its respective #ifdef guard
during the corresponding dynamic-to-static conversion commit,
dropping the __maybe_unused annotations.
- Extended the WARN macro removal to also cover __legacy_mmap_fits().
- Updated commit message of patch 18, so that it correctly mentions
pci_stop_dev() rather than pci_stop_bus_device().
- Updated commit message of patch 24 to clarify the indirect
relationship between ReBAR and the HAVE_PCI_MMAP and/or
ARCH_GENERIC_PCI_MMAP_RESOURCE guards.
Changes in v6:
https://lore.kernel.org/linux-pci/20260416180107.777065-1-kwilczynski@kernel.org/
- Fixed commit message for patch 13, removing reference to
pci_resource_flags() which was no longer changed there.
- Added a new patch (24) to move the BAR resource resize
(ReBAR) support behind existing PCI mmap #ifdef guard,
so that the code is not included on architectures that
do not support resource resizing (i.e., Alpha, etc.).
Changes in v5:
https://lore.kernel.org/linux-pci/20260411080148.471335-1-kwilczynski@kernel.org/
- Added new Tested-by, Reviewed-by, and Acked-by tags.
- Used the existing _io function names in the static macro
definitions, deferring the rename to the conversion commit
where it belongs, to avoid a forward reference across
commits. This was reported by Sashiko, see:
https://sashiko.dev/#/patchset/20260411080148.471335-1-kwilczynski%40kernel.org?part=6
- Folded the __resource_resize_store() conversion into the
main static attributes commit so the resize path is never
broken between commits. This was reported by Sashiko, see:
https://sashiko.dev/#/patchset/20260410055040.39233-1-kwilczynski%40kernel.org?part=6https://sashiko.dev/#/patchset/20260411080148.471335-1-kwilczynski%40kernel.org?part=7
- Dropped the unnecessary parentheses cleanup from the Alpha
BAR index commit, as the line is replaced two commits later
anyway, as per Ilpo Järvinen's feedback.
- Squashed the Alpha accessor macro and cleanup commits into
one, using pci_resource_is_mem() directly instead of the
intermediate pci_resource_flags() step, as per Ilpo
Järvinen's feedback.
- Moved the raw literal conversion in pci_create_legacy_files()
into the macro definition commit, so the macros and their
usage are introduced together, as per Ilpo Järvinen's
feedback.
- Removed unnecessary backslash line continuation from the
ternary in pci_mmap_legacy_page_range().
- Kept pci_resource_len() for visibility checks instead of
resource_assigned(). The static is_visible() callback
runs at device_add() time during the PCI enumeration,
before the pci_assign_unassigned_bus_resources() populates
res->parent, as such, resource_assigned() returned false
for every BAR, hiding all resource files. This is related
to review feedback from Ilpo Järvinen.
Changes in v4:
https://lore.kernel.org/linux-pci/20260410055040.39233-1-kwilczynski@kernel.org/
- Added new Reviewed-by tags.
- Added pci_resource_is_io() and pci_resource_is_mem() helpers
for resource type checks, replacing the open-coded bitwise
flag tests in pci_mmap_resource(), pci_resource_io(), and
Alpha's pci_mmap_resource(), as per Ilpo Järvinen's
suggestion.
- Split the __pci_mmap_fits() cleanup into two patches. An
overflow fix for zero-length BARs, which now includes a
Fixes: tag referencing the original Alpha PCI sysfs commit,
and the WARN macro removal is a separate cleanup as per Ilpo
Järvinen's suggestion.
- Added a missing Fixes: tag to the Alpha lockdown check,
referencing the commit that added the check to the generic
path but missed Alpha's implementation.
- Added PCI_LEGACY_IO_SIZE and PCI_LEGACY_MEM_SIZE macros to
replace the raw literals used for legacy address space sizes.
These are used in both Alpha's pci_mmap_legacy_page_range()
and the static legacy attribute definitions, as per Ilpo
Järvinen's suggestion.
- Replaced sysfs_update_groups() in the BAR resize path with
sysfs_remove_groups() before the resize and sysfs_create_groups()
after, restoring the original teardown before BAR resize
ordering. This was reported by Sashiko, see:
https://sashiko.dev/#/patchset/20260410055040.39233-1-kwilczynski%40kernel.org?part=7
- Defined pci_dev_resource_attr_groups as a NULL macro when
HAVE_PCI_MMAP and ARCH_GENERIC_PCI_MMAP_RESOURCE are both
absent, so the resize path compiles unconditionally without
#ifdef guards in the function body. This was reported by
Sashiko, see:
https://sashiko.dev/#/patchset/20260410055040.39233-1-kwilczynski%40kernel.org?part=7
- Moved the pci_legacy_has_sparse() prototype into the patch
that introduces the function, alongside the existing
pci_adjust_legacy_attr() declaration, to fix a bisection
issue where Alpha would warn on -Wmissing-prototypes.
This was reported by Sashiko, see:
https://sashiko.dev/#/patchset/20260410055040.39233-1-kwilczynski%40kernel.org?part=18
Changes in v3:
https://lore.kernel.org/linux-pci/20210910202623.2293708-1-kw@linux.com/
- Updated for modern kernel releases and expanded scope. The
v2 only covered the generic resource files. This version
also converts Alpha's sparse/dense resource files and the
legacy bus attributes, removing pci_sysfs_init() entirely.
- Split the single macro definition into three distinct ones
(per I/O, UC, and WC), to make sure that each carries only
the callbacks its resource type needs.
- Updated to use the new .bin_size callback, as the attributes
are const, to replace using a->size directly, which was not
ideal. This required changes to pci_llseek_resource(), to
ensure that it would work for device and bus-level attributes.
- Updated the __resource_resize_store() to include CAP_SYS_ADMIN
capabilities check.
- Added the security_locked_down() check to Alpha's
pci_mmap_resource(), to align with other architectures.
Changes in v2:
https://lore.kernel.org/linux-pci/20210825212255.878043-1-kw@linux.com/
- Refactored code so that the macros, helpers and internal
functions can be used to correctly leverage the read(),
write() and mmap() callbacks rather than to use the
.is_bin_visible() callback to set up sysfs objects
internals as this is not supported.
- Refactored some if-statements to check for a resource
flag first, and then call either arch_can_pci_mmap_io()
or arch_can_pci_mmap_wc(), plus store result of testing
for IORESOURCE_MEM and IORESOURCE_PREFETCH flags into
a boolean variable, as per Bjorn Helgaas' suggestion.
- Renamed pci_read_resource_io() and pci_write_resource_io()
callbacks so that these are not specifically tied to I/O
BARs read() and write() operations also as per Bjorn
Helgaas' suggestion.
- Updated style for code handling bitwise operations to
match the style that is preferred as per Bjorn Helgaas'
suggestion.
- Updated commit messages adding more details about the
implementation as requested by Bjorn Helgaas.
Krzysztof Wilczyński (24):
PCI/sysfs: Use PCI resource accessor macros
PCI: Add pci_resource_is_io() and pci_resource_is_mem() helpers
PCI/sysfs: Only allow supported resource types in I/O and MMIO helpers
PCI/sysfs: Split pci_llseek_resource() for device and legacy
attributes
PCI/sysfs: Add CAP_SYS_ADMIN check to __resource_resize_store()
PCI/sysfs: Add static PCI resource attribute macros
PCI/sysfs: Convert PCI resource files to static attributes
PCI/sysfs: Warn about BAR resize failure in __resource_resize_store()
PCI/sysfs: Add stubs for pci_{create,remove}_sysfs_dev_files()
PCI/sysfs: Limit pci_sysfs_init() late_initcall compile scope
alpha/PCI: Add security_locked_down() check to pci_mmap_resource()
alpha/PCI: Use BAR index in sysfs attr->private instead of resource
pointer
alpha/PCI: Use PCI resource accessor macros
alpha/PCI: Fix __pci_mmap_fits() overflow for zero-length BARs
alpha/PCI: Remove WARN from __pci_mmap_fits() and __legacy_mmap_fits()
alpha/PCI: Add static PCI resource attribute macros
alpha/PCI: Convert resource files to static attributes
PCI/sysfs: Remove pci_{create,remove}_sysfs_dev_files()
PCI: Add macros for legacy I/O and memory address space sizes
alpha/PCI: Compute legacy size in pci_mmap_legacy_page_range()
PCI/sysfs: Add __weak pci_legacy_has_sparse() helper
PCI/sysfs: Convert legacy I/O and memory attributes to static
definitions
PCI/sysfs: Remove pci_create_legacy_files() and pci_sysfs_init()
PCI/sysfs: Limit BAR resize attribute scope to platforms with PCI mmap
arch/alpha/include/asm/pci.h | 13 +-
arch/alpha/kernel/pci-sysfs.c | 385 +++++++++++----------
arch/powerpc/include/asm/pci.h | 2 -
drivers/pci/bus.c | 1 -
drivers/pci/pci-sysfs.c | 592 +++++++++++++++++++--------------
drivers/pci/pci.h | 16 +-
drivers/pci/probe.c | 6 -
drivers/pci/remove.c | 3 -
include/linux/pci.h | 39 ++-
9 files changed, 589 insertions(+), 468 deletions(-)
--
2.54.0
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:35:59
Replace direct pdev->resource[] accesses with pci_resource_n(),
and pdev->resource[].flags accesses with pci_resource_flags().
No functional changes intended.
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:36:11
Add helpers to check whether a PCI resource is of I/O port or
memory type. These replace the open-coded pci_resource_flags()
with IORESOURCE_IO and IORESOURCE_MEM pattern used across the
tree.
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
include/linux/pci.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
@@ -2300,6 +2300,31 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);CONCATENATE(__pci_dev_for_each_res,COUNT_ARGS(__VA_ARGS__))\(dev,res,__VA_ARGS__)+/**+*pci_resource_is_io-checkifaPCIresourceisofI/Oporttype.+*@dev:PCIdevicetocheck.+*@resno:Theresourcenumber(BARindex)tocheck.+*+*ReturnstrueiftheresourcetypeisI/Oport.+*/+staticinlineboolpci_resource_is_io(conststructpci_dev*dev,intresno)+{+returnresource_type(pci_resource_n(dev,resno))==IORESOURCE_IO;+}++/**+*pci_resource_is_mem-checkifaPCIresourceisofmemorytype.+*@dev:PCIdevicetocheck.+*@resno:Theresourcenumber(BARindex)tocheck.+*+*Returnstrueiftheresourcetypeismemory,including+*prefetchablememory.+*/+staticinlineboolpci_resource_is_mem(conststructpci_dev*dev,intresno)+{+returnresource_type(pci_resource_n(dev,resno))==IORESOURCE_MEM;+}+/**Similartothehelpersabove,thesemanipulateper-pci_dev*driver-specificdata.Theyarereallyjustawrapperaround
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:36:20
Currently, when the sysfs attributes for PCI resources are added
dynamically, the resource access callbacks are only set when the
underlying BAR type matches, using .read and .write for IORESOURCE_IO,
and .mmap for IORESOURCE_MEM or IORESOURCE_IO with arch_can_pci_mmap_io()
support. As such, when the callback is not set, the operation inherently
fails.
After the conversion to static attributes, visibility callbacks will
control which resource files appear for each BAR, but the callbacks
themselves will always be set.
Thus, add a type check to pci_resource_io() and pci_mmap_resource()
to return -EIO for an unsupported resource type.
Use the new pci_resource_is_io() and pci_resource_is_mem() helpers
for the type checks, replacing the open-coded bitwise flag tests and
also drop the local struct resource pointer in pci_mmap_resource().
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:36:27
Both legacy and resource attributes set .f_mapping = iomem_get_mapping,
so the default generic_file_llseek() would consult iomem_inode for the
file size, which knows nothing about the attribute. That is why custom
llseek callbacks exist.
Currently, the legacy and resource attributes have .size set at creation
time, as such, using the attr->size is sufficient. However, the upcoming
static resource attributes will have .size == 0 set, since they are const,
and the .bin_size callback will be used to provide the real size to kernfs
instead.
The legacy attributes operate on a struct pci_bus, not struct pci_dev,
so calling to_pci_dev() on them would be invalid.
Thus, split pci_llseek_resource() into two functions:
- pci_llseek_resource(), which derives the file size from the BAR
using pci_resource_len().
- pci_llseek_resource_legacy(), which uses attr->size directly.
Update the dynamic legacy attribute creation to use the new
pci_llseek_resource_legacy() callback.
The original pci_llseek_resource() was added in commit 24de09c16f97
("PCI: Implement custom llseek for sysfs resource entries").
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:36:34
Currently, the __resource_resize_store() allows writing to the
resourceN_resize sysfs attribute to change a BAR's size without
checking for capabilities, currently relying only on the file
access check.
Resizing a BAR modifies PCI device configuration and can disrupt
active drivers. After the upcoming conversion to static attributes,
it will also trigger resource file updates via sysfs_update_groups().
Thus, add a CAP_SYS_ADMIN check to prevent unprivileged users from
performing BAR resize operations.
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 3 +++
1 file changed, 3 insertions(+)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:36:42
Add three macros for declaring static binary attributes for PCI
resource files:
- pci_dev_resource_io_attr(), for I/O BAR resources (read/write)
- pci_dev_resource_uc_attr(), for memory BAR resources (mmap uncached)
- pci_dev_resource_wc_attr(), for write-combine resources (mmap WC)
Each macro only sets the callbacks its resource type needs. The I/O
macro conditionally includes mmap support via __PCI_RESOURCE_IO_MMAP_ATTRS
on architectures where arch_can_pci_mmap_io() is true at compile time
(such as PowerPC, SPARC, and Xtensa).
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:36:50
Currently, the PCI resource files (resourceN, resourceN_wc) are
dynamically created by pci_create_sysfs_dev_files(), called from
both pci_bus_add_device() and the pci_sysfs_init() late_initcall,
with only a sysfs_initialized flag for synchronisation. This has
caused "duplicate filename" warnings and boot panics when both
paths race on the same device.
This is especially likely on Devicetree-based platforms, where the
PCI host controllers are platform drivers that probe via the driver
model, which can happen during or after the late_initcall. As such,
pci_bus_add_device() and pci_sysfs_init() are more likely to overlap.
Thus, convert to static const attributes with three attribute groups
(I/O, UC, WC), each with an .is_bin_visible callback that checks
resource flags, BAR length, and non_mappable_bars. A .bin_size
callback provides pci_resource_len() to the kernfs node for correct
stat and lseek behaviour.
As part of this conversion:
- Rename pci_read_resource_io() and pci_write_resource_io() to
pci_read_resource() and pci_write_resource() since the callbacks
are no longer I/O-specific in the static attribute context.
- Update __resource_resize_store() to use sysfs_create_groups() and
sysfs_remove_groups(), which re-evaluates visibility and runs the
.bin_size callback for the static resource attribute groups.
- Remove pci_create_resource_files(), pci_remove_resource_files(),
and pci_create_attr() which are no longer needed.
- Move the __weak stubs outside the #if guard so they remain
available for callers converted in subsequent commits.
Platforms that do not define the HAVE_PCI_MMAP macro or the
ARCH_GENERIC_PCI_MMAP_RESOURCE macro, such as Alpha architecture,
continue using their platform-specific resource file creation.
For reference, the dynamic creation dates back to the pre-Git era:
https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/drivers/pci/pci-sysfs.c?id=42298be0eeb5ae98453b3374c36161b05a46c5dc
The write-combine support was added in commit 45aec1ae72fc ("x86: PAT
export resource_wc in pci sysfs").
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 285 +++++++++++++++++++++-------------------
include/linux/pci.h | 2 -
2 files changed, 152 insertions(+), 135 deletions(-)
@@ -1238,129 +1237,144 @@ static const struct bin_attribute dev_resource##_bar##_wc_attr = { \.mmap=pci_mmap_resource_wc,\}-/**-*pci_remove_resource_files-cleanupresourcefiles-*@pdev:devtocleanup-*-*Ifwecreatedresourcefilesfor@pdev,removethemfromsysfsand-*freetheirresources.-*/-staticvoidpci_remove_resource_files(structpci_dev*pdev)+staticinlineumode_t+__pci_resource_attr_is_visible(structkobject*kobj,+conststructbin_attribute*a,+intbar,boolwrite_combine,+unsignedlongflags){-inti;+structpci_dev*pdev=to_pci_dev(kobj_to_dev(kobj));-for(i=0;i<PCI_STD_NUM_BARS;i++){-structbin_attribute*res_attr;--res_attr=pdev->res_attr[i];-if(res_attr){-sysfs_remove_bin_file(&pdev->dev.kobj,res_attr);-kfree(res_attr);-}--res_attr=pdev->res_attr_wc[i];-if(res_attr){-sysfs_remove_bin_file(&pdev->dev.kobj,res_attr);-kfree(res_attr);-}-}-}--staticintpci_create_attr(structpci_dev*pdev,intnum,intwrite_combine)-{-/* allocate attribute structure, piggyback attribute name */-intname_len=write_combine?13:10;-structbin_attribute*res_attr;-char*res_attr_name;-intretval;--res_attr=kzalloc(sizeof(*res_attr)+name_len,GFP_ATOMIC);-if(!res_attr)-return-ENOMEM;--res_attr_name=(char*)(res_attr+1);--sysfs_bin_attr_init(res_attr);-if(write_combine){-sprintf(res_attr_name,"resource%d_wc",num);-res_attr->mmap=pci_mmap_resource_wc;-}else{-sprintf(res_attr_name,"resource%d",num);-if(pci_resource_flags(pdev,num)&IORESOURCE_IO){-res_attr->read=pci_read_resource_io;-res_attr->write=pci_write_resource_io;-if(arch_can_pci_mmap_io())-res_attr->mmap=pci_mmap_resource_uc;-}else{-res_attr->mmap=pci_mmap_resource_uc;-}-}-if(res_attr->mmap){-res_attr->f_mapping=iomem_get_mapping;-/*-*generic_file_llseek()consultsf_mapping->hosttodetermine-*thefilesize.Asiomem_inodeknowsnothingaboutthe-*attribute,it'snotgoingtowork,sooverrideitaswell.-*/-res_attr->llseek=pci_llseek_resource;-}-res_attr->attr.name=res_attr_name;-res_attr->attr.mode=0600;-res_attr->size=pci_resource_len(pdev,num);-res_attr->private=(void*)(unsignedlong)num;-retval=sysfs_create_bin_file(&pdev->dev.kobj,res_attr);-if(retval){-kfree(res_attr);-returnretval;-}--if(write_combine)-pdev->res_attr_wc[num]=res_attr;-else-pdev->res_attr[num]=res_attr;--return0;-}--/**-*pci_create_resource_files-createresourcefilesinsysfsfor@dev-*@pdev:devinquestion-*-*Walktheresourcesin@pdevcreatingfilesforeachresourceavailable.-*/-staticintpci_create_resource_files(structpci_dev*pdev)-{-inti;-intretval;--/* Skip devices with non-mappable BARs */if(pdev->non_mappable_bars)return0;-/* Expose the PCI resources from this device as files */-for(i=0;i<PCI_STD_NUM_BARS;i++){+if(!pci_resource_len(pdev,bar))+return0;-/* skip empty resources */-if(!pci_resource_len(pdev,i))-continue;+if((pci_resource_flags(pdev,bar)&flags)!=flags)+return0;-retval=pci_create_attr(pdev,i,0);-/* for prefetchable resources, create a WC mappable file */-if(!retval&&arch_can_pci_mmap_wc()&&-pci_resource_flags(pdev,i)&IORESOURCE_PREFETCH)-retval=pci_create_attr(pdev,i,1);-if(retval){-pci_remove_resource_files(pdev);-returnretval;-}-}-return0;+if(write_combine&&!arch_can_pci_mmap_wc())+return0;++returna->attr.mode;}-#else /* !(defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)) */-int__weakpci_create_resource_files(structpci_dev*dev){return0;}-void__weakpci_remove_resource_files(structpci_dev*dev){return;}++staticumode_tpci_dev_resource_io_is_visible(structkobject*kobj,+conststructbin_attribute*a,+intn)+{+return__pci_resource_attr_is_visible(kobj,a,n,false,+IORESOURCE_IO);+}++staticumode_tpci_dev_resource_uc_is_visible(structkobject*kobj,+conststructbin_attribute*a,+intn)+{+return__pci_resource_attr_is_visible(kobj,a,n,false,+IORESOURCE_MEM);+}++staticumode_tpci_dev_resource_wc_is_visible(structkobject*kobj,+conststructbin_attribute*a,+intn)+{+return__pci_resource_attr_is_visible(kobj,a,n,true,+IORESOURCE_MEM|IORESOURCE_PREFETCH);+}++staticsize_tpci_dev_resource_bin_size(structkobject*kobj,+conststructbin_attribute*a,+intn)+{+structpci_dev*pdev=to_pci_dev(kobj_to_dev(kobj));++returnpci_resource_len(pdev,n);+}++pci_dev_resource_io_attr(0);+pci_dev_resource_io_attr(1);+pci_dev_resource_io_attr(2);+pci_dev_resource_io_attr(3);+pci_dev_resource_io_attr(4);+pci_dev_resource_io_attr(5);++pci_dev_resource_uc_attr(0);+pci_dev_resource_uc_attr(1);+pci_dev_resource_uc_attr(2);+pci_dev_resource_uc_attr(3);+pci_dev_resource_uc_attr(4);+pci_dev_resource_uc_attr(5);++pci_dev_resource_wc_attr(0);+pci_dev_resource_wc_attr(1);+pci_dev_resource_wc_attr(2);+pci_dev_resource_wc_attr(3);+pci_dev_resource_wc_attr(4);+pci_dev_resource_wc_attr(5);++staticconststructbin_attribute*constpci_dev_resource_io_attrs[]={+&dev_resource0_io_attr,+&dev_resource1_io_attr,+&dev_resource2_io_attr,+&dev_resource3_io_attr,+&dev_resource4_io_attr,+&dev_resource5_io_attr,+NULL,+};++staticconststructbin_attribute*constpci_dev_resource_uc_attrs[]={+&dev_resource0_uc_attr,+&dev_resource1_uc_attr,+&dev_resource2_uc_attr,+&dev_resource3_uc_attr,+&dev_resource4_uc_attr,+&dev_resource5_uc_attr,+NULL,+};++staticconststructbin_attribute*constpci_dev_resource_wc_attrs[]={+&dev_resource0_wc_attr,+&dev_resource1_wc_attr,+&dev_resource2_wc_attr,+&dev_resource3_wc_attr,+&dev_resource4_wc_attr,+&dev_resource5_wc_attr,+NULL,+};++staticconststructattribute_grouppci_dev_resource_io_attr_group={+.bin_attrs=pci_dev_resource_io_attrs,+.is_bin_visible=pci_dev_resource_io_is_visible,+.bin_size=pci_dev_resource_bin_size,+};++staticconststructattribute_grouppci_dev_resource_uc_attr_group={+.bin_attrs=pci_dev_resource_uc_attrs,+.is_bin_visible=pci_dev_resource_uc_is_visible,+.bin_size=pci_dev_resource_bin_size,+};++staticconststructattribute_grouppci_dev_resource_wc_attr_group={+.bin_attrs=pci_dev_resource_wc_attrs,+.is_bin_visible=pci_dev_resource_wc_is_visible,+.bin_size=pci_dev_resource_bin_size,+};++staticconststructattribute_group*pci_dev_resource_attr_groups[]={+&pci_dev_resource_io_attr_group,+&pci_dev_resource_uc_attr_group,+&pci_dev_resource_wc_attr_group,+NULL,+};+#else+#define pci_dev_resource_attr_groups NULL#endif+int__weakpci_create_resource_files(structpci_dev*dev){return0;}+void__weakpci_remove_resource_files(structpci_dev*dev){}+/***pci_write_rom-usedtoenableaccesstothePCIROMdisplay*@filp:sysfsfile
@@ -1662,14 +1676,14 @@ static ssize_t __resource_resize_store(struct device *dev, int n,pci_write_config_word(pdev,PCI_COMMAND,cmd&~PCI_COMMAND_MEMORY);-pci_remove_resource_files(pdev);+sysfs_remove_groups(&pdev->dev.kobj,pci_dev_resource_attr_groups);ret=pci_resize_resource(pdev,n,size,0);pci_assign_unassigned_bus_resources(bus);-if(pci_create_resource_files(pdev))-pci_warn(pdev,"Failed to recreate resource files after BAR resizing\n");+if(sysfs_create_groups(&pdev->dev.kobj,pci_dev_resource_attr_groups))+pci_warn(pdev,"Failed to recreate resource groups after BAR resizing\n");pci_write_config_word(pdev,PCI_COMMAND,cmd);pm_put:
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:36:57
Add a pci_warn() to __resource_resize_store(), so that BAR resize
failures are visible to the user, which can help troubleshoot any
potential resource resize issues.
While at it, rename the resource_resize_is_visible() to
resource_resize_attr_is_visible() along with the corresponding
group variable to align with the naming convention used by the
resource attribute groups.
Also, change the order of pci_dev_groups[] such that the resize
group is now located alongside the other resource groups.
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:37:05
On platforms with HAVE_PCI_MMAP or ARCH_GENERIC_PCI_MMAP_RESOURCE,
resource files are now handled by static attribute groups registered
via pci_dev_groups[].
Thus, the pci_create_sysfs_dev_files() and pci_remove_sysfs_dev_files()
can now be stubbed out, as the dynamic resource file creation is no
longer needed.
Also, simplify pci_sysfs_init() on these platforms to only iterate
buses for legacy attributes creation, skipping the per-device loop.
Move the __weak stubs for pci_create_resource_files() and
pci_remove_resource_files() into the #else branch since only platforms
without HAVE_PCI_MMAP (such as Alpha architecture) still need them.
Guard the res_attr[] and res_attr_wc[] fields in struct pci_dev the
same way.
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 15 ++++++++++++---
include/linux/pci.h | 4 ++++
2 files changed, 16 insertions(+), 3 deletions(-)
@@ -515,8 +515,10 @@ struct pci_dev {spinlock_tpcie_cap_lock;/* Protects RMW ops in capability accessors */u32saved_config_space[16];/* Config space saved at suspend time */structhlist_headsaved_cap_space;+#if !defined(HAVE_PCI_MMAP) && !defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)structbin_attribute*res_attr[DEVICE_COUNT_RESOURCE];/* sysfs file for resources */structbin_attribute*res_attr_wc[DEVICE_COUNT_RESOURCE];/* sysfs file for WC mapping of resources */+#endif#ifdef CONFIG_HOTPLUG_PCI_PCIEunsignedintbroken_cmd_compl:1;/* No compl for some cmds */
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:37:12
Currently, pci_sysfs_init() and sysfs_initialized compile
unconditionally, even on platforms where static attribute
groups handle all resource file creation.
Thus, place them behind a new HAVE_PCI_SYSFS_INIT macro,
especially as the late_initcall is only needed when:
- HAVE_PCI_LEGACY is set, to iterate buses and create legacy
I/O and memory files.
- Neither HAVE_PCI_MMAP nor ARCH_GENERIC_PCI_MMAP_RESOURCE is
set, to iterate devices and create resource files via the
__weak pci_create_resource_files() stub override (this is
how the Alpha architecture handles this currently).
On most systems both conditions are false and the entire
late_initcall compiles away.
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 9 +++++++++
1 file changed, 9 insertions(+)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:37:20
Currently, Alpha's pci_mmap_resource() does not check
security_locked_down(LOCKDOWN_PCI_ACCESS) before allowing
userspace to mmap PCI BARs.
The generic version has had this check since commit eb627e17727e
("PCI: Lock down BAR access when the kernel is locked down") to
prevent DMA attacks when the kernel is locked down.
Add the same check to Alpha's pci_mmap_resource().
Fixes: eb627e17727e ("PCI: Lock down BAR access when the kernel is locked down")
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/kernel/pci-sysfs.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:37:27
Currently, Alpha's pci_create_one_attr() stores a resource pointer in
attr->private, and pci_mmap_resource() loops through all BARs to find
the matching index.
Thus, store the BAR index directly in attr->private and retrieve the
resource via pci_resource_n(). This eliminates the loop and aligns
with the convention used by the generic PCI sysfs code.
The PCI core change was first added in the commit dca40b186b75 ("PCI:
Use BAR index in sysfs attr->private instead of resource pointer").
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/kernel/pci-sysfs.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:37:35
Replace direct pdev->resource[] accesses with pci_resource_n(),
and open-coded res->flags type checks with pci_resource_is_mem()
and pci_resource_start() helpers.
While at it, move the pci_resource_n() call directly into
pcibios_resource_to_bus() and drop the local struct
resource pointer.
No functional changes intended.
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/kernel/pci-sysfs.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:37:42
Currently, __pci_mmap_fits() computes the BAR size using
pci_resource_len() - 1, which wraps to a large value when the
BAR length is zero, causing the bounds check to incorrectly
succeed.
Thus, add an early return for empty resources.
Fixes: 10a0ef39fbd1 ("PCI/alpha: pci sysfs resources")
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/kernel/pci-sysfs.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:37:50
Remove the WARN() that fires when userspace attempts to mmap beyond
the BAR bounds. The check still returns 0 to reject the mapping,
but the warning is excessive for normal operation.
A similar warning was removed from the PCI core in the commit
3b519e4ea618 ("PCI: fix size checks for mmap() on /proc/bus/pci files").
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <redacted>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/kernel/pci-sysfs.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
@@ -48,13 +48,7 @@ static int __pci_mmap_fits(struct pci_dev *pdev, int num,start=vma->vm_pgoff;size=((len-1)>>(PAGE_SHIFT-shift))+1;-if(start<size&&size-start>=nr)-return1;-WARN(1,"process \"%s\" tried to map%s 0x%08lx-0x%08lx on %s BAR %d "-"(size 0x%08lx)\n",-current->comm,sparse?" sparse":"",start,start+nr,-pci_name(pdev),num,size);-return0;+returnstart<size&&size-start>=nr;}/**
@@ -259,7 +253,7 @@ int pci_create_resource_files(struct pci_dev *pdev)staticint__legacy_mmap_fits(structpci_controller*hose,structvm_area_struct*vma,-unsignedlongres_size,intsparse)+unsignedlongres_size){unsignedlongnr,start,size;
@@ -267,13 +261,7 @@ static int __legacy_mmap_fits(struct pci_controller *hose,start=vma->vm_pgoff;size=((res_size-1)>>PAGE_SHIFT)+1;-if(start<size&&size-start>=nr)-return1;-WARN(1,"process \"%s\" tried to map%s 0x%08lx-0x%08lx on hose %d "-"(size 0x%08lx)\n",-current->comm,sparse?" sparse":"",start,start+nr,-hose->index,size);-return0;+returnstart<size&&size-start>=nr;}staticinlineinthas_sparse(structpci_controller*hose,
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:37:58
Add macros for declaring static binary attributes for Alpha's PCI
resource files:
- pci_dev_resource_attr(), for dense/BWX systems (mmap dense)
- pci_dev_resource_sparse_attr(), for sparse systems (mmap sparse)
- pci_dev_resource_dense_attr(), for dense companion files (mmap dense)
Each macro creates a const bin_attribute with the BAR index stored in
the .private property and the appropriate .mmap callback.
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <redacted>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/kernel/pci-sysfs.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:38:06
Currently, Alpha's PCI resource files (resourceN, resourceN_sparse,
resourceN_dense) are dynamically created by pci_create_resource_files(),
which overrides the generic __weak implementation. The current code
allocates bin_attributes at runtime and manages them via the res_attr[]
and res_attr_wc[] fields in struct pci_dev.
Thus, convert to static const attributes with three attribute groups
(plain, sparse, dense), each with an .is_bin_visible callback that
checks resource length, has_sparse(), and sparse_mem_mmap_fits(). A
.bin_size callback provides the resource size to the kernfs node, with
the sparse variant shifting by 5 bits for byte-level addressing.
Register the groups via ARCH_PCI_DEV_GROUPS so the driver model handles
creation and removal automatically.
Use the new pci_resource_is_mem() helper for the type check, replacing
the open-coded bitwise flag test.
Finally, remove pci_create_resource_files(), pci_remove_resource_files(),
pci_create_attr(), and pci_create_one_attr() which are no longer needed.
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <redacted>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/include/asm/pci.h | 9 ++
arch/alpha/kernel/pci-sysfs.c | 291 +++++++++++++++++++---------------
2 files changed, 172 insertions(+), 128 deletions(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:38:14
Currently, pci_create_sysfs_dev_files() and pci_remove_sysfs_dev_files()
are no-op stubs. With both the generic and Alpha resource files now
handled by static attribute groups, no platform needs dynamic per-device
sysfs file creation.
Thus, remove both functions, their declarations, and the call sites in
pci_bus_add_device() and pci_stop_dev().
Remove __weak pci_create_resource_files() and pci_remove_resource_files()
stubs and their declarations in pci.h, as no architecture overrides them
anymore.
Remove the res_attr[] and res_attr_wc[] fields from struct pci_dev
which were used to track dynamically allocated resource attributes.
Finally, simplify pci_sysfs_init() to only handle legacy file creation
under HAVE_PCI_LEGACY, removing the per-device loop and the
HAVE_PCI_SYSFS_INIT helper added earlier.
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/bus.c | 1 -
drivers/pci/pci-sysfs.c | 52 ++---------------------------------------
drivers/pci/pci.h | 4 ----
drivers/pci/remove.c | 1 -
include/linux/pci.h | 9 -------
5 files changed, 2 insertions(+), 65 deletions(-)
@@ -515,10 +515,6 @@ struct pci_dev {spinlock_tpcie_cap_lock;/* Protects RMW ops in capability accessors */u32saved_config_space[16];/* Config space saved at suspend time */structhlist_headsaved_cap_space;-#if !defined(HAVE_PCI_MMAP) && !defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)-structbin_attribute*res_attr[DEVICE_COUNT_RESOURCE];/* sysfs file for resources */-structbin_attribute*res_attr_wc[DEVICE_COUNT_RESOURCE];/* sysfs file for WC mapping of resources */-#endif#ifdef CONFIG_HOTPLUG_PCI_PCIEunsignedintbroken_cmd_compl:1;/* No compl for some cmds */
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:38:22
Add defines for the standard PCI legacy address space sizes,
replacing the raw literals used by the legacy sysfs attributes.
Then, replace open-coded values with the newly added macros.
No functional changes intended.
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 4 ++--
include/linux/pci.h | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
@@ -1169,6 +1170,10 @@ enum {/* These external functions are only available when PCI support is enabled */#ifdef CONFIG_PCI+/* PCI legacy I/O port and memory address space sizes. */+#define PCI_LEGACY_IO_SIZE (SZ_64K - 1)+#define PCI_LEGACY_MEM_SIZE SZ_1M+externunsignedintpci_flags;staticinlinevoidpci_set_flags(intflags){pci_flags=flags;}
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:38:30
Currently, pci_mmap_legacy_page_range() reads the legacy resource
size from bus->legacy_mem->size or bus->legacy_io->size. This
couples the mmap bounds check to the struct pci_bus fields that
will be removed when legacy attributes are converted to static
definitions.
Compute the size directly using PCI_LEGACY_MEM_SIZE (0x100000) and
PCI_LEGACY_IO_SIZE (0xffff) macros, and shift by 5 bits for sparse
systems.
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <redacted>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/kernel/pci-sysfs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:38:37
Currently, Alpha's sparse/dense legacy attribute handling is done via
pci_adjust_legacy_attr(), which updates dynamically allocated attributes
at runtime. The upcoming conversion to static attributes needs a way
to determine sparse support at visibility check time.
Add a __weak pci_legacy_has_sparse() that returns false by default.
Alpha overrides it to check has_sparse() on the bus host controller.
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/include/asm/pci.h | 2 ++
arch/alpha/kernel/pci-sysfs.c | 7 +++++++
drivers/pci/pci-sysfs.c | 6 ++++++
drivers/pci/pci.h | 4 ++++
4 files changed, 19 insertions(+)
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:38:44
Currently, legacy_io and legacy_mem are dynamically allocated and
created by pci_create_legacy_files(), with pci_adjust_legacy_attr()
updating the attributes at runtime on Alpha to rename them and shift
the size for sparse addressing.
Convert to four static const attributes (legacy_io, legacy_io_sparse,
legacy_mem, legacy_mem_sparse) with is_bin_visible() callbacks that
use pci_legacy_has_sparse() to select the appropriate variant per bus.
The sizes are compile-time constants and .size is set directly on
each attribute.
Register the groups in pcibus_groups[] under a HAVE_PCI_LEGACY guard
so the driver model handles creation and removal automatically.
Stub out pci_create_legacy_files() and pci_remove_legacy_files() as
the dynamic creation is no longer needed. Remove the __weak
pci_adjust_legacy_attr(), Alpha's override, and its declaration from
both Alpha and PowerPC asm/pci.h headers.
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
arch/alpha/include/asm/pci.h | 2 -
arch/alpha/kernel/pci-sysfs.c | 38 ++----
arch/powerpc/include/asm/pci.h | 2 -
drivers/pci/pci-sysfs.c | 221 +++++++++++++++++++--------------
4 files changed, 135 insertions(+), 128 deletions(-)
@@ -989,91 +971,144 @@ bool __weak pci_legacy_has_sparse(struct pci_bus *bus,returnfalse;}-/**-*pci_adjust_legacy_attr-adjustmentoflegacyfileattributes-*@b:bustocreatefilesunder-*@mmap_type:I/Oportormemory-*-*Stubimplementation.Canbeoverriddenbyarchifnecessary.-*/-void__weakpci_adjust_legacy_attr(structpci_bus*b,-enumpci_mmap_statemmap_type)+staticinlineumode_t__pci_legacy_is_visible(structkobject*kobj,+conststructbin_attribute*a,+enumpci_mmap_statetype,+boolsparse){+structpci_bus*bus=to_pci_bus(kobj_to_dev(kobj));++if(pci_legacy_has_sparse(bus,type)!=sparse)+return0;++returna->attr.mode;}-/**-*pci_create_legacy_files-createlegacyI/Oportandmemoryfiles-*@b:bustocreatefilesunder-*-*SomeplatformsallowaccesstolegacyI/OportandISAmemoryspaceon-*aper-busbasis.Thisroutinecreatesthefilesandtiestheminto-*theirassociatedread,writeandmmapfilesfrompci-sysfs.c-*-*Onerrorunwind,butdon'tpropagatetheerrortothecaller-*asitisoktosetupthePCIbuswithoutthesefiles.-*/-voidpci_create_legacy_files(structpci_bus*b)+staticumode_tpci_legacy_io_is_visible(structkobject*kobj,+conststructbin_attribute*a,intn){-interror;--if(!sysfs_initialized)-return;--b->legacy_io=kzalloc_objs(structbin_attribute,2,GFP_ATOMIC);-if(!b->legacy_io)-gotokzalloc_err;--sysfs_bin_attr_init(b->legacy_io);-b->legacy_io->attr.name="legacy_io";-b->legacy_io->size=PCI_LEGACY_IO_SIZE;-b->legacy_io->attr.mode=0600;-b->legacy_io->read=pci_read_legacy_io;-b->legacy_io->write=pci_write_legacy_io;-/* See pci_create_attr() for motivation */-b->legacy_io->llseek=pci_llseek_resource_legacy;-b->legacy_io->mmap=pci_mmap_legacy_io;-b->legacy_io->f_mapping=iomem_get_mapping;-pci_adjust_legacy_attr(b,pci_mmap_io);-error=device_create_bin_file(&b->dev,b->legacy_io);-if(error)-gotolegacy_io_err;--/* Allocated above after the legacy_io struct */-b->legacy_mem=b->legacy_io+1;-sysfs_bin_attr_init(b->legacy_mem);-b->legacy_mem->attr.name="legacy_mem";-b->legacy_mem->size=PCI_LEGACY_MEM_SIZE;-b->legacy_mem->attr.mode=0600;-b->legacy_mem->mmap=pci_mmap_legacy_mem;-/* See pci_create_attr() for motivation */-b->legacy_mem->llseek=pci_llseek_resource_legacy;-b->legacy_mem->f_mapping=iomem_get_mapping;-pci_adjust_legacy_attr(b,pci_mmap_mem);-error=device_create_bin_file(&b->dev,b->legacy_mem);-if(error)-gotolegacy_mem_err;--return;--legacy_mem_err:-device_remove_bin_file(&b->dev,b->legacy_io);-legacy_io_err:-kfree(b->legacy_io);-b->legacy_io=NULL;-kzalloc_err:-dev_warn(&b->dev,"could not create legacy I/O port and ISA memory resources in sysfs\n");+return__pci_legacy_is_visible(kobj,a,pci_mmap_io,false);}-voidpci_remove_legacy_files(structpci_bus*b)+staticumode_tpci_legacy_io_sparse_is_visible(structkobject*kobj,+conststructbin_attribute*a,+intn){-if(b->legacy_io){-device_remove_bin_file(&b->dev,b->legacy_io);-device_remove_bin_file(&b->dev,b->legacy_mem);-kfree(b->legacy_io);/* both are allocated here */-}+return__pci_legacy_is_visible(kobj,a,pci_mmap_io,true);}++staticumode_tpci_legacy_mem_is_visible(structkobject*kobj,+conststructbin_attribute*a,intn)+{+return__pci_legacy_is_visible(kobj,a,pci_mmap_mem,false);+}++staticumode_tpci_legacy_mem_sparse_is_visible(structkobject*kobj,+conststructbin_attribute*a,+intn)+{+return__pci_legacy_is_visible(kobj,a,pci_mmap_mem,true);+}++staticloff_tpci_llseek_resource_legacy(structfile*filep,+structkobject*kobj__always_unused,+conststructbin_attribute*attr,+loff_toffset,intwhence)+{+returnfixed_size_llseek(filep,offset,whence,attr->size);+}++staticconststructbin_attributepci_legacy_io_attr={+.attr={.name="legacy_io",.mode=0600},+.size=PCI_LEGACY_IO_SIZE,+.read=pci_read_legacy_io,+.write=pci_write_legacy_io,+.mmap=pci_mmap_legacy_io,+.llseek=pci_llseek_resource_legacy,+.f_mapping=iomem_get_mapping,+};++staticconststructbin_attributepci_legacy_io_sparse_attr={+.attr={.name="legacy_io_sparse",.mode=0600},+.size=PCI_LEGACY_IO_SIZE<<5,+.read=pci_read_legacy_io,+.write=pci_write_legacy_io,+.mmap=pci_mmap_legacy_io,+.llseek=pci_llseek_resource_legacy,+.f_mapping=iomem_get_mapping,+};++staticconststructbin_attributepci_legacy_mem_attr={+.attr={.name="legacy_mem",.mode=0600},+.size=PCI_LEGACY_MEM_SIZE,+.mmap=pci_mmap_legacy_mem,+.llseek=pci_llseek_resource_legacy,+.f_mapping=iomem_get_mapping,+};++staticconststructbin_attributepci_legacy_mem_sparse_attr={+.attr={.name="legacy_mem_sparse",.mode=0600},+.size=PCI_LEGACY_MEM_SIZE<<5,+.mmap=pci_mmap_legacy_mem,+.llseek=pci_llseek_resource_legacy,+.f_mapping=iomem_get_mapping,+};++staticconststructbin_attribute*constpci_legacy_io_attrs[]={+&pci_legacy_io_attr,+NULL,+};++staticconststructbin_attribute*constpci_legacy_io_sparse_attrs[]={+&pci_legacy_io_sparse_attr,+NULL,+};++staticconststructbin_attribute*constpci_legacy_mem_attrs[]={+&pci_legacy_mem_attr,+NULL,+};++staticconststructbin_attribute*constpci_legacy_mem_sparse_attrs[]={+&pci_legacy_mem_sparse_attr,+NULL,+};++staticconststructattribute_grouppci_legacy_io_group={+.bin_attrs=pci_legacy_io_attrs,+.is_bin_visible=pci_legacy_io_is_visible,+};++staticconststructattribute_grouppci_legacy_io_sparse_group={+.bin_attrs=pci_legacy_io_sparse_attrs,+.is_bin_visible=pci_legacy_io_sparse_is_visible,+};++staticconststructattribute_grouppci_legacy_mem_group={+.bin_attrs=pci_legacy_mem_attrs,+.is_bin_visible=pci_legacy_mem_is_visible,+};++staticconststructattribute_grouppci_legacy_mem_sparse_group={+.bin_attrs=pci_legacy_mem_sparse_attrs,+.is_bin_visible=pci_legacy_mem_sparse_is_visible,+};++voidpci_create_legacy_files(structpci_bus*b){}+voidpci_remove_legacy_files(structpci_bus*b){}#endif /* HAVE_PCI_LEGACY */+conststructattribute_group*pcibus_groups[]={+&pcibus_group,+#ifdef HAVE_PCI_LEGACY+&pci_legacy_io_group,+&pci_legacy_io_sparse_group,+&pci_legacy_mem_group,+&pci_legacy_mem_sparse_group,+#endif+NULL,+};+#if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)/***pci_mmap_resource-mapaPCIresourceintousermemoryspace
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:38:52
Currently, pci_create_legacy_files() and pci_remove_legacy_files() are
no-op stubs. With legacy attributes now handled by static groups
registered via pcibus_groups[], no call site needs them.
Remove both functions, their declarations, and the call sites in
pci_register_host_bridge(), pci_alloc_child_bus(), and pci_remove_bus().
Remove the pci_sysfs_init() late_initcall and sysfs_initialized. The
late_initcall originally existed to create all the dynamic PCI sysfs
files, but with both resource and legacy attributes now handled by
static groups, it is no longer needed.
Remove the legacy_io and legacy_mem fields from struct pci_bus which
were used to track the dynamically allocated legacy attributes.
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 21 ---------------------
drivers/pci/pci.h | 8 --------
drivers/pci/probe.c | 6 ------
drivers/pci/remove.c | 2 --
include/linux/pci.h | 2 --
5 files changed, 39 deletions(-)
@@ -1073,9 +1073,6 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)dev_err(&bus->dev,"failed to add bus: %d\n",err);}-/* Create legacy_io and legacy_mem files for this bus */-pci_create_legacy_files(bus);-if(parent)dev_info(parent,"PCI host bridge to bus %s\n",name);else
@@ -1281,9 +1278,6 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,dev_err(&child->dev,"failed to add bus: %d\n",ret);}-/* Create legacy_io and legacy_mem files for this bus */-pci_create_legacy_files(child);-returnchild;}
@@ -726,8 +726,6 @@ struct pci_bus {pci_bus_flags_tbus_flags;/* Inherited by child buses */structdevice*bridge;structdevicedev;-structbin_attribute*legacy_io;/* Legacy I/O for this bus */-structbin_attribute*legacy_mem;/* Legacy mem */unsignedintis_added:1;unsignedintunsafe_warn:1;/* warned about RW1C config write */unsignedintflit_mode:1;/* Link in Flit mode */
From: Krzysztof Wilczyński <kwilczynski@kernel.org> Date: 2026-05-08 04:38:59
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.
Thus, 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.
Tested-by: Shivaprasad G Bhat <redacted>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
---
drivers/pci/pci-sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
On Fri, May 08, 2026 at 04:35:19AM +0000, Krzysztof Wilczyński wrote:
Hello,
This series converts every dynamically allocated PCI sysfs attribute to
a static const definition. After the full series, pci_sysfs_init() and
sysfs_initialized are gone, and every sysfs file is created by the
driver model at device_add() time.
Currently, the PCI resource files (resourceN, resourceN_wc) and the
legacy bus files (legacy_io, legacy_mem) are created dynamically
from two unsynchronised paths:
Path A: late_initcall
pci_sysfs_init() (late_initcall)
sysfs_initialized = 1
for_each_pci_dev()
pci_create_sysfs_dev_files()
sysfs_create_bin_file() (resourceN, resourceN_wc)
pci_find_next_bus()
pci_create_legacy_files()
sysfs_create_bin_file() (legacy_io, legacy_mem)
Path B: device registration / hotplug
pci_bus_add_devices()
pci_bus_add_device()
pci_create_sysfs_dev_files()
if (!sysfs_initialized) <- only guard
return
sysfs_create_bin_file() (resourceN, resourceN_wc)
On most ACPI systems this does not race because PCI enumeration
completes at subsys_initcall time, before pci_sysfs_init() runs:
subsys_initcall (level 4):
acpi_pci_root_add()
pci_bus_add_device()
pci_create_sysfs_dev_files()
if (!sysfs_initialized) <- variable not yet set
return -EACCES
late_initcall (level 7):
pci_sysfs_init()
sysfs_initialized = 1
for_each_pci_dev()
pci_create_sysfs_dev_files() <- creates the files, no race
On Devicetree platforms the host controller is a platform driver that
probes via the driver model, often on a workqueue, and overlaps with the
late_initcall:
CPU 0 (late_initcall) CPU 1 (driver probe)
--------------------------- ----------------------------
pci_sysfs_init()
sysfs_initialized = 1
for_each_pci_dev() pci_bus_add_device()
pci_create_sysfs_dev_files() pci_create_sysfs_dev_files()
sysfs_create_bin_file() sysfs_create_bin_file()
-> "duplicate filename"
The same happens on ACPI when probing is asynchronous (hv_pci on
Azure, RISC-V with ACPI).
The duplicate causes sysfs_create_bin_file() to fail with -EEXIST.
pci_create_resource_files() then calls pci_remove_resource_files() in
its error unwind, tearing down files the other thread created and
still references through pdev->res_attr[]. This has caused kernel
panics on i.MX6 and boot failures on other platforms.
Several different fixes have been proposed over the years: reordering
the sysfs_initialized assignment, adding locks, checking
pci_dev_is_added(), setting pdev->res_attr[] to NULL after kfree
(which only prevents a double-free on the teardown path, not the
error unwind removing the other thread's files). None would address the
root cause.
This has been reported a few times:
- https://lore.kernel.org/linux-pci/20250702155112.40124-1-heshuan@bytedance.com/
- https://lore.kernel.org/linux-pci/b51519d6-ce45-4b6d-8135-c70169bd110e@h-partners.com/
- https://lore.kernel.org/linux-pci/1702093576-30405-1-git-send-email-ssengar@linux.microsoft.com/
- https://lore.kernel.org/linux-pci/SY0P300MB04687548090B73E40AF97D8897B82@SY0P300MB0468.AUSP300.PROD.OUTLOOK.COM/
- https://lore.kernel.org/linux-pci/20230105174736.GA1154719@bhelgaas/
- https://lore.kernel.org/linux-pci/m3eebg9puj.fsf@t19.piap.pl/
- https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/
- https://lore.kernel.org/linux-pci/1366196798-15929-1-git-send-email-artem.savkov@gmail.com/
- https://bugzilla.kernel.org/show_bug.cgi?id=215515
- https://bugzilla.kernel.org/show_bug.cgi?id=216888
With static attributes the driver model creates sysfs entries once per
device at device_add() time, under the device lock, eliminating the
late_initcall iteration and the race along with it.
Krzysztof
---
Changes in v7:
https://lore.kernel.org/linux-pci/20260422161407.118748-1-kwilczynski@kernel.org/
- Addded Alex Williamson (author of the resource resize sysfs
attributes) to the list of recipients for visibility.
- Split pci_llseek_resource() into pci_llseek_resource() and
pci_llseek_resource_legacy() since legacy attributes operate
on a struct pci_bus where to_pci_dev() would be invalid,
as per Bjorn Helgaas' feedback.
- Moved each llseek variant inside its respective #ifdef guard
during the corresponding dynamic-to-static conversion commit,
dropping the __maybe_unused annotations.
- Extended the WARN macro removal to also cover __legacy_mmap_fits().
- Updated commit message of patch 18, so that it correctly mentions
pci_stop_dev() rather than pci_stop_bus_device().
- Updated commit message of patch 24 to clarify the indirect
relationship between ReBAR and the HAVE_PCI_MMAP and/or
ARCH_GENERIC_PCI_MMAP_RESOURCE guards.
Changes in v6:
https://lore.kernel.org/linux-pci/20260416180107.777065-1-kwilczynski@kernel.org/
- Fixed commit message for patch 13, removing reference to
pci_resource_flags() which was no longer changed there.
- Added a new patch (24) to move the BAR resource resize
(ReBAR) support behind existing PCI mmap #ifdef guard,
so that the code is not included on architectures that
do not support resource resizing (i.e., Alpha, etc.).
Changes in v5:
https://lore.kernel.org/linux-pci/20260411080148.471335-1-kwilczynski@kernel.org/
- Added new Tested-by, Reviewed-by, and Acked-by tags.
- Used the existing _io function names in the static macro
definitions, deferring the rename to the conversion commit
where it belongs, to avoid a forward reference across
commits. This was reported by Sashiko, see:
https://sashiko.dev/#/patchset/20260411080148.471335-1-kwilczynski%40kernel.org?part=6
- Folded the __resource_resize_store() conversion into the
main static attributes commit so the resize path is never
broken between commits. This was reported by Sashiko, see:
https://sashiko.dev/#/patchset/20260410055040.39233-1-kwilczynski%40kernel.org?part=6https://sashiko.dev/#/patchset/20260411080148.471335-1-kwilczynski%40kernel.org?part=7
- Dropped the unnecessary parentheses cleanup from the Alpha
BAR index commit, as the line is replaced two commits later
anyway, as per Ilpo Järvinen's feedback.
- Squashed the Alpha accessor macro and cleanup commits into
one, using pci_resource_is_mem() directly instead of the
intermediate pci_resource_flags() step, as per Ilpo
Järvinen's feedback.
- Moved the raw literal conversion in pci_create_legacy_files()
into the macro definition commit, so the macros and their
usage are introduced together, as per Ilpo Järvinen's
feedback.
- Removed unnecessary backslash line continuation from the
ternary in pci_mmap_legacy_page_range().
- Kept pci_resource_len() for visibility checks instead of
resource_assigned(). The static is_visible() callback
runs at device_add() time during the PCI enumeration,
before the pci_assign_unassigned_bus_resources() populates
res->parent, as such, resource_assigned() returned false
for every BAR, hiding all resource files. This is related
to review feedback from Ilpo Järvinen.
Changes in v4:
https://lore.kernel.org/linux-pci/20260410055040.39233-1-kwilczynski@kernel.org/
- Added new Reviewed-by tags.
- Added pci_resource_is_io() and pci_resource_is_mem() helpers
for resource type checks, replacing the open-coded bitwise
flag tests in pci_mmap_resource(), pci_resource_io(), and
Alpha's pci_mmap_resource(), as per Ilpo Järvinen's
suggestion.
- Split the __pci_mmap_fits() cleanup into two patches. An
overflow fix for zero-length BARs, which now includes a
Fixes: tag referencing the original Alpha PCI sysfs commit,
and the WARN macro removal is a separate cleanup as per Ilpo
Järvinen's suggestion.
- Added a missing Fixes: tag to the Alpha lockdown check,
referencing the commit that added the check to the generic
path but missed Alpha's implementation.
- Added PCI_LEGACY_IO_SIZE and PCI_LEGACY_MEM_SIZE macros to
replace the raw literals used for legacy address space sizes.
These are used in both Alpha's pci_mmap_legacy_page_range()
and the static legacy attribute definitions, as per Ilpo
Järvinen's suggestion.
- Replaced sysfs_update_groups() in the BAR resize path with
sysfs_remove_groups() before the resize and sysfs_create_groups()
after, restoring the original teardown before BAR resize
ordering. This was reported by Sashiko, see:
https://sashiko.dev/#/patchset/20260410055040.39233-1-kwilczynski%40kernel.org?part=7
- Defined pci_dev_resource_attr_groups as a NULL macro when
HAVE_PCI_MMAP and ARCH_GENERIC_PCI_MMAP_RESOURCE are both
absent, so the resize path compiles unconditionally without
#ifdef guards in the function body. This was reported by
Sashiko, see:
https://sashiko.dev/#/patchset/20260410055040.39233-1-kwilczynski%40kernel.org?part=7
- Moved the pci_legacy_has_sparse() prototype into the patch
that introduces the function, alongside the existing
pci_adjust_legacy_attr() declaration, to fix a bisection
issue where Alpha would warn on -Wmissing-prototypes.
This was reported by Sashiko, see:
https://sashiko.dev/#/patchset/20260410055040.39233-1-kwilczynski%40kernel.org?part=18
Changes in v3:
https://lore.kernel.org/linux-pci/20210910202623.2293708-1-kw@linux.com/
- Updated for modern kernel releases and expanded scope. The
v2 only covered the generic resource files. This version
also converts Alpha's sparse/dense resource files and the
legacy bus attributes, removing pci_sysfs_init() entirely.
- Split the single macro definition into three distinct ones
(per I/O, UC, and WC), to make sure that each carries only
the callbacks its resource type needs.
- Updated to use the new .bin_size callback, as the attributes
are const, to replace using a->size directly, which was not
ideal. This required changes to pci_llseek_resource(), to
ensure that it would work for device and bus-level attributes.
- Updated the __resource_resize_store() to include CAP_SYS_ADMIN
capabilities check.
- Added the security_locked_down() check to Alpha's
pci_mmap_resource(), to align with other architectures.
Changes in v2:
https://lore.kernel.org/linux-pci/20210825212255.878043-1-kw@linux.com/
- Refactored code so that the macros, helpers and internal
functions can be used to correctly leverage the read(),
write() and mmap() callbacks rather than to use the
.is_bin_visible() callback to set up sysfs objects
internals as this is not supported.
- Refactored some if-statements to check for a resource
flag first, and then call either arch_can_pci_mmap_io()
or arch_can_pci_mmap_wc(), plus store result of testing
for IORESOURCE_MEM and IORESOURCE_PREFETCH flags into
a boolean variable, as per Bjorn Helgaas' suggestion.
- Renamed pci_read_resource_io() and pci_write_resource_io()
callbacks so that these are not specifically tied to I/O
BARs read() and write() operations also as per Bjorn
Helgaas' suggestion.
- Updated style for code handling bitwise operations to
match the style that is preferred as per Bjorn Helgaas'
suggestion.
- Updated commit messages adding more details about the
implementation as requested by Bjorn Helgaas.
Krzysztof Wilczyński (24):
PCI/sysfs: Use PCI resource accessor macros
PCI: Add pci_resource_is_io() and pci_resource_is_mem() helpers
PCI/sysfs: Only allow supported resource types in I/O and MMIO helpers
PCI/sysfs: Split pci_llseek_resource() for device and legacy
attributes
PCI/sysfs: Add CAP_SYS_ADMIN check to __resource_resize_store()
PCI/sysfs: Add static PCI resource attribute macros
PCI/sysfs: Convert PCI resource files to static attributes
PCI/sysfs: Warn about BAR resize failure in __resource_resize_store()
PCI/sysfs: Add stubs for pci_{create,remove}_sysfs_dev_files()
PCI/sysfs: Limit pci_sysfs_init() late_initcall compile scope
alpha/PCI: Add security_locked_down() check to pci_mmap_resource()
alpha/PCI: Use BAR index in sysfs attr->private instead of resource
pointer
alpha/PCI: Use PCI resource accessor macros
alpha/PCI: Fix __pci_mmap_fits() overflow for zero-length BARs
alpha/PCI: Remove WARN from __pci_mmap_fits() and __legacy_mmap_fits()
alpha/PCI: Add static PCI resource attribute macros
alpha/PCI: Convert resource files to static attributes
PCI/sysfs: Remove pci_{create,remove}_sysfs_dev_files()
PCI: Add macros for legacy I/O and memory address space sizes
alpha/PCI: Compute legacy size in pci_mmap_legacy_page_range()
PCI/sysfs: Add __weak pci_legacy_has_sparse() helper
PCI/sysfs: Convert legacy I/O and memory attributes to static
definitions
PCI/sysfs: Remove pci_create_legacy_files() and pci_sysfs_init()
PCI/sysfs: Limit BAR resize attribute scope to platforms with PCI mmap
arch/alpha/include/asm/pci.h | 13 +-
arch/alpha/kernel/pci-sysfs.c | 385 +++++++++++----------
arch/powerpc/include/asm/pci.h | 2 -
drivers/pci/bus.c | 1 -
drivers/pci/pci-sysfs.c | 592 +++++++++++++++++++--------------
drivers/pci/pci.h | 16 +-
drivers/pci/probe.c | 6 -
drivers/pci/remove.c | 3 -
include/linux/pci.h | 39 ++-
9 files changed, 589 insertions(+), 468 deletions(-)
Updated pci/sysfs to this series, thank you very much! Looks great!