summaryrefslogtreecommitdiff
path: root/arch/mips/lib/iomap-pci.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2025-03-11 11:48:49 +0100
committerArnd Bergmann <arnd@arndb.de>2025-03-15 11:07:07 +0100
commit976bf3aec388331454362b60cd1b5605f99bfe38 (patch)
treef80b6614f37617b7b2996d4511f515ea776af2aa /arch/mips/lib/iomap-pci.c
parent53a83845dd27f7aeb456a0bac01aba9587fbf51f (diff)
mips: drop GENERIC_IOMAP wrapper
All PIO on MIPS platforms is memory mapped, so there is no benefit in the lib/iomap.c wrappers that switch between inb/outb and readb/writeb style accessses. In fact, the '#define PIO_RESERVED 0' setting completely disables the GENERIC_IOMAP functionality, and the '#define PIO_OFFSET mips_io_port_base' setting is based on a misunderstanding of what the offset is meant to do. MIPS started using GENERIC_IOMAP in 2018 with commit b962aeb02205 ("MIPS: Use GENERIC_IOMAP") replacing a simple custom implementation of the same interfaces, but at the time the asm-generic/io.h version was not usable yet. Since the header is now always included, it's now possible to go back to the even simpler version. Use the normal GENERIC_PCI_IOMAP functionality for all mips platforms without the hacky GENERIC_IOMAP, and provide a custom pci_iounmap() for the CONFIG_PCI_DRIVERS_LEGACY case to ensure the I/O port base never gets unmapped. The readsl() prototype needs an extra 'const' keyword to make it compatible with the generic ioread32_rep() alias. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/mips/lib/iomap-pci.c')
-rw-r--r--arch/mips/lib/iomap-pci.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/mips/lib/iomap-pci.c b/arch/mips/lib/iomap-pci.c
index a9cb28813f0b..2f82c776c6d0 100644
--- a/arch/mips/lib/iomap-pci.c
+++ b/arch/mips/lib/iomap-pci.c
@@ -43,4 +43,13 @@ void __iomem *__pci_ioport_map(struct pci_dev *dev,
return (void __iomem *) (ctrl->io_map_base + port);
}
+void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
+{
+ struct pci_controller *ctrl = dev->bus->sysdata;
+ void __iomem *base = (void __iomem *)ctrl->io_map_base;
+
+ if (addr < base || addr > (base + resource_size(ctrl->io_resource)))
+ iounmap(addr);
+}
+
#endif /* CONFIG_PCI_DRIVERS_LEGACY */