]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
alpha/PCI: Compute legacy size in pci_mmap_legacy_page_range()
authorKrzysztof Wilczyński <kwilczynski@kernel.org>
Fri, 8 May 2026 04:35:39 +0000 (04:35 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 20:19:09 +0000 (15:19 -0500)
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.

Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Link: https://patch.msgid.link/20260508043543.217179-21-kwilczynski@kernel.org
arch/alpha/kernel/pci-sysfs.c

index 435654ffa4a07d1d29e8229745f208188634d2c0..2038acbcfd2a95e94d5220f73aafa8d13577fbfd 100644 (file)
@@ -173,8 +173,11 @@ int pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma,
        int sparse = has_sparse(hose, mmap_type);
        unsigned long res_size;
 
-       res_size = (mmap_type == pci_mmap_mem) ? bus->legacy_mem->size :
-                                                bus->legacy_io->size;
+       res_size = (mmap_type == pci_mmap_mem) ? PCI_LEGACY_MEM_SIZE :
+                                                PCI_LEGACY_IO_SIZE;
+       if (sparse)
+               res_size <<= 5;
+
        if (!__legacy_mmap_fits(vma, res_size))
                return -EINVAL;