On Mon, Dec 4, 2023, at 13:38, Philipp Stanner wrote: > The implementation of pci_iounmap() is currently scattered over two > files, drivers/pci/iomap.c and lib/iomap.c. Additionally, > architectures can define their own version. > > To have only one version, it's necessary to create a helper function, > iomem_is_ioport(), that tells pci_iounmap() whether the passed address > points to an ioport or normal memory. > > iomem_is_ioport() can be provided through two different ways: > 1. The architecture itself provides it. As of today, the version > coming from lib/iomap.c de facto is the x86-specific version and > comes into play when CONFIG_GENERIC_IOMAP is selected. This rather > confusing naming is an artifact left by the removal of IA64. > 2. As a default version in include/asm-generic/io.h for those > architectures that don't use CONFIG_GENERIC_IOMAP, but also don't > provide their own version of iomem_is_ioport(). > > Once all architectures that support ports provide iomem_is_ioport(), the > arch-specific definitions for pci_iounmap() can be removed and the archs > can use the generic implementation, instead. > > Create a unified version of pci_iounmap() in drivers/pci/iomap.c. > Provide the function iomem_is_ioport() in include/asm-generic/io.h > (generic) and lib/iomap.c ("pseudo-generic" for x86). > > Remove the CONFIG_GENERIC_IOMAP guard around > ARCH_WANTS_GENERIC_PCI_IOUNMAP so that configs that set > CONFIG_GENERIC_PCI_IOMAP without CONFIG_GENERIC_IOMAP still get the > function. > > Add TODOs for follow-up work on the "generic is not generic but > x86-spcific"-Problem. > > Suggested-by: Arnd Bergmann <arnd@xxxxxxxxxx> > Signed-off-by: Philipp Stanner <pstanner@xxxxxxxxxx> Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx>