]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PCI/sysfs: Add __weak pci_legacy_has_sparse() helper
authorKrzysztof Wilczyński <kwilczynski@kernel.org>
Fri, 8 May 2026 04:35:40 +0000 (04:35 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 20:19:09 +0000 (15:19 -0500)
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.

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-22-kwilczynski@kernel.org
arch/alpha/include/asm/pci.h
arch/alpha/kernel/pci-sysfs.c
drivers/pci/pci-sysfs.c
drivers/pci/pci.h

index ef19295f2e33c7d42f783e4710040c87c258451f..95de7ffd59e8d8667395f48dd82e5714f128b15e 100644 (file)
@@ -86,6 +86,8 @@ extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
                                      enum pci_mmap_state mmap_state);
 extern void pci_adjust_legacy_attr(struct pci_bus *bus,
                                   enum pci_mmap_state mmap_type);
+extern bool pci_legacy_has_sparse(struct pci_bus *bus,
+                                 enum pci_mmap_state type);
 #define HAVE_PCI_LEGACY        1
 
 extern const struct attribute_group pci_dev_resource_attr_group;
index 2038acbcfd2a95e94d5220f73aafa8d13577fbfd..20736a0c1a3992136172b83f1ee9efc3a5d78507 100644 (file)
@@ -184,6 +184,13 @@ int pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma,
        return hose_mmap_page_range(hose, vma, mmap_type, sparse);
 }
 
+bool pci_legacy_has_sparse(struct pci_bus *bus, enum pci_mmap_state type)
+{
+       struct pci_controller *hose = bus->sysdata;
+
+       return has_sparse(hose, type);
+}
+
 /**
  * pci_adjust_legacy_attr - adjustment of legacy file attributes
  * @bus: bus to create files under
index 1e60f072f746fa26cbab0966c5bb326c4483a48d..c1ba706844c948533f0a183dc24d7d78bc9351ba 100644 (file)
@@ -983,6 +983,12 @@ static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
        return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io);
 }
 
+bool __weak pci_legacy_has_sparse(struct pci_bus *bus,
+                                 enum pci_mmap_state type)
+{
+       return false;
+}
+
 /**
  * pci_adjust_legacy_attr - adjustment of legacy file attributes
  * @b: bus to create files under
index 71a1fde1e505e02222379fae3c9c3cff550e3be9..c64c7f5f0bcf883fc66acb78ebb4cdda39462b30 100644 (file)
@@ -392,6 +392,10 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
 
 }
 
+#ifdef HAVE_PCI_LEGACY
+bool pci_legacy_has_sparse(struct pci_bus *bus, enum pci_mmap_state type);
+#endif
+
 #ifdef CONFIG_SYSFS
 extern const struct attribute_group *pci_dev_groups[];
 extern const struct attribute_group *pci_dev_attr_groups[];