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

mm: introduce ARCH_HAS_PTE_DEVMAP

ARCH_HAS_ZONE_DEVICE is somewhat meaningless in itself, and combined
with the long-out-of-date comment can lead to the impression than an
architecture may just enable it (since __add_pages() now "comprehends
device memory" for itself) and expect things to work.

In practice, however, ZONE_DEVICE users have little chance of
functioning correctly without __HAVE_ARCH_PTE_DEVMAP, so let's clean
that up the same way as ARCH_HAS_PTE_SPECIAL and make it the proper
dependency so the real situation is clearer.

Link: http://lkml.kernel.org/r/87554aa78478a02a63f2c4cf60a847279ae3eb3b.1558547956.git.robin.murphy@arm.com
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Acked-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Robin Murphy and committed by
Linus Torvalds
17596731 7588adf8

+11 -14
+1 -1
arch/powerpc/Kconfig
··· 129 129 select ARCH_HAS_MMIOWB if PPC64 130 130 select ARCH_HAS_PHYS_TO_DMA 131 131 select ARCH_HAS_PMEM_API if PPC64 132 + select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 132 133 select ARCH_HAS_PTE_SPECIAL 133 134 select ARCH_HAS_MEMBARRIER_CALLBACKS 134 135 select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64 ··· 137 136 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 138 137 select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 139 138 select ARCH_HAS_UBSAN_SANITIZE_ALL 140 - select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 141 139 select ARCH_HAVE_NMI_SAFE_CMPXCHG 142 140 select ARCH_KEEP_MEMBLOCK 143 141 select ARCH_MIGHT_HAVE_PC_PARPORT
-1
arch/powerpc/include/asm/book3s/64/pgtable.h
··· 90 90 #define _PAGE_SOFT_DIRTY _RPAGE_SW3 /* software: software dirty tracking */ 91 91 #define _PAGE_SPECIAL _RPAGE_SW2 /* software: special page */ 92 92 #define _PAGE_DEVMAP _RPAGE_SW1 /* software: ZONE_DEVICE page */ 93 - #define __HAVE_ARCH_PTE_DEVMAP 94 93 95 94 /* 96 95 * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE
+1 -1
arch/x86/Kconfig
··· 70 70 select ARCH_HAS_KCOV if X86_64 71 71 select ARCH_HAS_MEMBARRIER_SYNC_CORE 72 72 select ARCH_HAS_PMEM_API if X86_64 73 + select ARCH_HAS_PTE_DEVMAP if X86_64 73 74 select ARCH_HAS_PTE_SPECIAL 74 75 select ARCH_HAS_REFCOUNT 75 76 select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 ··· 81 80 select ARCH_HAS_STRICT_MODULE_RWX 82 81 select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE 83 82 select ARCH_HAS_UBSAN_SANITIZE_ALL 84 - select ARCH_HAS_ZONE_DEVICE if X86_64 85 83 select ARCH_HAVE_NMI_SAFE_CMPXCHG 86 84 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 87 85 select ARCH_MIGHT_HAVE_PC_PARPORT
+2 -2
arch/x86/include/asm/pgtable.h
··· 271 271 return boot_cpu_has(X86_FEATURE_PSE); 272 272 } 273 273 274 - #ifdef __HAVE_ARCH_PTE_DEVMAP 274 + #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP 275 275 static inline int pmd_devmap(pmd_t pmd) 276 276 { 277 277 return !!(pmd_val(pmd) & _PAGE_DEVMAP); ··· 732 732 return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE); 733 733 } 734 734 735 - #ifdef __HAVE_ARCH_PTE_DEVMAP 735 + #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP 736 736 static inline int pte_devmap(pte_t a) 737 737 { 738 738 return (pte_flags(a) & _PAGE_DEVMAP) == _PAGE_DEVMAP;
-1
arch/x86/include/asm/pgtable_types.h
··· 103 103 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) 104 104 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) 105 105 #define _PAGE_DEVMAP (_AT(u64, 1) << _PAGE_BIT_DEVMAP) 106 - #define __HAVE_ARCH_PTE_DEVMAP 107 106 #else 108 107 #define _PAGE_NX (_AT(pteval_t, 0)) 109 108 #define _PAGE_DEVMAP (_AT(pteval_t, 0))
+2 -2
include/linux/mm.h
··· 547 547 struct mmu_gather; 548 548 struct inode; 549 549 550 - #if !defined(__HAVE_ARCH_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE) 550 + #if !defined(CONFIG_ARCH_HAS_PTE_DEVMAP) || !defined(CONFIG_TRANSPARENT_HUGEPAGE) 551 551 static inline int pmd_devmap(pmd_t pmd) 552 552 { 553 553 return 0; ··· 1750 1750 } 1751 1751 #endif 1752 1752 1753 - #ifndef __HAVE_ARCH_PTE_DEVMAP 1753 + #ifndef CONFIG_ARCH_HAS_PTE_DEVMAP 1754 1754 static inline int pte_devmap(pte_t pte) 1755 1755 { 1756 1756 return 0;
+2 -2
include/linux/pfn_t.h
··· 97 97 #endif 98 98 #endif 99 99 100 - #ifdef __HAVE_ARCH_PTE_DEVMAP 100 + #ifdef CONFIG_ARCH_HAS_PTE_DEVMAP 101 101 static inline bool pfn_t_devmap(pfn_t pfn) 102 102 { 103 103 const u64 flags = PFN_DEV|PFN_MAP; ··· 115 115 defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) 116 116 pud_t pud_mkdevmap(pud_t pud); 117 117 #endif 118 - #endif /* __HAVE_ARCH_PTE_DEVMAP */ 118 + #endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */ 119 119 120 120 #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL 121 121 static inline bool pfn_t_special(pfn_t pfn)
+2 -3
mm/Kconfig
··· 649 649 See Documentation/admin-guide/mm/idle_page_tracking.rst for 650 650 more details. 651 651 652 - # arch_add_memory() comprehends device memory 653 - config ARCH_HAS_ZONE_DEVICE 652 + config ARCH_HAS_PTE_DEVMAP 654 653 bool 655 654 656 655 config ZONE_DEVICE ··· 657 658 depends on MEMORY_HOTPLUG 658 659 depends on MEMORY_HOTREMOVE 659 660 depends on SPARSEMEM_VMEMMAP 660 - depends on ARCH_HAS_ZONE_DEVICE 661 + depends on ARCH_HAS_PTE_DEVMAP 661 662 select XARRAY_MULTI 662 663 663 664 help
+1 -1
mm/gup.c
··· 1895 1895 } 1896 1896 #endif /* CONFIG_ARCH_HAS_PTE_SPECIAL */ 1897 1897 1898 - #if defined(__HAVE_ARCH_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE) 1898 + #if defined(CONFIG_ARCH_HAS_PTE_DEVMAP) && defined(CONFIG_TRANSPARENT_HUGEPAGE) 1899 1899 static int __gup_device_huge(unsigned long pfn, unsigned long addr, 1900 1900 unsigned long end, struct page **pages, int *nr) 1901 1901 {