include/linux/io-mapping.h | 231 ------------------------------------- mm/Kconfig | 4 - mm/Makefile | 1 - mm/io-mapping.c | 30 ----- 4 files changed, 266 deletions(-) delete mode 100644 include/linux/io-mapping.h delete mode 100644 mm/io-mapping.c
This is dead code, which was used from commit b739f125e4eb ("i915: use
io_mapping_map_user") but reverted a month later by commit
0e4fe0c9f2f9 ("Revert "i915: use io_mapping_map_user"") back in 2021.
Since then nobody has used it, so remove it.
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
include/linux/io-mapping.h | 231 -------------------------------------
mm/Kconfig | 4 -
mm/Makefile | 1 -
mm/io-mapping.c | 30 -----
4 files changed, 266 deletions(-)
delete mode 100644 include/linux/io-mapping.h
delete mode 100644 mm/io-mapping.c
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
deleted file mode 100644
index 7376c1df9c90..000000000000
--- a/include/linux/io-mapping.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright © 2008 Keith Packard <keithp@keithp.com>
- */
-
-#ifndef _LINUX_IO_MAPPING_H
-#define _LINUX_IO_MAPPING_H
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/bug.h>
-#include <linux/io.h>
-#include <linux/pgtable.h>
-#include <asm/page.h>
-
-/*
- * The io_mapping mechanism provides an abstraction for mapping
- * individual pages from an io device to the CPU in an efficient fashion.
- *
- * See Documentation/driver-api/io-mapping.rst
- */
-
-struct io_mapping {
- resource_size_t base;
- unsigned long size;
- pgprot_t prot;
- void __iomem *iomem;
-};
-
-#ifdef CONFIG_HAVE_ATOMIC_IOMAP
-
-#include <linux/pfn.h>
-#include <asm/iomap.h>
-/*
- * For small address space machines, mapping large objects
- * into the kernel virtual space isn't practical. Where
- * available, use fixmap support to dynamically map pages
- * of the object at run time.
- */
-
-static inline struct io_mapping *
-io_mapping_init_wc(struct io_mapping *iomap,
- resource_size_t base,
- unsigned long size)
-{
- pgprot_t prot;
-
- if (iomap_create_wc(base, size, &prot))
- return NULL;
-
- iomap->base = base;
- iomap->size = size;
- iomap->prot = prot;
- return iomap;
-}
-
-static inline void
-io_mapping_fini(struct io_mapping *mapping)
-{
- iomap_free(mapping->base, mapping->size);
-}
-
-/* Atomic map/unmap */
-static inline void __iomem *
-io_mapping_map_atomic_wc(struct io_mapping *mapping,
- unsigned long offset)
-{
- resource_size_t phys_addr;
-
- BUG_ON(offset >= mapping->size);
- phys_addr = mapping->base + offset;
- if (!IS_ENABLED(CONFIG_PREEMPT_RT))
- preempt_disable();
- else
- migrate_disable();
- pagefault_disable();
- return __iomap_local_pfn_prot(PHYS_PFN(phys_addr), mapping->prot);
-}
-
-static inline void
-io_mapping_unmap_atomic(void __iomem *vaddr)
-{
- kunmap_local_indexed((void __force *)vaddr);
- pagefault_enable();
- if (!IS_ENABLED(CONFIG_PREEMPT_RT))
- preempt_enable();
- else
- migrate_enable();
-}
-
-static inline void __iomem *
-io_mapping_map_local_wc(struct io_mapping *mapping, unsigned long offset)
-{
- resource_size_t phys_addr;
-
- BUG_ON(offset >= mapping->size);
- phys_addr = mapping->base + offset;
- return __iomap_local_pfn_prot(PHYS_PFN(phys_addr), mapping->prot);
-}
-
-static inline void io_mapping_unmap_local(void __iomem *vaddr)
-{
- kunmap_local_indexed((void __force *)vaddr);
-}
-
-static inline void __iomem *
-io_mapping_map_wc(struct io_mapping *mapping,
- unsigned long offset,
- unsigned long size)
-{
- resource_size_t phys_addr;
-
- BUG_ON(offset >= mapping->size);
- phys_addr = mapping->base + offset;
-
- return ioremap_wc(phys_addr, size);
-}
-
-static inline void
-io_mapping_unmap(void __iomem *vaddr)
-{
- iounmap(vaddr);
-}
-
-#else /* HAVE_ATOMIC_IOMAP */
-
-#include <linux/uaccess.h>
-
-/* Create the io_mapping object*/
-static inline struct io_mapping *
-io_mapping_init_wc(struct io_mapping *iomap,
- resource_size_t base,
- unsigned long size)
-{
- iomap->iomem = ioremap_wc(base, size);
- if (!iomap->iomem)
- return NULL;
-
- iomap->base = base;
- iomap->size = size;
- iomap->prot = pgprot_writecombine(PAGE_KERNEL);
-
- return iomap;
-}
-
-static inline void
-io_mapping_fini(struct io_mapping *mapping)
-{
- iounmap(mapping->iomem);
-}
-
-/* Non-atomic map/unmap */
-static inline void __iomem *
-io_mapping_map_wc(struct io_mapping *mapping,
- unsigned long offset,
- unsigned long size)
-{
- return mapping->iomem + offset;
-}
-
-static inline void
-io_mapping_unmap(void __iomem *vaddr)
-{
-}
-
-/* Atomic map/unmap */
-static inline void __iomem *
-io_mapping_map_atomic_wc(struct io_mapping *mapping,
- unsigned long offset)
-{
- if (!IS_ENABLED(CONFIG_PREEMPT_RT))
- preempt_disable();
- else
- migrate_disable();
- pagefault_disable();
- return io_mapping_map_wc(mapping, offset, PAGE_SIZE);
-}
-
-static inline void
-io_mapping_unmap_atomic(void __iomem *vaddr)
-{
- io_mapping_unmap(vaddr);
- pagefault_enable();
- if (!IS_ENABLED(CONFIG_PREEMPT_RT))
- preempt_enable();
- else
- migrate_enable();
-}
-
-static inline void __iomem *
-io_mapping_map_local_wc(struct io_mapping *mapping, unsigned long offset)
-{
- return io_mapping_map_wc(mapping, offset, PAGE_SIZE);
-}
-
-static inline void io_mapping_unmap_local(void __iomem *vaddr)
-{
- io_mapping_unmap(vaddr);
-}
-
-#endif /* !HAVE_ATOMIC_IOMAP */
-
-static inline struct io_mapping *
-io_mapping_create_wc(resource_size_t base,
- unsigned long size)
-{
- struct io_mapping *iomap;
-
- iomap = kmalloc(sizeof(*iomap), GFP_KERNEL);
- if (!iomap)
- return NULL;
-
- if (!io_mapping_init_wc(iomap, base, size)) {
- kfree(iomap);
- return NULL;
- }
-
- return iomap;
-}
-
-static inline void
-io_mapping_free(struct io_mapping *iomap)
-{
- io_mapping_fini(iomap);
- kfree(iomap);
-}
-
-int io_mapping_map_user(struct io_mapping *iomap, struct vm_area_struct *vma,
- unsigned long addr, unsigned long pfn, unsigned long size);
-
-#endif /* _LINUX_IO_MAPPING_H */
diff --git a/mm/Kconfig b/mm/Kconfig
index 0287e8d94aea..b7a47bb593d6 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -1254,10 +1254,6 @@ config KMAP_LOCAL
config KMAP_LOCAL_NON_LINEAR_PTE_ARRAY
bool
-# struct io_mapping based helper. Selected by drivers that need them
-config IO_MAPPING
- bool
-
config MEMFD_CREATE
bool "Enable memfd_create() system call" if EXPERT
diff --git a/mm/Makefile b/mm/Makefile
index 690ddcf7d9a1..e4ab5ca755d1 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -142,7 +142,6 @@ obj-$(CONFIG_MEMFD_CREATE) += memfd.o
obj-$(CONFIG_MAPPING_DIRTY_HELPERS) += mapping_dirty_helpers.o
obj-$(CONFIG_PTDUMP) += ptdump.o
obj-$(CONFIG_PAGE_REPORTING) += page_reporting.o
-obj-$(CONFIG_IO_MAPPING) += io-mapping.o
obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o
obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o
obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o
diff --git a/mm/io-mapping.c b/mm/io-mapping.c
deleted file mode 100644
index d3586e95c12c..000000000000
--- a/mm/io-mapping.c
+++ /dev/null
@@ -1,30 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-
-#include <linux/mm.h>
-#include <linux/io-mapping.h>
-
-/**
- * io_mapping_map_user - remap an I/O mapping to userspace
- * @iomap: the source io_mapping
- * @vma: user vma to map to
- * @addr: target user address to start at
- * @pfn: physical address of kernel memory
- * @size: size of map area
- *
- * Note: this is only safe if the mm semaphore is held when called.
- */
-int io_mapping_map_user(struct io_mapping *iomap, struct vm_area_struct *vma,
- unsigned long addr, unsigned long pfn, unsigned long size)
-{
- vm_flags_t expected_flags = VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
-
- if (WARN_ON_ONCE((vma->vm_flags & expected_flags) != expected_flags))
- return -EINVAL;
-
- pgprot_t remap_prot = __pgprot((pgprot_val(iomap->prot) & _PAGE_CACHE_MASK) |
- (pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK));
-
- /* We rely on prevalidation of the io-mapping to skip pfnmap tracking. */
- return remap_pfn_range_notrack(vma, addr, pfn, size, remap_prot);
-}
-EXPORT_SYMBOL_GPL(io_mapping_map_user);
--
2.50.1
Hi Lorenzo, kernel test robot noticed the following build errors: [auto build test ERROR on akpm-mm/mm-everything] url: https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Stoakes/mm-remove-io-mapping/20250724-225556 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20250724145313.65920-1-lorenzo.stoakes%40oracle.com patch subject: [PATCH] mm: remove io-mapping config: x86_64-buildonly-randconfig-003-20250725 (https://download.01.org/0day-ci/archive/20250726/202507261811.4FJjX1bu-lkp@intel.com/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250726/202507261811.4FJjX1bu-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202507261811.4FJjX1bu-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/net/ethernet/mellanox/mlx4/main.c:43:10: fatal error: 'linux/io-mapping.h' file not found 43 | #include <linux/io-mapping.h> | ^~~~~~~~~~~~~~~~~~~~ 1 error generated. -- >> drivers/net/ethernet/mellanox/mlx4/pd.c:36:10: fatal error: 'linux/io-mapping.h' file not found 36 | #include <linux/io-mapping.h> | ^~~~~~~~~~~~~~~~~~~~ 1 error generated. vim +43 drivers/net/ethernet/mellanox/mlx4/main.c c1b43dca137f21 drivers/net/mlx4/main.c Eli Cohen 2011-03-22 @43 #include <linux/io-mapping.h> ab9c17a009ee8e drivers/net/ethernet/mellanox/mlx4/main.c Jack Morgenstein 2011-12-13 44 #include <linux/delay.h> 10b1c04e92229e drivers/net/ethernet/mellanox/mlx4/main.c Jack Morgenstein 2016-12-29 45 #include <linux/etherdevice.h> 09d4d087cd4869 drivers/net/ethernet/mellanox/mlx4/main.c Jiri Pirko 2016-02-26 46 #include <net/devlink.h> 225c7b1feef1b4 drivers/net/mlx4/main.c Roland Dreier 2007-05-08 47 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On Sat, 26 Jul 2025 18:15:44 +0800 kernel test robot <lkp@intel.com> wrote: > kernel test robot noticed the following build errors: > > [auto build test ERROR on akpm-mm/mm-everything] > > url: https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Stoakes/mm-remove-io-mapping/20250724-225556 > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything > patch link: https://lore.kernel.org/r/20250724145313.65920-1-lorenzo.stoakes%40oracle.com > patch subject: [PATCH] mm: remove io-mapping > config: x86_64-buildonly-randconfig-003-20250725 (https://download.01.org/0day-ci/archive/20250726/202507261811.4FJjX1bu-lkp@intel.com/config) > compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250726/202507261811.4FJjX1bu-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202507261811.4FJjX1bu-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > >> drivers/net/ethernet/mellanox/mlx4/main.c:43:10: fatal error: 'linux/io-mapping.h' file not found > 43 | #include <linux/io-mapping.h> > | ^~~~~~~~~~~~~~~~~~~~ I'm all confused. include/linux/io-mapping.h is present in every tree I can find. This report doesn't identify the HEAD commit which was used?
On Sat, Jul 26, 2025 at 10:39:52AM -0700, Andrew Morton wrote: > On Sat, 26 Jul 2025 18:15:44 +0800 kernel test robot <lkp@intel.com> wrote: > > > kernel test robot noticed the following build errors: > > > > [auto build test ERROR on akpm-mm/mm-everything] > > > > url: https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Stoakes/mm-remove-io-mapping/20250724-225556 > > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything > > patch link: https://lore.kernel.org/r/20250724145313.65920-1-lorenzo.stoakes%40oracle.com > > patch subject: [PATCH] mm: remove io-mapping > > config: x86_64-buildonly-randconfig-003-20250725 (https://download.01.org/0day-ci/archive/20250726/202507261811.4FJjX1bu-lkp@intel.com/config) > > compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250726/202507261811.4FJjX1bu-lkp@intel.com/reproduce) > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > the same patch/commit), kindly add following tags > > | Reported-by: kernel test robot <lkp@intel.com> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202507261811.4FJjX1bu-lkp@intel.com/ > > > > All errors (new ones prefixed by >>): > > > > >> drivers/net/ethernet/mellanox/mlx4/main.c:43:10: fatal error: 'linux/io-mapping.h' file not found > > 43 | #include <linux/io-mapping.h> > > | ^~~~~~~~~~~~~~~~~~~~ > > I'm all confused. include/linux/io-mapping.h is present in every tree > I can find. This report doesn't identify the HEAD commit which was > used? It's testing against this original version of the series that incorrectly removed the header (long week :>). The v2 of this series does the right thing (just remove the one dead code function, file it's in and related Makefile, Kconfig stuff). Anyway yes this test report is totally redundant! Cheers, Lorenzo
Lorenzo Stoakes <lorenzo.stoakes@oracle.com> writes: > This is dead code, which was used from commit b739f125e4eb ("i915: use > io_mapping_map_user") but reverted a month later by commit > 0e4fe0c9f2f9 ("Revert "i915: use io_mapping_map_user"") back in 2021. > > Since then nobody has used it, so remove it. > > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> > --- > include/linux/io-mapping.h | 231 ------------------------------------- > mm/Kconfig | 4 - > mm/Makefile | 1 - > mm/io-mapping.c | 30 ----- > 4 files changed, 266 deletions(-) > delete mode 100644 include/linux/io-mapping.h > delete mode 100644 mm/io-mapping.c [...] > -/* > - * The io_mapping mechanism provides an abstraction for mapping > - * individual pages from an io device to the CPU in an efficient fashion. > - * > - * See Documentation/driver-api/io-mapping.rst > - */ ^ | You'll want to get rid of that file --+ too jon
On Thu, Jul 24, 2025 at 12:53:00PM -0600, Jonathan Corbet wrote: > Lorenzo Stoakes <lorenzo.stoakes@oracle.com> writes: > > > This is dead code, which was used from commit b739f125e4eb ("i915: use > > io_mapping_map_user") but reverted a month later by commit > > 0e4fe0c9f2f9 ("Revert "i915: use io_mapping_map_user"") back in 2021. > > > > Since then nobody has used it, so remove it. > > > > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> > > --- > > include/linux/io-mapping.h | 231 ------------------------------------- > > mm/Kconfig | 4 - > > mm/Makefile | 1 - > > mm/io-mapping.c | 30 ----- > > 4 files changed, 266 deletions(-) > > delete mode 100644 include/linux/io-mapping.h > > delete mode 100644 mm/io-mapping.c > > [...] > > > -/* > > - * The io_mapping mechanism provides an abstraction for mapping > > - * individual pages from an io device to the CPU in an efficient fashion. > > - * > > - * See Documentation/driver-api/io-mapping.rst > > - */ > ^ > | > You'll want to get rid of that file --+ too > > jon Thanks for this, but it turns out we aren't getting rid of the header at all (doh!) just io_mapping_map_user()... It's been a long week :) Cheers, Lorenzo
Sorry Andrew please ignore this for now, I'll send a v2 later. I'm not having a great day here... I wrongly assumed that, since this is wholly unused in practice, that nobody would refer to it or include the header, but it turns out that's incorrect. Thanks. On Thu, Jul 24, 2025 at 03:53:12PM +0100, Lorenzo Stoakes wrote: > This is dead code, which was used from commit b739f125e4eb ("i915: use > io_mapping_map_user") but reverted a month later by commit > 0e4fe0c9f2f9 ("Revert "i915: use io_mapping_map_user"") back in 2021. > > Since then nobody has used it, so remove it. > > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> > --- > include/linux/io-mapping.h | 231 ------------------------------------- > mm/Kconfig | 4 - > mm/Makefile | 1 - > mm/io-mapping.c | 30 ----- > 4 files changed, 266 deletions(-) > delete mode 100644 include/linux/io-mapping.h > delete mode 100644 mm/io-mapping.c > > diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h > deleted file mode 100644 > index 7376c1df9c90..000000000000 > --- a/include/linux/io-mapping.h > +++ /dev/null > @@ -1,231 +0,0 @@ > -/* SPDX-License-Identifier: GPL-2.0-only */ > -/* > - * Copyright © 2008 Keith Packard <keithp@keithp.com> > - */ > - > -#ifndef _LINUX_IO_MAPPING_H > -#define _LINUX_IO_MAPPING_H > - > -#include <linux/types.h> > -#include <linux/slab.h> > -#include <linux/bug.h> > -#include <linux/io.h> > -#include <linux/pgtable.h> > -#include <asm/page.h> > - > -/* > - * The io_mapping mechanism provides an abstraction for mapping > - * individual pages from an io device to the CPU in an efficient fashion. > - * > - * See Documentation/driver-api/io-mapping.rst > - */ > - > -struct io_mapping { > - resource_size_t base; > - unsigned long size; > - pgprot_t prot; > - void __iomem *iomem; > -}; > - > -#ifdef CONFIG_HAVE_ATOMIC_IOMAP > - > -#include <linux/pfn.h> > -#include <asm/iomap.h> > -/* > - * For small address space machines, mapping large objects > - * into the kernel virtual space isn't practical. Where > - * available, use fixmap support to dynamically map pages > - * of the object at run time. > - */ > - > -static inline struct io_mapping * > -io_mapping_init_wc(struct io_mapping *iomap, > - resource_size_t base, > - unsigned long size) > -{ > - pgprot_t prot; > - > - if (iomap_create_wc(base, size, &prot)) > - return NULL; > - > - iomap->base = base; > - iomap->size = size; > - iomap->prot = prot; > - return iomap; > -} > - > -static inline void > -io_mapping_fini(struct io_mapping *mapping) > -{ > - iomap_free(mapping->base, mapping->size); > -} > - > -/* Atomic map/unmap */ > -static inline void __iomem * > -io_mapping_map_atomic_wc(struct io_mapping *mapping, > - unsigned long offset) > -{ > - resource_size_t phys_addr; > - > - BUG_ON(offset >= mapping->size); > - phys_addr = mapping->base + offset; > - if (!IS_ENABLED(CONFIG_PREEMPT_RT)) > - preempt_disable(); > - else > - migrate_disable(); > - pagefault_disable(); > - return __iomap_local_pfn_prot(PHYS_PFN(phys_addr), mapping->prot); > -} > - > -static inline void > -io_mapping_unmap_atomic(void __iomem *vaddr) > -{ > - kunmap_local_indexed((void __force *)vaddr); > - pagefault_enable(); > - if (!IS_ENABLED(CONFIG_PREEMPT_RT)) > - preempt_enable(); > - else > - migrate_enable(); > -} > - > -static inline void __iomem * > -io_mapping_map_local_wc(struct io_mapping *mapping, unsigned long offset) > -{ > - resource_size_t phys_addr; > - > - BUG_ON(offset >= mapping->size); > - phys_addr = mapping->base + offset; > - return __iomap_local_pfn_prot(PHYS_PFN(phys_addr), mapping->prot); > -} > - > -static inline void io_mapping_unmap_local(void __iomem *vaddr) > -{ > - kunmap_local_indexed((void __force *)vaddr); > -} > - > -static inline void __iomem * > -io_mapping_map_wc(struct io_mapping *mapping, > - unsigned long offset, > - unsigned long size) > -{ > - resource_size_t phys_addr; > - > - BUG_ON(offset >= mapping->size); > - phys_addr = mapping->base + offset; > - > - return ioremap_wc(phys_addr, size); > -} > - > -static inline void > -io_mapping_unmap(void __iomem *vaddr) > -{ > - iounmap(vaddr); > -} > - > -#else /* HAVE_ATOMIC_IOMAP */ > - > -#include <linux/uaccess.h> > - > -/* Create the io_mapping object*/ > -static inline struct io_mapping * > -io_mapping_init_wc(struct io_mapping *iomap, > - resource_size_t base, > - unsigned long size) > -{ > - iomap->iomem = ioremap_wc(base, size); > - if (!iomap->iomem) > - return NULL; > - > - iomap->base = base; > - iomap->size = size; > - iomap->prot = pgprot_writecombine(PAGE_KERNEL); > - > - return iomap; > -} > - > -static inline void > -io_mapping_fini(struct io_mapping *mapping) > -{ > - iounmap(mapping->iomem); > -} > - > -/* Non-atomic map/unmap */ > -static inline void __iomem * > -io_mapping_map_wc(struct io_mapping *mapping, > - unsigned long offset, > - unsigned long size) > -{ > - return mapping->iomem + offset; > -} > - > -static inline void > -io_mapping_unmap(void __iomem *vaddr) > -{ > -} > - > -/* Atomic map/unmap */ > -static inline void __iomem * > -io_mapping_map_atomic_wc(struct io_mapping *mapping, > - unsigned long offset) > -{ > - if (!IS_ENABLED(CONFIG_PREEMPT_RT)) > - preempt_disable(); > - else > - migrate_disable(); > - pagefault_disable(); > - return io_mapping_map_wc(mapping, offset, PAGE_SIZE); > -} > - > -static inline void > -io_mapping_unmap_atomic(void __iomem *vaddr) > -{ > - io_mapping_unmap(vaddr); > - pagefault_enable(); > - if (!IS_ENABLED(CONFIG_PREEMPT_RT)) > - preempt_enable(); > - else > - migrate_enable(); > -} > - > -static inline void __iomem * > -io_mapping_map_local_wc(struct io_mapping *mapping, unsigned long offset) > -{ > - return io_mapping_map_wc(mapping, offset, PAGE_SIZE); > -} > - > -static inline void io_mapping_unmap_local(void __iomem *vaddr) > -{ > - io_mapping_unmap(vaddr); > -} > - > -#endif /* !HAVE_ATOMIC_IOMAP */ > - > -static inline struct io_mapping * > -io_mapping_create_wc(resource_size_t base, > - unsigned long size) > -{ > - struct io_mapping *iomap; > - > - iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); > - if (!iomap) > - return NULL; > - > - if (!io_mapping_init_wc(iomap, base, size)) { > - kfree(iomap); > - return NULL; > - } > - > - return iomap; > -} > - > -static inline void > -io_mapping_free(struct io_mapping *iomap) > -{ > - io_mapping_fini(iomap); > - kfree(iomap); > -} > - > -int io_mapping_map_user(struct io_mapping *iomap, struct vm_area_struct *vma, > - unsigned long addr, unsigned long pfn, unsigned long size); > - > -#endif /* _LINUX_IO_MAPPING_H */ > diff --git a/mm/Kconfig b/mm/Kconfig > index 0287e8d94aea..b7a47bb593d6 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -1254,10 +1254,6 @@ config KMAP_LOCAL > config KMAP_LOCAL_NON_LINEAR_PTE_ARRAY > bool > > -# struct io_mapping based helper. Selected by drivers that need them > -config IO_MAPPING > - bool > - > config MEMFD_CREATE > bool "Enable memfd_create() system call" if EXPERT > > diff --git a/mm/Makefile b/mm/Makefile > index 690ddcf7d9a1..e4ab5ca755d1 100644 > --- a/mm/Makefile > +++ b/mm/Makefile > @@ -142,7 +142,6 @@ obj-$(CONFIG_MEMFD_CREATE) += memfd.o > obj-$(CONFIG_MAPPING_DIRTY_HELPERS) += mapping_dirty_helpers.o > obj-$(CONFIG_PTDUMP) += ptdump.o > obj-$(CONFIG_PAGE_REPORTING) += page_reporting.o > -obj-$(CONFIG_IO_MAPPING) += io-mapping.o > obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o > obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o > obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o > diff --git a/mm/io-mapping.c b/mm/io-mapping.c > deleted file mode 100644 > index d3586e95c12c..000000000000 > --- a/mm/io-mapping.c > +++ /dev/null > @@ -1,30 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0-only > - > -#include <linux/mm.h> > -#include <linux/io-mapping.h> > - > -/** > - * io_mapping_map_user - remap an I/O mapping to userspace > - * @iomap: the source io_mapping > - * @vma: user vma to map to > - * @addr: target user address to start at > - * @pfn: physical address of kernel memory > - * @size: size of map area > - * > - * Note: this is only safe if the mm semaphore is held when called. > - */ > -int io_mapping_map_user(struct io_mapping *iomap, struct vm_area_struct *vma, > - unsigned long addr, unsigned long pfn, unsigned long size) > -{ > - vm_flags_t expected_flags = VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP; > - > - if (WARN_ON_ONCE((vma->vm_flags & expected_flags) != expected_flags)) > - return -EINVAL; > - > - pgprot_t remap_prot = __pgprot((pgprot_val(iomap->prot) & _PAGE_CACHE_MASK) | > - (pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK)); > - > - /* We rely on prevalidation of the io-mapping to skip pfnmap tracking. */ > - return remap_pfn_range_notrack(vma, addr, pfn, size, remap_prot); > -} > -EXPORT_SYMBOL_GPL(io_mapping_map_user); > -- > 2.50.1 >
On Thu, Jul 24, 2025 at 04:39:16PM +0100, Lorenzo Stoakes wrote: > Sorry Andrew please ignore this for now, I'll send a v2 later. > > I'm not having a great day here... > > I wrongly assumed that, since this is wholly unused in practice, that nobody > would refer to it or include the header, but it turns out that's incorrect. Yeah long week :) the header is used all over the place, so we just need to drop the function decl. v2 incoming soon.
On 24.07.25 17:39, Lorenzo Stoakes wrote: > Sorry Andrew please ignore this for now, I'll send a v2 later. > > I'm not having a great day here... > > I wrongly assumed that, since this is wholly unused in practice, that nobody > would refer to it or include the header, but it turns out that's incorrect. So, do we have to keep all (and keep it in MAINTAINERS) or is it just about cleaning up the headers? -- Cheers, David / dhildenb
On Thu, Jul 24, 2025 at 06:16:11PM +0200, David Hildenbrand wrote: > On 24.07.25 17:39, Lorenzo Stoakes wrote: > > Sorry Andrew please ignore this for now, I'll send a v2 later. > > > > I'm not having a great day here... > > > > I wrongly assumed that, since this is wholly unused in practice, that nobody > > would refer to it or include the header, but it turns out that's incorrect. > > So, do we have to keep all (and keep it in MAINTAINERS) or is it just about > cleaning up the headers? No we don't have to keep, I just sent this patch, then Vlastimil pointed out off-list that there were a bunch of includes that I missed. It's matching about how my day is going. I had wrongly assumed since there are no actual users, that nobody would just import this header for no reason. But hey. They do. Apparently docs also reference it. I'll just send a v2 tomorrow. Cheers, Lorenzo
On 24.07.25 16:53, Lorenzo Stoakes wrote: > This is dead code, which was used from commit b739f125e4eb ("i915: use > io_mapping_map_user") but reverted a month later by commit > 0e4fe0c9f2f9 ("Revert "i915: use io_mapping_map_user"") back in 2021. > > Since then nobody has used it, so remove it. > > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> > --- > include/linux/io-mapping.h | 231 ------------------------------------- > mm/Kconfig | 4 - > mm/Makefile | 1 - > mm/io-mapping.c | 30 ----- > 4 files changed, 266 deletions(-) > delete mode 100644 include/linux/io-mapping.h > delete mode 100644 mm/io-mapping.c IIUC, you're dropping the MAINTAINERS entry in the other patch already Acked-by: David Hildenbrand <david@redhat.com> -- Cheers, David / dhildenb
© 2016 - 2025 Red Hat, Inc.