linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm: remove mm/io-mapping.c
@ 2025-07-25 14:29 Lorenzo Stoakes
  2025-07-25 14:38 ` Vlastimil Babka
  0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Stoakes @ 2025-07-25 14:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Christoph Hellwig, David Hildenbrand, Liam R . Howlett,
	Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
	linux-kernel, linux-mm

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>
Acked-by: David Hildenbrand <david@redhat.com>
---
v2:
* Restrict ourselves to removing only the io_mapping_map_user() function :) v1
  was rushed out and zealously assumed that io-mapping.h somehow only referred
  to this, rather silly.

v1:
https://lore.kernel.org/all/20250724145313.65920-1-lorenzo.stoakes@oracle.com/

 include/linux/io-mapping.h |  3 ---
 mm/Kconfig                 |  4 ----
 mm/Makefile                |  1 -
 mm/io-mapping.c            | 30 ------------------------------
 4 files changed, 38 deletions(-)
 delete mode 100644 mm/io-mapping.c

diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
index 7376c1df9c90..c16353cc6e3c 100644
--- a/include/linux/io-mapping.h
+++ b/include/linux/io-mapping.h
@@ -225,7 +225,4 @@ io_mapping_free(struct io_mapping *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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mm: remove mm/io-mapping.c
  2025-07-25 14:29 [PATCH v2] mm: remove mm/io-mapping.c Lorenzo Stoakes
@ 2025-07-25 14:38 ` Vlastimil Babka
  0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2025-07-25 14:38 UTC (permalink / raw)
  To: Lorenzo Stoakes, Andrew Morton
  Cc: Christoph Hellwig, David Hildenbrand, Liam R . Howlett,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko, linux-kernel,
	linux-mm

On 7/25/25 16:29, 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>
> Acked-by: David Hildenbrand <david@redhat.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

Think we'll need also to remove this line:

Documentation/core-api/mm-api.rst:.. kernel-doc:: mm/io-mapping.c



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-25 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 14:29 [PATCH v2] mm: remove mm/io-mapping.c Lorenzo Stoakes
2025-07-25 14:38 ` Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).