Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: abstract io_remap_pfn_range() based on PFN

The only instances in which we customise this function are ones in which we
customise the PFN used.

Instances where architectures were not passing the pgprot value through
pgprot_decrypted() are ones where pgprot_decrypted() was a no-op anyway, so
we can simply always pass pgprot through this function.

Use this fact to simplify the use of io_remap_pfn_range(), by abstracting
the PFN via io_remap_pfn_range_pfn() and using this instead of providing a
general io_remap_pfn_range() function per-architecture.

Link: https://lkml.kernel.org/r/d086191bf431b58ce3b231b4f4f555d080f60327.1760959442.git.lorenzo.stoakes@oracle.com
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Chatre, Reinette <reinette.chatre@intel.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Dave Martin <dave.martin@arm.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: James Morse <james.morse@arm.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kevin Tian <kevin.tian@intel.com>
Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Robin Murohy <robin.murphy@arm.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes and committed by
Andrew Morton
c707a68f 51e38e7d

+29 -31
-3
arch/csky/include/asm/pgtable.h
··· 263 263 #define update_mmu_cache(vma, addr, ptep) \ 264 264 update_mmu_cache_range(NULL, vma, addr, ptep, 1) 265 265 266 - #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 267 - remap_pfn_range(vma, vaddr, pfn, size, prot) 268 - 269 266 #endif /* __ASM_CSKY_PGTABLE_H */
+5 -4
arch/mips/alchemy/common/setup.c
··· 94 94 return phys_addr; 95 95 } 96 96 97 - int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long vaddr, 98 - unsigned long pfn, unsigned long size, pgprot_t prot) 97 + static inline unsigned long io_remap_pfn_range_pfn(unsigned long pfn, 98 + unsigned long size) 99 99 { 100 100 phys_addr_t phys_addr = fixup_bigphys_addr(pfn << PAGE_SHIFT, size); 101 101 102 - return remap_pfn_range(vma, vaddr, phys_addr >> PAGE_SHIFT, size, prot); 102 + return phys_addr >> PAGE_SHIFT; 103 103 } 104 - EXPORT_SYMBOL(io_remap_pfn_range); 104 + EXPORT_SYMBOL(io_remap_pfn_range_pfn); 105 + 105 106 #endif /* CONFIG_MIPS_FIXUP_BIGPHYS_ADDR */
+2 -3
arch/mips/include/asm/pgtable.h
··· 604 604 */ 605 605 #ifdef CONFIG_MIPS_FIXUP_BIGPHYS_ADDR 606 606 phys_addr_t fixup_bigphys_addr(phys_addr_t addr, phys_addr_t size); 607 - int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long vaddr, 608 - unsigned long pfn, unsigned long size, pgprot_t prot); 609 - #define io_remap_pfn_range io_remap_pfn_range 607 + unsigned long io_remap_pfn_range_pfn(unsigned long pfn, unsigned long size); 608 + #define io_remap_pfn_range_pfn io_remap_pfn_range_pfn 610 609 #else 611 610 #define fixup_bigphys_addr(addr, size) (addr) 612 611 #endif /* CONFIG_MIPS_FIXUP_BIGPHYS_ADDR */
+4 -8
arch/sparc/include/asm/pgtable_32.h
··· 395 395 #define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) 396 396 #define GET_PFN(pfn) (pfn & 0x0fffffffUL) 397 397 398 - int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long, 399 - unsigned long, pgprot_t); 400 - 401 - static inline int io_remap_pfn_range(struct vm_area_struct *vma, 402 - unsigned long from, unsigned long pfn, 403 - unsigned long size, pgprot_t prot) 398 + static inline unsigned long io_remap_pfn_range_pfn(unsigned long pfn, 399 + unsigned long size) 404 400 { 405 401 unsigned long long offset, space, phys_base; 406 402 ··· 404 408 space = GET_IOSPACE(pfn); 405 409 phys_base = offset | (space << 32ULL); 406 410 407 - return remap_pfn_range(vma, from, phys_base >> PAGE_SHIFT, size, prot); 411 + return phys_base >> PAGE_SHIFT; 408 412 } 409 - #define io_remap_pfn_range io_remap_pfn_range 413 + #define io_remap_pfn_range_pfn io_remap_pfn_range_pfn 410 414 411 415 #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS 412 416 #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
+4 -8
arch/sparc/include/asm/pgtable_64.h
··· 1048 1048 #define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) 1049 1049 #define GET_PFN(pfn) (pfn & 0x0fffffffffffffffUL) 1050 1050 1051 - int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long, 1052 - unsigned long, pgprot_t); 1053 - 1054 1051 void adi_restore_tags(struct mm_struct *mm, struct vm_area_struct *vma, 1055 1052 unsigned long addr, pte_t pte); 1056 1053 ··· 1081 1084 return 0; 1082 1085 } 1083 1086 1084 - static inline int io_remap_pfn_range(struct vm_area_struct *vma, 1085 - unsigned long from, unsigned long pfn, 1086 - unsigned long size, pgprot_t prot) 1087 + static inline unsigned long io_remap_pfn_range_pfn(unsigned long pfn, 1088 + unsigned long size) 1087 1089 { 1088 1090 unsigned long offset = GET_PFN(pfn) << PAGE_SHIFT; 1089 1091 int space = GET_IOSPACE(pfn); ··· 1090 1094 1091 1095 phys_base = offset | (((unsigned long) space) << 32UL); 1092 1096 1093 - return remap_pfn_range(vma, from, phys_base >> PAGE_SHIFT, size, prot); 1097 + return phys_base >> PAGE_SHIFT; 1094 1098 } 1095 - #define io_remap_pfn_range io_remap_pfn_range 1099 + #define io_remap_pfn_range_pfn io_remap_pfn_range_pfn 1096 1100 1097 1101 static inline unsigned long __untagged_addr(unsigned long start) 1098 1102 {
+14 -5
include/linux/mm.h
··· 3684 3684 return VM_FAULT_NOPAGE; 3685 3685 } 3686 3686 3687 - #ifndef io_remap_pfn_range 3688 - static inline int io_remap_pfn_range(struct vm_area_struct *vma, 3689 - unsigned long addr, unsigned long pfn, 3690 - unsigned long size, pgprot_t prot) 3687 + #ifndef io_remap_pfn_range_pfn 3688 + static inline unsigned long io_remap_pfn_range_pfn(unsigned long pfn, 3689 + unsigned long size) 3691 3690 { 3692 - return remap_pfn_range(vma, addr, pfn, size, pgprot_decrypted(prot)); 3691 + return pfn; 3693 3692 } 3694 3693 #endif 3694 + 3695 + static inline int io_remap_pfn_range(struct vm_area_struct *vma, 3696 + unsigned long addr, unsigned long orig_pfn, 3697 + unsigned long size, pgprot_t orig_prot) 3698 + { 3699 + const unsigned long pfn = io_remap_pfn_range_pfn(orig_pfn, size); 3700 + const pgprot_t prot = pgprot_decrypted(orig_prot); 3701 + 3702 + return remap_pfn_range(vma, addr, pfn, size, prot); 3703 + } 3695 3704 3696 3705 static inline vm_fault_t vmf_error(int err) 3697 3706 {