On Wed, Apr 22, 2026 at 04:14:07PM +0000, Krzysztof Wilczyński wrote:
> The resourceN_resize sysfs attributes allow users to resize
> Resizable BARs (ReBAR).  After a successful resize, the resource
> attribute groups are removed and recreated so that the updated
> BAR sizes are reflected in the sysfs files.

Out of curiosity, where does this removal/recreation happen?  I don't
see it in pci_resize_resource() or
pci_do_resource_release_and_resize().

> Resizable BARs are a PCI Express extended capability
> (PCI_EXT_CAP_ID_REBAR), which requires PCIe extended config
> space.

It sounds like the fact that ReBAR requires extended config space is
important somehow (beyond just the fact that we can't discover ReBAR
without it)?  Is there some connection between extended config space
and mmap?

> Every PCIe-capable architecture defines either HAVE_PCI_MMAP or
> ARCH_GENERIC_PCI_MMAP_RESOURCE (via the relevant arch headers
> or the generic asm-generic/pci.h fallback).  On platforms that
> define neither, the resource files are not created and the sysfs
> group remove and create calls in __resource_resize_store() are
> no-ops.

What's the connection between ReBAR and mmap?

> 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.
> 
> Signed-off-by: Krzysztof Wilczyński <[email protected]>
> ---
>  drivers/pci/pci-sysfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index b167e32d55ac..37c1990124d0 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -1690,6 +1690,7 @@ static const struct attribute_group 
> pci_dev_reset_method_attr_group = {
>       .is_visible = pci_dev_reset_attr_is_visible,
>  };
>  
> +#if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)
>  static ssize_t __resource_resize_show(struct device *dev, int n, char *buf)
>  {
>       struct pci_dev *pdev = to_pci_dev(dev);
> @@ -1804,6 +1805,7 @@ static const struct attribute_group 
> pci_dev_resource_resize_attr_group = {
>       .attrs = resource_resize_attrs,
>       .is_visible = resource_resize_attr_is_visible,
>  };
> +#endif
>  
>  static struct attribute *pci_dev_dev_attrs[] = {
>       &dev_attr_boot_vga.attr,
> @@ -1878,8 +1880,8 @@ const struct attribute_group *pci_dev_groups[] = {
>       &pci_dev_resource_io_attr_group,
>       &pci_dev_resource_uc_attr_group,
>       &pci_dev_resource_wc_attr_group,
> -#endif
>       &pci_dev_resource_resize_attr_group,
> +#endif
>       &pci_dev_config_attr_group,
>       &pci_dev_rom_attr_group,
>       &pci_dev_reset_attr_group,
> -- 
> 2.54.0
> 

Reply via email to