[PATCH 17/20] alpha/PCI: Compute legacy size in pci_mmap_legacy_page_range()

Krzysztof Wilczyński kwilczynski at kernel.org
Fri Apr 10 15:50:37 AEST 2026


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 from the known constants (0x100000 for
memory, 0xffff for I/O) and shift by 5 bits for sparse systems.

Signed-off-by: Krzysztof Wilczyński <kwilczynski at kernel.org>
---
 arch/alpha/kernel/pci-sysfs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c
index 27adfe6dbd5e..2da95d965e9c 100644
--- a/arch/alpha/kernel/pci-sysfs.c
+++ b/arch/alpha/kernel/pci-sysfs.c
@@ -180,8 +180,10 @@ 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) ? 0x100000 : 0xffff;
+	if (sparse)
+		res_size <<= 5;
+
 	if (!__legacy_mmap_fits(hose, vma, res_size, sparse))
 		return -EINVAL;
 
-- 
2.53.0



More information about the Linuxppc-dev mailing list