On Thu, Apr 30, 2026 at 11:51:28AM +0900, Krzysztof Wilczyński wrote: > Hello, > > > The only platform without these aforementioned defines is Alpha, which is > > conventional PCI only and cannot have ReBAR. So this guard removes dead > > sysfs code on platforms where it can never be executed. > > Having a closer look: > > resource_resize_attr_is_visible() > pci_rebar_get_current_size() <- returns -ENOTSUPP, so is_visible > callback returns 0 > pci_rebar_find_pos() > pos = pdev->rebar_cap <- set to 0 on a conventional PCI > if (!pos) > return -ENOTSUPP <- no ReBAR support > > The pdev->rebar_cap is set during PCI enumeration: > > pci_init_capabilities() > pci_rebar_init() > pdev->rebar_cap = pci_find_ext_capability() > pci_find_next_ext_capability() > if (dev->cfg_size <= PCI_CFG_SPACE_SIZE) > return 0; <- dev->cfg_size set to 256 here for > conventional PCI > > The PCI_CFG_SPACE_SIZE is 256 here. > > When the platform has support for PCI Express, the dev->cfg_size is then > set to 4096. On an architecture that supports conventional PCI only (such > as Alpha), the pdev->rebar_cap will be set to 0, the is_visible callback > will then return 0, and the resize sysfs attribute is never created, as > such, the __resource_resize_store() callback will never be executed. > > To make the connetion here to the #ifdef guards: > > For the pci_rebar_get_current_size() to return >= 0, the device needs > PCI Express and extended configuration space support. As of today, > every architecture with PCI Express support defines HAVE_PCI_MMAP or > ARCH_GENERIC_PCI_MMAP_RESOURCE. > > I hope the reasoning here works.
We're talking about this #ifdef: +#if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) static ssize_t __resource_resize_show(struct device *dev, int n, char *buf) ... +#endif I follow the reasoning now but by next week I won't, so I think it requires too much background knowledge. Future changes involving HAVE_PCI_MMAP or ARCH_GENERIC_PCI_MMAP_RESOURCE could easily break this. IIUC it's basically doing what "#ifdef CONFIG_PCI_REBAR" or even "#ifdef CONFIG_PCI_EXPRESS" would do, if we had such a thing. How terrible would it be if we just accepted this dead code on Alpha?
