mm, highmem: kmap_atomic rework -v3
Subsystems (33)
cover mm, highmem: kmap_atomic rework -v3
Next version of the kmap_atomic rework using Andrew's fancy CPP trickery to avoid having to convert the whole tree at once.
This is compile tested for i386-allmodconfig, frv, mips-sb1250-swarm, powerpc-ppc6xx_defconfig, sparc32_defconfig, arm-omap3 (all with HIGHEM=y).
Tested on Tile by Chris Metcalf.
Boot-tested with: i386-defconfig.
Not tested with:
- nm10300, the arch doesn't build with highmem to begin with
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/5 mm: strictly nested kmap_atomic
Ensure kmap_atomic usage is strictly nested
--- crypto/async_tx/async_memcpy.c | 2 +- crypto/blkcipher.c | 2 +- drivers/block/loop.c | 4 ++-- include/linux/highmem.h | 4 ++-- kernel/power/snapshot.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-)
crypto/async_tx/async_memcpy.c +1 -1
@@ -83,8 +83,8 @@ async_memcpy(struct page *dest, struct pmemcpy (dest_buf, src_buf, len); -kunmap_atomic (dest_buf,KM_USER0 );kunmap_atomic (src_buf,KM_USER1 ); +kunmap_atomic (dest_buf,KM_USER0 );async_tx_sync_epilog (submit); }
crypto/blkcipher.c +1 -1
@@ -89,9 +89,9 @@ static inline unsigned int blkcipher_donmemcpy (walk->dst.virt.addr, walk->page, n);blkcipher_unmap_dst (walk); }else if (!(walk->flags &BLKCIPHER_WALK_PHYS )) { -blkcipher_unmap_src (walk);if (walk->flags &BLKCIPHER_WALK_DIFF )blkcipher_unmap_dst (walk); +blkcipher_unmap_src (walk); }scatterwalk_advance (&walk->in, n);
drivers/block/loop.c +2 -2
@@ -99,8 +99,8 @@ static int transfer_none(struct loop_develse memcpy (raw_buf, loop_buf, size); -kunmap_atomic (raw_buf,KM_USER0 );kunmap_atomic (loop_buf,KM_USER1 ); +kunmap_atomic (raw_buf,KM_USER0 );cond_resched ();return 0 ; }
@@ -128,8 +128,8 @@ static int transfer_xor(struct loop_devifor (i =0 ; i < size; i++) *out++ = *in++ ^ key[(i &511 ) % keysize]; -kunmap_atomic (raw_buf,KM_USER0 );kunmap_atomic (loop_buf,KM_USER1 ); +kunmap_atomic (raw_buf,KM_USER0 );cond_resched ();return 0 ; }
include/linux/highmem.h +2 -2
@@ -191,8 +191,8 @@ static inline void copy_user_highpage(st vfrom =kmap_atomic (from,KM_USER0 ); vto =kmap_atomic (to,KM_USER1 );copy_user_page (vto, vfrom, vaddr, to); -kunmap_atomic (vfrom,KM_USER0 );kunmap_atomic (vto,KM_USER1 ); + kunmap_atomic(vfrom, KM_USER0); }#endif
@@ -204,8 +204,8 @@ static inline void copy_highpage(struct vfrom =kmap_atomic (from,KM_USER0 ); vto =kmap_atomic (to,KM_USER1 );copy_page (vto, vfrom); -kunmap_atomic (vfrom,KM_USER0 );kunmap_atomic (vto,KM_USER1 ); + kunmap_atomic(vfrom, KM_USER0); }#endif /* _LINUX_HIGHMEM_H */
kernel/power/snapshot.c +2 -2
@@ -978,8 +978,8 @@ static void copy_data_page(unsigned long src =kmap_atomic (s_page,KM_USER0 ); dst =kmap_atomic (d_page,KM_USER1 );do_copy_page (dst, src); -kunmap_atomic (src,KM_USER0 );kunmap_atomic (dst,KM_USER1 ); +kunmap_atomic (src,KM_USER0 ); }else {if (PageHighMem (d_page)) {/* Page pointed to by src may contain some kernel
@@ -2253,8 +2253,8 @@ swap_two_pages_data(struct page *p1, strmemcpy (buf, kaddr1,PAGE_SIZE );memcpy (kaddr1, kaddr2,PAGE_SIZE );memcpy (kaddr2, buf,PAGE_SIZE ); -kunmap_atomic (kaddr1,KM_USER0 );kunmap_atomic (kaddr2,KM_USER1 ); +kunmap_atomic (kaddr1,KM_USER0 ); }/**
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/5 mm: stack based kmap_atomic
In reply to Peter ZijlstraKeep the current interface but ignore the KM_type and use a stack based approach.
The advantage is that we get rid of crappy code like:
#define __KM_PTE \ (in_nmi() ? KM_NMI_PTE : \ in_irq() ? KM_IRQ_PTE : \ KM_PTE0)
and in general can stop worrying about what context we're in and what kmap slots might be appropriate for that.
The down-side is that FRV kmap_atomic gets more expensive.
For now we use a CPP trick suggested by Andrew:
#define kmap_atomic(page, args...) __kmap_atomic(page)
to avoid having to touch all kmap_atomic users in a single patch.
[ not compiled on:
- nm10300: the arch doesn't actually build with highmem to begin with ]
--- arch/arm/include/asm/highmem.h | 6 arch/arm/mm/highmem.c | 23 arch/frv/include/asm/highmem.h | 25 arch/frv/mb93090-mb00/pci-dma.c | 4 arch/frv/mm/cache-page.c | 8 arch/frv/mm/highmem.c | 51 arch/mips/include/asm/highmem.h | 18 arch/mips/mm/highmem.c | 50 arch/mn10300/include/asm/highmem.h | 42 arch/powerpc/include/asm/highmem.h | 9 arch/powerpc/mm/highmem.c | 35 arch/sparc/include/asm/highmem.h | 4 arch/sparc/mm/highmem.c | 48 arch/tile/include/asm/highmem.h | 10 arch/tile/mm/highmem.c | 85 arch/x86/include/asm/highmem.h | 11 arch/x86/include/asm/iomap.h | 4 arch/x86/kernel/crash_dump_32.c | 2 arch/x86/mm/highmem_32.c | 74 arch/x86/mm/iomap_32.c | 43 drivers/gpu/drm/i915/i915_gem.c | 9 drivers/gpu/drm/i915/i915_irq.c | 5 drivers/gpu/drm/i915/intel_overlay.c | 5 drivers/gpu/drm/nouveau/nouveau_bios.c | 8 drivers/gpu/drm/ttm/ttm_bo_util.c | 8 include/linux/highmem.h | 61 include/linux/io-mapping.h | 14 mm/highmem.c | 62 usr/src/linux-2.6/drivers/gpu/drm/nouveau/nouveau_bios.c | 6832 --------------- 29 files changed, 361 insertions(+), 7195 deletions(-)
arch/arm/mm/highmem.c +14 -9
@@ -36,18 +36,17 @@ void kunmap(struct page *page) }EXPORT_SYMBOL (kunmap); -void *kmap_atomic (struct page *page,enum km_type type) +void *__kmap_atomic (struct page *page) {unsigned int idx;unsigned long vaddr;void *kmap; +int type;pagefault_disable ();if (!PageHighMem (page))return page_address (page); -debug_kmap_atomic (type); -#ifdef CONFIG_DEBUG_HIGHMEM /* * There is no cache coherency issue when non VIVT, so force the
@@ -61,6 +60,8 @@ void *kmap_atomic(struct page *page, enuif (kmap)return kmap; + type =kmap_atomic_idx_push (); + idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#ifdef CONFIG_DEBUG_HIGHMEM
@@ -80,14 +81,17 @@ void *kmap_atomic(struct page *page, enureturn (void *)vaddr; } -EXPORT_SYMBOL (kmap_atomic); +EXPORT_SYMBOL (__kmap_atomic); -void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type) +void __kunmap_atomic (void *kvaddr) {unsigned long vaddr = (unsigned long ) kvaddr &PAGE_MASK ; -unsigned int idx = type +KM_TYPE_NR *smp_processor_id (); +int idx, type;if (kvaddr >= (void *)FIXADDR_START ) { + type =kmap_atomic_idx_pop (); + idx = type +KM_TYPE_NR *smp_processor_id (); +if (cache_is_vivt ())__cpuc_flush_dcache_area ((void *)vaddr,PAGE_SIZE );#ifdef CONFIG_DEBUG_HIGHMEM
@@ -103,15 +107,16 @@ void kunmap_atomic_notypecheck(void *kva }pagefault_enable (); } -EXPORT_SYMBOL (kunmap_atomic_notypecheck); +EXPORT_SYMBOL (__kunmap_atomic); -void *kmap_atomic_pfn (unsigned long pfn,enum km_type type) +void *kmap_atomic_pfn (unsigned long pfn) { -unsigned int idx;unsigned long vaddr; +int idx, type;pagefault_disable (); + type =kmap_atomic_idx_push (); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#ifdef CONFIG_DEBUG_HIGHMEM
arch/frv/include/asm/highmem.h +5 -20
@@ -112,12 +112,11 @@ extern struct page *kmap_atomic_to_page( (void *) damlr; \ }) -static inline void *kmap_atomic (struct page *page,enum km_type type) +static inline void *kmap_atomic_primary (struct page *page,enum km_type type) {unsigned long paddr;pagefault_disable (); -debug_kmap_atomic (type); paddr =page_to_phys (page);switch (type) {
@@ -125,14 +124,6 @@ static inline void *kmap_atomic(struct pcase 1 :return __kmap_atomic_primary (1 , paddr,3 );case 2 :return __kmap_atomic_primary (2 , paddr,4 );case 3 :return __kmap_atomic_primary (3 , paddr,5 ); -case 4 :return __kmap_atomic_primary (4 , paddr,6 ); -case 5 :return __kmap_atomic_primary (5 , paddr,7 ); -case 6 :return __kmap_atomic_primary (6 , paddr,8 ); -case 7 :return __kmap_atomic_primary (7 , paddr,9 ); -case 8 :return __kmap_atomic_primary (8 , paddr,10 ); - - case 9 ... 9 + NR_TLB_LINES - 1: -return __kmap_atomic_secondary (type -9 , paddr);default :BUG ();
@@ -152,22 +143,13 @@ do { \ asmvolatile ("tlbpr %0,gr0,#4,#1" : :"r" (vaddr) :"memory" ); \ }while (0 ) -static inline void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) +static inline void kunmap_atomic_primary(void *kvaddr, enum km_type type) {switch (type) {case 0 :__kunmap_atomic_primary (0 ,2 );break ;case 1 :__kunmap_atomic_primary (1 ,3 );break ;case 2 :__kunmap_atomic_primary (2 ,4 );break ;case 3 :__kunmap_atomic_primary (3 ,5 );break ; -case 4 :__kunmap_atomic_primary (4 ,6 );break ; -case 5 :__kunmap_atomic_primary (5 ,7 );break ; -case 6 :__kunmap_atomic_primary (6 ,8 );break ; -case 7 :__kunmap_atomic_primary (7 ,9 );break ; -case 8 :__kunmap_atomic_primary (8 ,10 );break ; - - case 9 ... 9 + NR_TLB_LINES - 1: -__kunmap_atomic_secondary (type -9 , kvaddr); -break ;default :BUG ();
@@ -175,6 +157,9 @@ static inline void kunmap_atomic_notypecpagefault_enable (); } +void *__kmap_atomic (struct page *page); +void __kunmap_atomic (void *kvaddr); +#endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */
arch/mips/mm/highmem.c +27 -23
117 lines not on this page · raw message
arch/mn10300/include/asm/highmem.h +26 -16
67 lines not on this page · raw message
arch/powerpc/mm/highmem.c +21 -14
@@ -29,17 +29,17 @@* be used in IRQ contexts, so in some (very limited) cases we need * it. */ -void *kmap_atomic_prot (struct page *page,enum km_type type,pgprot_t prot) +void *kmap_atomic_prot (struct page *page,pgprot_t prot) { -unsigned int idx;unsigned long vaddr; +int idx, type;/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ pagefault_disable ();if (!PageHighMem (page))return page_address (page); -debug_kmap_atomic (type); + type =kmap_atomic_idx_push (); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#ifdef CONFIG_DEBUG_HIGHMEM
@@ -52,26 +52,33 @@ void *kmap_atomic_prot(struct page *page }EXPORT_SYMBOL (kmap_atomic_prot); -void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type) +void __kunmap_atomic (void *kvaddr) { -#ifdef CONFIG_DEBUG_HIGHMEM unsigned long vaddr = (unsigned long ) kvaddr &PAGE_MASK ; -enum fixed_addresses idx = type +KM_TYPE_NR *smp_processor_id (); +int type;if (vaddr <__fix_to_virt (FIX_KMAP_END )) {pagefault_enable ();return ; } -BUG_ON (vaddr !=__fix_to_virt (FIX_KMAP_BEGIN + idx)); + type =kmap_atomic_idx_pop (); -/* -* force other mappings to Oops if they'll try to access -* this pte without first remap it -*/ -pte_clear (&init_mm, vaddr, kmap_pte-idx); -local_flush_tlb_page (NULL , vaddr); +#ifdef CONFIG_DEBUG_HIGHMEM + { +unsigned int idx; + + idx = type +KM_TYPE_NR *smp_processor_id (); +BUG_ON (vaddr !=__fix_to_virt (FIX_KMAP_BEGIN + idx)); + +/* +* force other mappings to Oops if they'll try to access +* this pte without first remap it +*/ +pte_clear (&init_mm, vaddr, kmap_pte-idx); +local_flush_tlb_page (NULL , vaddr); + }#endif pagefault_enable (); } -EXPORT_SYMBOL (kunmap_atomic_notypecheck); +EXPORT_SYMBOL (__kunmap_atomic);
arch/sparc/mm/highmem.c +27 -21
88 lines not on this page · raw message
arch/x86/mm/highmem_32.c +41 -33
127 lines not on this page · raw message
include/linux/highmem.h +39 -22
94 lines not on this page · raw message
mm/highmem.c +4 -58
71 lines not on this page · raw message
arch/x86/mm/iomap_32.c +26 -17
81 lines not on this page · raw message
arch/frv/mb93090-mb00/pci-dma.c +2 -2
@@ -61,14 +61,14 @@ int dma_map_sg(struct device *dev, struc dampr2 =__get_DAMPR (2 );for (i =0 ; i < nents; i++) { - vaddr =kmap_atomic (sg_page (&sg[i]), __KM_CACHE); + vaddr =kmap_atomic_primary (sg_page (&sg[i]), __KM_CACHE);frv_dcache_writeback ((unsigned long ) vaddr, (unsigned long ) vaddr +PAGE_SIZE ); } -kunmap_atomic (vaddr, __KM_CACHE); +kunmap_atomic_primary (vaddr, __KM_CACHE);if (dampr2) {__set_DAMPR (2 , dampr2);__set_IAMPR (2 , dampr2);
arch/frv/mm/cache-page.c +4 -4
@@ -26,11 +26,11 @@ void flush_dcache_page(struct page *page dampr2 =__get_DAMPR (2 ); - vaddr =kmap_atomic (page, __KM_CACHE); + vaddr =kmap_atomic_primary (page, __KM_CACHE);frv_dcache_writeback ((unsigned long ) vaddr, (unsigned long ) vaddr +PAGE_SIZE ); -kunmap_atomic (vaddr, __KM_CACHE); +kunmap_atomic_primary (vaddr, __KM_CACHE);if (dampr2) {__set_DAMPR (2 , dampr2);
@@ -54,12 +54,12 @@ void flush_icache_user_range(struct vm_a dampr2 =__get_DAMPR (2 ); - vaddr =kmap_atomic (page, __KM_CACHE); + vaddr =kmap_atomic_primary (page, __KM_CACHE); start = (start & ~PAGE_MASK ) | (unsigned long ) vaddr;frv_cache_wback_inv (start, start + len); -kunmap_atomic (vaddr, __KM_CACHE); +kunmap_atomic_primary (vaddr, __KM_CACHE);if (dampr2) {__set_DAMPR (2 , dampr2);
arch/frv/mm/highmem.c +51 -0
54 lines not on this page · raw message
arch/arm/include/asm/highmem.h +3 -3
@@ -35,9 +35,9 @@ extern void kunmap_high_l1_vipt(struct p#ifdef CONFIG_HIGHMEM extern void *kmap (struct page *page);extern void kunmap (struct page *page); -extern void *kmap_atomic (struct page *page,enum km_type type); -extern void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); -extern void *kmap_atomic_pfn (unsigned long pfn,enum km_type type); +extern void *__kmap_atomic (struct page *page); +extern void __kunmap_atomic (void *kvaddr); +extern void *kmap_atomic_pfn (unsigned long pfn);extern struct page *kmap_atomic_to_page (const void *ptr);#endif
arch/mips/include/asm/highmem.h +6 -12
@@ -45,18 +45,12 @@ extern pte_t *pkmap_page_table;extern void *kmap_high (struct page *page);extern void kunmap_high (struct page *page); -extern void *__kmap (struct page *page); -extern void __kunmap (struct page *page); -extern void *__kmap_atomic (struct page *page,enum km_type type); -extern void __kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); -extern void *kmap_atomic_pfn (unsigned long pfn,enum km_type type); -extern struct page *__kmap_atomic_to_page (void *ptr); - -#define kmap __kmap -#define kunmap __kunmap -#define kmap_atomic __kmap_atomic -#define kunmap_atomic_notypecheck __kunmap_atomic_notypecheck -#define kmap_atomic_to_page __kmap_atomic_to_page +extern void *kmap (struct page *page); +extern void kunmap (struct page *page); +extern void *__kmap_atomic (struct page *page); +extern void __kunmap_atomic (void *kvaddr); +extern void *kmap_atomic_pfn (unsigned long pfn); +extern struct page *kmap_atomic_to_page (void *ptr);#define flush_cache_kmaps () flush_cache_all()
arch/powerpc/include/asm/highmem.h +4 -5
@@ -60,9 +60,8 @@ extern pte_t *pkmap_page_table;extern void *kmap_high (struct page *page);extern void kunmap_high (struct page *page); -extern void *kmap_atomic_prot (struct page *page,enum km_type type, -pgprot_t prot); -extern void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); +extern void *kmap_atomic_prot (struct page *page,pgprot_t prot); +extern void __kunmap_atomic (void *kvaddr);static inline void *kmap (struct page *page) {
@@ -80,9 +79,9 @@ static inline void kunmap(struct page *pkunmap_high (page); } -static inline void *kmap_atomic (struct page *page,enum km_type type) +static inline void *__kmap_atomic (struct page *page) { -return kmap_atomic_prot (page, type, kmap_prot); +return kmap_atomic_prot (page, kmap_prot); }static inline struct page *kmap_atomic_to_page (void *ptr)
arch/sparc/include/asm/highmem.h +2 -2
@@ -70,8 +70,8 @@ static inline void kunmap(struct page *pkunmap_high (page); } -extern void *kmap_atomic (struct page *page,enum km_type type); -extern void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); +extern void *__kmap_atomic (struct page *page); +extern void __kunmap_atomic (void *kvaddr);extern struct page *kmap_atomic_to_page (void *vaddr);#define flush_cache_kmaps () flush_cache_all()
arch/tile/include/asm/highmem.h +5 -5
@@ -60,12 +60,12 @@ void *kmap_fix_kpte(struct page *page, i/* This macro is used only in map_new_virtual() to map "page". */ #define kmap_prot page_to_kpgprot(page) -void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); -void *kmap_atomic_pfn (unsigned long pfn,enum km_type type); -void *kmap_atomic_prot_pfn (unsigned long pfn,enum km_type type,pgprot_t prot); +void *__kmap_atomic (struct page *page); +void __kunmap_atomic (void *kvaddr); +void *kmap_atomic_pfn (unsigned long pfn); +void *kmap_atomic_prot_pfn (unsigned long pfn,pgprot_t prot);struct page *kmap_atomic_to_page (void *ptr); -void *kmap_atomic_prot (struct page *page,enum km_type type,pgprot_t prot); -void *kmap_atomic (struct page *page,enum km_type type); +void *kmap_atomic_prot (struct page *page,pgprot_t prot);void kmap_atomic_fix_kpte (struct page *page,int finished);#define flush_cache_kmaps () do { } while (0)
arch/tile/mm/highmem.c +23 -62
135 lines not on this page · raw message
arch/x86/include/asm/highmem.h +6 -5
@@ -59,11 +59,12 @@ extern void kunmap_high(struct page *pagvoid *kmap (struct page *page);void kunmap (struct page *page); -void *kmap_atomic_prot (struct page *page,enum km_type type,pgprot_t prot); -void *kmap_atomic (struct page *page,enum km_type type); -void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); -void *kmap_atomic_pfn (unsigned long pfn,enum km_type type); -void *kmap_atomic_prot_pfn (unsigned long pfn,enum km_type type,pgprot_t prot); + +void *kmap_atomic_prot (struct page *page,pgprot_t prot); +void *__kmap_atomic (struct page *page); +void __kunmap_atomic (void *kvaddr); +void *kmap_atomic_pfn (unsigned long pfn); +void *kmap_atomic_prot_pfn (unsigned long pfn,pgprot_t prot);struct page *kmap_atomic_to_page (void *ptr);#define flush_cache_kmaps () do { } while (0)
arch/x86/kernel/crash_dump_32.c +1 -1
@@ -61,7 +61,7 @@ ssize_t copy_oldmem_page(unsigned long pif (!is_crashed_pfn_valid (pfn))return -EFAULT ; - vaddr =kmap_atomic_pfn (pfn,KM_PTE0 ); + vaddr =kmap_atomic_pfn (pfn);if (!userbuf) {memcpy (buf, (vaddr + offset), csize);
arch/x86/include/asm/iomap.h +2 -2
@@ -27,10 +27,10 @@#include <asm/tlbflush.h> void __iomem * -iomap_atomic_prot_pfn (unsigned long pfn,enum km_type type,pgprot_t prot); +iomap_atomic_prot_pfn (unsigned long pfn,pgprot_t prot);void -iounmap_atomic (void __iomem *kvaddr,enum km_type type); +iounmap_atomic (void __iomem *kvaddr);int iomap_create_wc (resource_size_t base,unsigned long size,pgprot_t *prot);
drivers/gpu/drm/i915/i915_gem.c +4 -5
@@ -504,10 +504,10 @@ fast_user_write(struct io_mapping *mappichar *vaddr_atomic;unsigned long unwritten; - vaddr_atomic =io_mapping_map_atomic_wc (mapping, page_base,KM_USER0 ); + vaddr_atomic =io_mapping_map_atomic_wc (mapping, page_base); unwritten =__copy_from_user_inatomic_nocache (vaddr_atomic + page_offset, user_data, length); -io_mapping_unmap_atomic (vaddr_atomic,KM_USER0 ); +io_mapping_unmap_atomic (vaddr_atomic);if (unwritten)return -EFAULT ;return 0 ;
@@ -3327,8 +3327,7 @@ i915_gem_object_pin_and_relocate(struct reloc_offset = obj_priv->gtt_offset + reloc->offset; reloc_page =io_mapping_map_atomic_wc (dev_priv->mm.gtt_mapping, (reloc_offset & - ~(PAGE_SIZE -1 )), -KM_USER0 ); + ~(PAGE_SIZE -1 ))); reloc_entry = (uint32_t __iomem *)(reloc_page + (reloc_offset & (PAGE_SIZE -1 ))); reloc_val = target_obj_priv->gtt_offset + reloc->delta;
@@ -3339,7 +3338,7 @@ i915_gem_object_pin_and_relocate(struct readl(reloc_entry), reloc_val);#endif writel (reloc_val, reloc_entry); -io_mapping_unmap_atomic (reloc_page,KM_USER0 ); +io_mapping_unmap_atomic (reloc_page);/* The updated presumed offset for this entry will be * copied back out to the user.
drivers/gpu/drm/i915/i915_irq.c +2 -3
@@ -456,10 +456,9 @@ i915_error_object_create(struct drm_devilocal_irq_save (flags); s =io_mapping_map_atomic_wc (dev_priv->mm.gtt_mapping, - reloc_offset, -KM_IRQ0 ); + reloc_offset);memcpy_fromio (d, s,PAGE_SIZE ); -io_mapping_unmap_atomic (s,KM_IRQ0 ); +io_mapping_unmap_atomic (s);local_irq_restore (flags); dst->pages[page] = d;
drivers/gpu/drm/i915/intel_overlay.c +2 -3
@@ -185,8 +185,7 @@ static struct overlay_registers *intel_oif (OVERLAY_NONPHYSICAL (overlay->dev)) { regs =io_mapping_map_atomic_wc (dev_priv->mm.gtt_mapping, - overlay->reg_bo->gtt_offset, -KM_USER0 ); + overlay->reg_bo->gtt_offset);if (!regs) {DRM_ERROR ("failed to map overlay regs in GTT\n" );
@@ -201,7 +200,7 @@ static struct overlay_registers *intel_ostatic void intel_overlay_unmap_regs_atomic (struct intel_overlay *overlay) {if (OVERLAY_NONPHYSICAL (overlay->dev)) -io_mapping_unmap_atomic (overlay->virt_addr,KM_USER0 ); +io_mapping_unmap_atomic (overlay->virt_addr); overlay->virt_addr =NULL ;
drivers/gpu/drm/ttm/ttm_bo_util.c +4 -4
@@ -170,7 +170,7 @@ static int ttm_copy_io_ttm_page(struct t src = (void *)((unsigned long )src + (page <<PAGE_SHIFT ));#ifdef CONFIG_X86 - dst =kmap_atomic_prot (d,KM_USER0 , prot); + dst =kmap_atomic_prot (d, prot);#else if (pgprot_val (prot) !=pgprot_val (PAGE_KERNEL )) dst =vmap (&d,1 ,0 , prot);
@@ -183,7 +183,7 @@ static int ttm_copy_io_ttm_page(struct tmemcpy_fromio (dst, src,PAGE_SIZE );#ifdef CONFIG_X86 -kunmap_atomic (dst,KM_USER0 ); +kunmap_atomic (dst);#else if (pgprot_val (prot) !=pgprot_val (PAGE_KERNEL ))vunmap (dst);
@@ -206,7 +206,7 @@ static int ttm_copy_ttm_io_page(struct t dst = (void *)((unsigned long )dst + (page <<PAGE_SHIFT ));#ifdef CONFIG_X86 - src =kmap_atomic_prot (s,KM_USER0 , prot); + src =kmap_atomic_prot (s, prot);#else if (pgprot_val (prot) !=pgprot_val (PAGE_KERNEL )) src =vmap (&s,1 ,0 , prot);
@@ -219,7 +219,7 @@ static int ttm_copy_ttm_io_page(struct tmemcpy_toio (dst, src,PAGE_SIZE );#ifdef CONFIG_X86 -kunmap_atomic (src,KM_USER0 ); +kunmap_atomic (src);#else if (pgprot_val (prot) !=pgprot_val (PAGE_KERNEL ))vunmap (src);
include/linux/io-mapping.h +6 -8
@@ -81,8 +81,7 @@ io_mapping_free(struct io_mapping *mappi/* Atomic map/unmap */ static inline void __iomem *io_mapping_map_atomic_wc (struct io_mapping *mapping, -unsigned long offset, -int slot) +unsigned long offset) {resource_size_t phys_addr;unsigned long pfn;
@@ -90,13 +89,13 @@ io_mapping_map_atomic_wc(struct io_mappiBUG_ON (offset >= mapping->size); phys_addr = mapping->base + offset; pfn = (unsigned long ) (phys_addr >>PAGE_SHIFT ); -return iomap_atomic_prot_pfn (pfn, slot, mapping->prot); +return iomap_atomic_prot_pfn (pfn, mapping->prot); }static inline void -io_mapping_unmap_atomic (void __iomem *vaddr,int slot) +io_mapping_unmap_atomic (void __iomem *vaddr) { -iounmap_atomic (vaddr, slot); +iounmap_atomic (vaddr); } static inline void __iomem *
@@ -137,14 +136,13 @@ io_mapping_free(struct io_mapping *mappi/* Atomic map/unmap */ static inline void __iomem *io_mapping_map_atomic_wc (struct io_mapping *mapping, -unsigned long offset, -int slot) +unsigned long offset) {return ((char __force __iomem *) mapping) + offset; }static inline void -io_mapping_unmap_atomic (void __iomem *vaddr,int slot) +io_mapping_unmap_atomic (void __iomem *vaddr) { }
usr/src/linux-2.6/drivers/gpu/drm/nouveau/nouveau_bios.c deleted +0 -6832
1,680 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Part of the diff is not shown here. View the raw message.
PATCH 3/5 mm: Remove pte_*map_nested()
In reply to Peter ZijlstraSince we no longer need to provide KM_type, the whole pte_*map_nested() API is now redundant, remove it.
--- arch/alpha/include/asm/pgtable.h | 2 -- arch/arm/include/asm/pgtable.h | 14 ++++++-------- arch/arm/mm/fault-armv.c | 4 ++-- arch/arm/mm/pgd.c | 4 ++-- arch/avr32/include/asm/pgtable.h | 2 -- arch/cris/include/asm/pgtable.h | 2 -- arch/frv/include/asm/pgtable.h | 9 ++------- arch/ia64/include/asm/pgtable.h | 2 -- arch/m32r/include/asm/pgtable.h | 2 -- arch/m68k/include/asm/motorola_pgtable.h | 2 -- arch/m68k/include/asm/sun3_pgtable.h | 2 -- arch/microblaze/include/asm/pgtable.h | 7 ++----- arch/mips/include/asm/pgtable-32.h | 3 --- arch/mips/include/asm/pgtable-64.h | 3 --- arch/mn10300/include/asm/pgtable.h | 2 -- arch/parisc/include/asm/pgtable.h | 2 -- arch/powerpc/include/asm/pgtable-ppc32.h | 8 ++------ arch/powerpc/include/asm/pgtable-ppc64.h | 2 -- arch/s390/include/asm/pgtable.h | 2 -- arch/score/include/asm/pgtable.h | 3 --- arch/sh/include/asm/pgtable_32.h | 3 --- arch/sh/include/asm/pgtable_64.h | 2 -- arch/sparc/include/asm/pgtable_32.h | 3 --- arch/sparc/include/asm/pgtable_64.h | 2 -- arch/tile/include/asm/pgtable.h | 5 ----- arch/um/include/asm/pgtable.h | 2 -- arch/x86/include/asm/pgtable_32.h | 14 ++------------ arch/x86/include/asm/pgtable_64.h | 2 -- arch/xtensa/include/asm/pgtable.h | 3 --- mm/memory.c | 4 ++-- mm/mremap.c | 4 ++-- 31 files changed, 22 insertions(+), 99 deletions(-)
arch/alpha/include/asm/pgtable.h +0 -2
@@ -318,9 +318,7 @@ extern inline pte_t * pte_offset_kernel( }#define pte_offset_map (dir,addr) pte_offset_kernel((dir),(addr)) -#define pte_offset_map_nested (dir,addr) pte_offset_kernel((dir),(addr))#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)extern pgd_t swapper_pg_dir[1024 ];
arch/arm/include/asm/pgtable.h +6 -8
@@ -263,17 +263,15 @@ extern struct page *empty_zero_page;#define pte_page (pte) (pfn_to_page(pte_pfn(pte)))#define pte_offset_kernel (dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr)) -#define pte_offset_map (dir,addr) (__pte_map(dir, KM_PTE0) + __pte_index(addr)) -#define pte_offset_map_nested (dir,addr) (__pte_map(dir, KM_PTE1) + __pte_index(addr)) -#define pte_unmap (pte) __pte_unmap(pte, KM_PTE0) -#define pte_unmap_nested (pte) __pte_unmap(pte, KM_PTE1) +#define pte_offset_map (dir,addr) (__pte_map(dir) + __pte_index(addr)) +#define pte_unmap (pte) __pte_unmap(pte)#ifndef CONFIG_HIGHPTE -#define __pte_map (dir,km) pmd_page_vaddr(*(dir)) -#define __pte_unmap (pte,km) do { } while (0) +#define __pte_map (dir) pmd_page_vaddr(*(dir)) +#define __pte_unmap (pte) do { } while (0)#else -#define __pte_map (dir,km) ((pte_t *)kmap_atomic(pmd_page(*(dir)), km) + PTRS_PER_PTE) -#define __pte_unmap (pte,km) kunmap_atomic((pte - PTRS_PER_PTE), km) +#define __pte_map (dir) ((pte_t *)kmap_atomic(pmd_page(*(dir))) + PTRS_PER_PTE) +#define __pte_unmap (pte) kunmap_atomic((pte - PTRS_PER_PTE))#endif #define set_pte_ext (ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
arch/arm/mm/fault-armv.c +2 -2
@@ -88,13 +88,13 @@ static int adjust_pte(struct vm_area_str* open-code the spin-locking. */ ptl =pte_lockptr (vma->vm_mm, pmd); - pte =pte_offset_map_nested (pmd, address); + pte =pte_offset_map (pmd, address);spin_lock (ptl); ret =do_adjust_pte (vma, address, pfn, pte);spin_unlock (ptl); -pte_unmap_nested (pte); +pte_unmap (pte);return ret; }
arch/arm/mm/pgd.c +2 -2
@@ -57,9 +57,9 @@ pgd_t *get_pgd_slow(struct mm_struct *mm goto no_pte; init_pmd =pmd_offset (init_pgd,0 ); - init_pte =pte_offset_map_nested (init_pmd,0 ); + init_pte =pte_offset_map (init_pmd,0 );set_pte_ext (new_pte, *init_pte,0 ); -pte_unmap_nested (init_pte); +pte_unmap (init_pte);pte_unmap (new_pte); }
arch/avr32/include/asm/pgtable.h +0 -2
@@ -319,9 +319,7 @@ static inline pte_t pte_modify(pte_t pte#define pte_offset_kernel (dir, address) \ ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))#define pte_offset_map (dir, address) pte_offset_kernel(dir, address) -#define pte_offset_map_nested (dir, address) pte_offset_kernel(dir, address)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)struct vm_area_struct ; extern void update_mmu_cache(struct vm_area_struct * vma,
arch/cris/include/asm/pgtable.h +0 -2
@@ -248,10 +248,8 @@ static inline pgd_t * pgd_offset(const s ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))#define pte_offset_map (dir, address) \ ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) -#define pte_offset_map_nested (dir, address) pte_offset_map(dir, address)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)#define pte_pfn (x) ((unsigned long)(__va((x).pte)) >> PAGE_SHIFT)#define pfn_pte (pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
arch/frv/include/asm/pgtable.h +2 -7
@@ -451,17 +451,12 @@ static inline pte_t pte_modify(pte_t pte#if defined(CONFIG_HIGHPTE )#define pte_offset_map (dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) -#define pte_offset_map_nested (dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address)) -#define pte_unmap (pte) kunmap_atomic(pte, KM_PTE0) -#define pte_unmap_nested (pte) kunmap_atomic((pte), KM_PTE1) + ((pte_t *)kmap_atomic(pmd_page(*(dir))) + pte_index(address)) +#define pte_unmap (pte) kunmap_atomic(pte)#else #define pte_offset_map (dir, address) \ ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) -#define pte_offset_map_nested (dir, address) pte_offset_map((dir), (address))#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)#endif /*
arch/ia64/include/asm/pgtable.h +0 -2
@@ -406,9 +406,7 @@ pgd_offset (const struct mm_struct *mm,#define pte_index (addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))#define pte_offset_kernel (dir,addr) ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))#define pte_offset_map (dir,addr) pte_offset_kernel(dir, addr) -#define pte_offset_map_nested (dir,addr) pte_offset_map(dir, addr)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)/* atomic versions of the some PTE manipulations: */
arch/m32r/include/asm/pgtable.h +0 -2
@@ -332,9 +332,7 @@ static inline void pmd_set(pmd_t * pmdp, ((pte_t *)pmd_page_vaddr(*(dir)) + pte_index(address))#define pte_offset_map (dir, address) \ ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) -#define pte_offset_map_nested (dir, address) pte_offset_map(dir, address)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)/* Encode and de-code a swap entry */ #define __swp_type (x) (((x).val >> 2) & 0x1f)
arch/m68k/include/asm/motorola_pgtable.h +0 -2
@@ -221,9 +221,7 @@ static inline pte_t *pte_offset_kernel(p }#define pte_offset_map (pmdp,address) ((pte_t *)__pmd_page(*pmdp) + (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))) -#define pte_offset_map_nested (pmdp, address) pte_offset_map(pmdp, address)#define pte_unmap (pte) ((void)0) -#define pte_unmap_nested (pte) ((void)0)/* * Allocate and free page tables. The xxx_kernel() versions are
arch/m68k/include/asm/sun3_pgtable.h +0 -2
@@ -219,9 +219,7 @@ static inline pte_t pgoff_to_pte(unsigne#define pte_offset_kernel (pmd, address) ((pte_t *) __pmd_page(*pmd) + pte_index(address))/* FIXME: should we bother with kmap() here? */ #define pte_offset_map (pmd, address) ((pte_t *)kmap(pmd_page(*pmd)) + pte_index(address)) -#define pte_offset_map_nested (pmd, address) pte_offset_map(pmd, address)#define pte_unmap (pte) kunmap(pte) -#define pte_unmap_nested (pte) kunmap(pte)/* Macros to (de)construct the fake PTEs representing swap pages. */ #define __swp_type (x) ((x).val & 0x7F)
arch/microblaze/include/asm/pgtable.h +2 -5
@@ -497,12 +497,9 @@ static inline pmd_t *pmd_offset(pgd_t *d#define pte_offset_kernel (dir, addr) \ ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(addr))#define pte_offset_map (dir, addr) \ - ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr)) -#define pte_offset_map_nested (dir, addr) \ - ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr)) + ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr)) -#define pte_unmap (pte) kunmap_atomic(pte, KM_PTE0) -#define pte_unmap_nested (pte) kunmap_atomic(pte, KM_PTE1) +#define pte_unmap (pte) kunmap_atomic(pte)/* Encode and decode a nonlinear file mapping entry */ #define PTE_FILE_MAX_BITS 29
arch/mips/include/asm/pgtable-32.h +0 -3
@@ -154,10 +154,7 @@ pfn_pte(unsigned long pfn, pgprot_t prot#define pte_offset_map (dir, address) \ ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) -#define pte_offset_map_nested (dir, address) \ - ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))#define pte_unmap (pte) ((void)(pte)) -#define pte_unmap_nested (pte) ((void)(pte))#if defined(CONFIG_CPU_R3000 ) || defined(CONFIG_CPU_TX39XX )
arch/mips/include/asm/pgtable-64.h +0 -3
@@ -257,10 +257,7 @@ static inline pmd_t *pmd_offset(pud_t * ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))#define pte_offset_map (dir, address) \ ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) -#define pte_offset_map_nested (dir, address) \ - ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))#define pte_unmap (pte) ((void)(pte)) -#define pte_unmap_nested (pte) ((void)(pte))/* * Initialize a new pgd / pmd table with invalid pointers.
arch/mn10300/include/asm/pgtable.h +0 -2
@@ -457,9 +457,7 @@ static inline int set_kernel_exec(unsign#define pte_offset_map (dir, address) \ ((pte_t *) page_address(pmd_page(*(dir))) + pte_index(address)) -#define pte_offset_map_nested (dir, address) pte_offset_map(dir, address)#define pte_unmap (pte) do {} while (0) -#define pte_unmap_nested (pte) do {} while (0)/* * The MN10300 has external MMU info in the form of a TLB: this is adapted from
arch/parisc/include/asm/pgtable.h +0 -2
@@ -397,9 +397,7 @@ static inline pte_t pte_modify(pte_t pte#define pte_offset_kernel (pmd, address) \ ((pte_t *) pmd_page_vaddr(*(pmd)) + pte_index(address))#define pte_offset_map (pmd, address) pte_offset_kernel(pmd, address) -#define pte_offset_map_nested (pmd, address) pte_offset_kernel(pmd, address)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)#define pte_unmap (pte) do { } while (0)#define pte_unmap_nested (pte) do { } while (0)
arch/powerpc/include/asm/pgtable-ppc32.h +2 -6
@@ -308,12 +308,8 @@ static inline void __ptep_set_access_fla#define pte_offset_kernel (dir, addr) \ ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))#define pte_offset_map (dir, addr) \ - ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr)) -#define pte_offset_map_nested (dir, addr) \ - ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr)) - -#define pte_unmap (pte) kunmap_atomic(pte, KM_PTE0) -#define pte_unmap_nested (pte) kunmap_atomic(pte, KM_PTE1) + ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr)) +#define pte_unmap (pte) kunmap_atomic(pte)/* * Encode and decode a swap entry.
arch/powerpc/include/asm/pgtable-ppc64.h +0 -2
@@ -193,9 +193,7 @@ (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))#define pte_offset_map (dir,addr) pte_offset_kernel((dir), (addr)) -#define pte_offset_map_nested (dir,addr) pte_offset_kernel((dir), (addr))#define pte_unmap (pte) do { } while(0) -#define pte_unmap_nested (pte) do { } while(0)/* to find an entry in a kernel page-table-directory */ /* This now only contains the vmalloc pages */
arch/s390/include/asm/pgtable.h +0 -2
@@ -1048,9 +1048,7 @@ static inline pmd_t *pmd_offset(pud_t *p#define pte_offset (pmd, addr) ((pte_t *) pmd_deref(*(pmd)) + pte_index(addr))#define pte_offset_kernel (pmd, address) pte_offset(pmd,address)#define pte_offset_map (pmd, address) pte_offset_kernel(pmd, address) -#define pte_offset_map_nested (pmd, address) pte_offset_kernel(pmd, address)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)/* * 31 bit swap entry format:
arch/score/include/asm/pgtable.h +0 -3
@@ -88,10 +88,7 @@ static inline void pmd_clear(pmd_t *pmdp#define pte_offset_map (dir, address) \ ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) -#define pte_offset_map_nested (dir, address) \ - ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))#define pte_unmap (pte) ((void)(pte)) -#define pte_unmap_nested (pte) ((void)(pte))/* * Bits 9(_PAGE_PRESENT) and 10(_PAGE_FILE)are taken,
arch/sh/include/asm/pgtable_32.h +0 -3
@@ -429,10 +429,7 @@ static inline pte_t pte_modify(pte_t pte#define pte_offset_kernel (dir, address) \ ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))#define pte_offset_map (dir, address) pte_offset_kernel(dir, address) -#define pte_offset_map_nested (dir, address) pte_offset_kernel(dir, address) -#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)#ifdef CONFIG_X2TLB #define pte_ERROR (e) \
arch/sh/include/asm/pgtable_64.h +0 -2
@@ -84,9 +84,7 @@ static __inline__ void set_pte(pte_t *pt ((pte_t *) ((pmd_val(*(dir))) & PAGE_MASK) + pte_index((addr)))#define pte_offset_map (dir,addr) pte_offset_kernel(dir, addr) -#define pte_offset_map_nested (dir,addr) pte_offset_kernel(dir, addr)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)#ifndef __ASSEMBLY__#define IOBASE_VADDR 0xff000000
arch/sparc/include/asm/pgtable_32.h +0 -3
@@ -304,10 +304,7 @@ BTFIXUPDEF_CALL(pte_t *, pte_offset_kern* and sun4c is guaranteed to have no highmem anyway. */ #define pte_offset_map (d, a) pte_offset_kernel(d,a) -#define pte_offset_map_nested (d, a) pte_offset_kernel(d,a) -#define pte_unmap (pte) do{}while(0) -#define pte_unmap_nested (pte) do{}while(0)/* Certain architectures need to do special things when pte's * within a page table are directly modified. Thus, the following
arch/sparc/include/asm/pgtable_64.h +0 -2
@@ -652,9 +652,7 @@ static inline int pte_special(pte_t pte) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))#define pte_offset_kernel pte_index#define pte_offset_map pte_index -#define pte_offset_map_nested pte_index#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)/* Actual page table PTE updates. */ extern void tlb_batch_add (struct mm_struct *mm,unsigned long vaddr,pte_t *ptep,pte_t orig);
arch/um/include/asm/pgtable.h +0 -2
@@ -338,9 +338,7 @@ static inline pte_t pte_modify(pte_t pte ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))#define pte_offset_map (dir, address) \ ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) -#define pte_offset_map_nested (dir, address) pte_offset_map(dir, address)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)struct mm_struct ;extern pte_t *virt_to_pte (struct mm_struct *mm,unsigned long addr);
arch/x86/include/asm/pgtable_32.h +2 -12
@@ -49,24 +49,14 @@ extern void set_pmd_pfn(unsigned long, u#endif #if defined(CONFIG_HIGHPTE ) -#define __KM_PTE \ - (in_nmi() ? KM_NMI_PTE : \ - in_irq() ? KM_IRQ_PTE : \ - KM_PTE0)#define pte_offset_map (dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir)), __KM_PTE) + \ + ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \ pte_index((address))) -#define pte_offset_map_nested (dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir)), KM_PTE1) + \ - pte_index((address))) -#define pte_unmap (pte) kunmap_atomic((pte), __KM_PTE) -#define pte_unmap_nested (pte) kunmap_atomic((pte), KM_PTE1) +#define pte_unmap (pte) kunmap_atomic((pte))#else #define pte_offset_map (dir, address) \ ((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address))) -#define pte_offset_map_nested (dir, address) pte_offset_map((dir), (address))#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)#endif /* Clear a kernel PTE and flush it from the TLB */
arch/x86/include/asm/pgtable_64.h +0 -2
@@ -127,9 +127,7 @@ static inline int pgd_large(pgd_t pgd) {/* x86-64 always has all page tables mapped. */ #define pte_offset_map (dir, address) pte_offset_kernel((dir), (address)) -#define pte_offset_map_nested (dir, address) pte_offset_kernel((dir), (address))#define pte_unmap (pte) ((void)(pte))/* NOP */ -#define pte_unmap_nested (pte) ((void)(pte))/* NOP */ #define update_mmu_cache (vma, address, ptep) do { } while (0)
arch/xtensa/include/asm/pgtable.h +0 -3
@@ -324,10 +324,7 @@ ptep_set_wrprotect(struct mm_struct *mm,#define pte_offset_kernel (dir,addr) \ ((pte_t*) pmd_page_vaddr(*(dir)) + pte_index(addr))#define pte_offset_map (dir,addr) pte_offset_kernel((dir),(addr)) -#define pte_offset_map_nested (dir,addr) pte_offset_kernel((dir),(addr)) -#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)/*
mm/memory.c +2 -2
@@ -736,7 +736,7 @@ static int copy_pte_range(struct mm_stru dst_pte =pte_alloc_map_lock (dst_mm, dst_pmd, addr, &dst_ptl);if (!dst_pte)return -ENOMEM ; - src_pte =pte_offset_map_nested (src_pmd, addr); + src_pte =pte_offset_map (src_pmd, addr); src_ptl =pte_lockptr (src_mm, src_pmd);spin_lock_nested (src_ptl,SINGLE_DEPTH_NESTING ); orig_src_pte = src_pte;
@@ -767,7 +767,7 @@ static int copy_pte_range(struct mm_struarch_leave_lazy_mmu_mode ();spin_unlock (src_ptl); -pte_unmap_nested (orig_src_pte); +pte_unmap (orig_src_pte);add_mm_rss_vec (dst_mm, rss);pte_unmap_unlock (orig_dst_pte, dst_ptl);cond_resched ();
mm/mremap.c +2 -2
@@ -101,7 +101,7 @@ static void move_ptes(struct vm_area_str* pte locks because exclusive mmap_sem prevents deadlock. */ old_pte =pte_offset_map_lock (mm, old_pmd, old_addr, &old_ptl); - new_pte =pte_offset_map_nested (new_pmd, new_addr); + new_pte =pte_offset_map (new_pmd, new_addr); new_ptl =pte_lockptr (mm, new_pmd);if (new_ptl != old_ptl)spin_lock_nested (new_ptl,SINGLE_DEPTH_NESTING );
@@ -119,7 +119,7 @@ static void move_ptes(struct vm_area_strarch_leave_lazy_mmu_mode ();if (new_ptl != old_ptl)spin_unlock (new_ptl); -pte_unmap_nested (new_pte -1 ); +pte_unmap (new_pte -1 );pte_unmap_unlock (old_pte -1 , old_ptl);if (mapping)spin_unlock (&mapping->i_mmap_lock);
arch/tile/include/asm/pgtable.h +0 -5
@@ -347,15 +347,10 @@ static inline pte_t pte_modify(pte_t pteextern pte_t *_pte_offset_map (pmd_t *,unsigned long address,enum km_type );#define pte_offset_map (dir, address) \ _pte_offset_map(dir, address, KM_PTE0) -#define pte_offset_map_nested (dir, address) \ - _pte_offset_map(dir, address, KM_PTE1)#define pte_unmap (pte) kunmap_atomic(pte, KM_PTE0) -#define pte_unmap_nested (pte) kunmap_atomic(pte, KM_PTE1)#else #define pte_offset_map (dir, address) pte_offset_kernel(dir, address) -#define pte_offset_map_nested (dir, address) pte_offset_map(dir, address)#define pte_unmap (pte) do { } while (0) -#define pte_unmap_nested (pte) do { } while (0)#endif /* Clear a non-executable kernel PTE and flush it from the TLB. */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/5 perf, x86: Fix up kmap_atomic type
In reply to Peter ZijlstraNow that the KM_type stuff is history, clean up the compiler warning.
--- arch/x86/kernel/cpu/perf_event.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event.c +2 -3
@@ -49,7 +49,6 @@ static unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n) {unsigned long offset, addr = (unsigned long )from; -int type =in_nmi () ?KM_NMI :KM_IRQ0 ;unsigned long size, len =0 ;struct page *page;void *map;
@@ -63,9 +62,9 @@ copy_from_user_nmi(void *to, const void offset = addr & (PAGE_SIZE -1 ); size =min (PAGE_SIZE - offset, n - len); - map =kmap_atomic (page, type); + map =kmap_atomic (page);memcpy (to, map+offset, size); -kunmap_atomic (map, type); +kunmap_atomic (map);put_page (page); len += size;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/5 mm: highmem documentation
In reply to Peter ZijlstraDocument outlining some of the highmem issues, started by me, edited by David.
--- Documentation/vm/highmem.txt | 163 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+)
Documentation/vm/highmem.txt new file +163 -0
@@ -0,0 +1,163 @@ + + ==================== + HIGH MEMORY HANDLING + ==================== + +By: Peter Zijlstra <[email protected]> + +Contents: + + (*) What is high memory? + + (*) Temporary virtual mappings. + + (*) Using kmap_atomic. + + (*) Cost of temporary mappings. + + (*) i386 PAE. + + +==================== +WHAT IS HIGH MEMORY? +==================== + +High memory (highmem) is used when the size of physical memory approaches or +exceeds the maximum size of virtual memory. At that point it becomes +impossible for the kernel to keep all of the available physical memory mapped +at all times. This means the kernel needs to start using temporary mappings of +the pieces of physical memory that it wants to access. + +The part of (physical) memory not covered by a permanent mapping is what we +refer to as 'highmem'. There are various architecture dependent constraints on +where exactly that border lies. + +In the i386 arch, for example, we choose to map the kernel into every process's +VM space so that we don't have to pay the full TLB invalidation costs for +kernel entry/exit. This means the available virtual memory space (4GiB on +i386) has to be divided between user and kernel space. + +The traditional split for architectures using this approach is 3:1, 3GiB for +userspace and the top 1GiB for kernel space: + + +--------+ 0xffffffff + | Kernel | + +--------+ 0xc0000000 + | | + | User | + | | + +--------+ 0x00000000 + +This means that the kernel can at most map 1GiB of physical memory at any one +time, but because we need virtual address space for other things - including +temporary maps to access the rest of the physical memory - the actual direct +map will typically be less (usually around ~896MiB). + +Other architectures that have mm context tagged TLBs can have separate kernel +and user maps. Some hardware (like some ARMs), however, have limited virtual +space when they use mm context tags. + + +========================== +TEMPORARY VIRTUAL MAPPINGS +========================== + +The kernel contains several ways of creating temporary mappings: + + (*) vmap(). This can be used to make a long duration mapping of multiple + physical pages into a contiguous virtual space. It needs global + synchronization to unmap. + + (*) kmap(). This permits a short duration mapping of a single page. It needs + global synchronization, but is amortized somewhat. It is also prone to + deadlocks when using in a nested fashion, and so it is not recommended for + new code. + + (*) kmap_atomic(). This permits a very short duration mapping of a single + page. Since the mapping is restricted to the CPU that issued it, it + performs well, but the issuing task is therefore required to stay on that + CPU until it has finished, lest some other task displace its mappings. + + kmap_atomic() may also be used by interrupt contexts, since it is does not + sleep and the caller may not sleep until after kunmap_atomic() is called. + + It may be assumed that k[un]map_atomic() won't fail. + + +================= +USING KMAP_ATOMIC +================= + +When and where to use kmap_atomic() is straightforward. It is used when code +wants to access the contents of a page that might be allocated from high memory +(see __GFP_HIGHMEM), for example a page in the pagecache. The API has two +functions, and they can be used in a manner similar to the following: + + /* Find the page of interest. */ + struct page *page = find_get_page(mapping, offset); + + /* Gain access to the contents of that page. */ + void *vaddr = kmap_atomic(page); + + /* Do something to the contents of that page. */ + memset(vaddr, 0, PAGE_SIZE); + + /* Unmap that page. */ + kunmap_atomic(vaddr); + +Note that the kunmap_atomic() call takes the result of the kmap_atomic() call +not the argument. + +If you need to map two pages because you want to copy from one page to +another you need to keep the kmap_atomic calls strictly nested, like: + + vaddr1 = kmap_atomic(page1); + vaddr2 = kmap_atomic(page2); + + memcpy(vaddr1, vaddr2, PAGE_SIZE); + + kunmap_atomic(vaddr2); + kunmap_atomic(vaddr1); + + +========================== +COST OF TEMPORARY MAPPINGS +========================== + +The cost of creating temporary mappings can be quite high. The arch has to +manipulate the kernel's page tables, the data TLB and/or the MMU's registers. + +If CONFIG_HIGHMEM is not set, then the kernel will try and create a mapping +simply with a bit of arithmetic that will convert the page struct address into +a pointer to the page contents rather than juggling mappings about. In such a +case, the unmap operation may be a null operation. + +If CONFIG_MMU is not set, then there can be no temporary mappings and no +highmem. In such a case, the arithmetic approach will also be used. + + +======== +i386 PAE +======== + +The i386 arch, under some circumstances, will permit you to stick up to 64GiB +of RAM into your 32-bit machine. This has a number of consequences: + + (*) Linux needs a page-frame structure for each page in the system and the + pageframes need to live in the permanent mapping, which means: + + (*) you can have 896M/sizeof(struct page) page-frames at most; with struct + page being 32-bytes that would end up being something in the order of 112G + worth of pages; the kernel, however, needs to store more than just + page-frames in that memory... + + (*) PAE makes your page tables larger - which slows the system down as more + data has to be accessed to traverse in TLB fills and the like. One + advantage is that PAE has more PTE bits and can provide advanced features + like NX and PAT. + +The general recommendation is that you don't use more than 8GiB on a 32-bit +machine - although more might work for you and your workload, you're pretty +much on your own - don't expect kernel developers to really care much if things +come apart. +
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/5] mm: stack based kmap_atomic
In reply to Peter ZijlstraQuoted 3 lines · Peter Zijlstra
usr/src/linux-2.6/drivers/gpu/drm/nouveau/nouveau_bios.c | 6832 ---------------
29 files changed, 361 insertions(+), 7195 deletions(-)
What's that odd 'usr/src/linux-2.6' file that you have and removed?
You're using some seriously broken SCM there.
Linus
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/5] mm: stack based kmap_atomic
Quoted 8 lines · Linus Torvalds
Quoted 3 lines · Peter Zijlstra
usr/src/linux-2.6/drivers/gpu/drm/nouveau/nouveau_bios.c | 6832 --------------- 29 files changed, 361 insertions(+), 7195 deletions(-)What's that odd '
usr/src/linux-2.6' file that you have and removed?You're using some seriously broken SCM there.
I use quilt, no idea what happened, let me have a peek.
It seems to include a full copy of that file to remove it.. I must have done something terribly daft to make that happen.
Fixed up version below:
---
Subject: mm: stack based kmap_atomic
From: Peter Zijlstra <[email protected]>
Date: Thu Oct 08 22:10:26 CEST 2009
Keep the current interface but ignore the KM_type and use a stack based approach.
The advantage is that we get rid of crappy code like:
#define __KM_PTE \ (in_nmi() ? KM_NMI_PTE : \ in_irq() ? KM_IRQ_PTE : \ KM_PTE0)
and in general can stop worrying about what context we're in and what kmap slots might be appropriate for that.
The down-side is that FRV kmap_atomic gets more expensive.
For now we use a CPP trick suggested by Andrew:
#define kmap_atomic(page, args...) __kmap_atomic(page)
to avoid having to touch all kmap_atomic users in a single patch.
[ not compiled on:
- nm10300: the arch doesn't actually build with highmem to begin with ]
LKML-Reference: <new-submission>
--- arch/arm/include/asm/highmem.h | 6 +- arch/arm/mm/highmem.c | 23 +++++--- arch/frv/include/asm/highmem.h | 25 +-------- arch/frv/mb93090-mb00/pci-dma.c | 4 - arch/frv/mm/cache-page.c | 8 +-- arch/frv/mm/highmem.c | 51 +++++++++++++++++++ arch/mips/include/asm/highmem.h | 18 ++---- arch/mips/mm/highmem.c | 50 ++++++++++--------- arch/mn10300/include/asm/highmem.h | 42 ++++++++++------ arch/powerpc/include/asm/highmem.h | 9 +-- arch/powerpc/mm/highmem.c | 35 ++++++++----- arch/sparc/include/asm/highmem.h | 4 - arch/sparc/mm/highmem.c | 48 ++++++++++-------- arch/tile/include/asm/highmem.h | 10 +-- arch/tile/mm/highmem.c | 85 ++++++++------------------------- arch/x86/include/asm/highmem.h | 11 ++-- arch/x86/include/asm/iomap.h | 4 - arch/x86/kernel/crash_dump_32.c | 2 arch/x86/mm/highmem_32.c | 74 +++++++++++++++------------- arch/x86/mm/iomap_32.c | 43 ++++++++++------ drivers/gpu/drm/i915/i915_gem.c | 9 +-- drivers/gpu/drm/i915/i915_irq.c | 5 - drivers/gpu/drm/i915/intel_overlay.c | 5 - drivers/gpu/drm/nouveau/nouveau_bios.c | 8 +-- drivers/gpu/drm/ttm/ttm_bo_util.c | 8 +-- include/linux/highmem.h | 61 +++++++++++++++-------- include/linux/io-mapping.h | 14 ++--- mm/highmem.c | 62 +----------------------- 28 files changed, 361 insertions(+), 363 deletions(-)
arch/arm/mm/highmem.c +14 -9
@@ -36,18 +36,17 @@ void kunmap(struct page *page) }EXPORT_SYMBOL (kunmap); -void *kmap_atomic (struct page *page,enum km_type type) +void *__kmap_atomic (struct page *page) {unsigned int idx;unsigned long vaddr;void *kmap; +int type;pagefault_disable ();if (!PageHighMem (page))return page_address (page); -debug_kmap_atomic (type); -#ifdef CONFIG_DEBUG_HIGHMEM /* * There is no cache coherency issue when non VIVT, so force the
@@ -61,6 +60,8 @@ void *kmap_atomic(struct page *page, enuif (kmap)return kmap; + type =kmap_atomic_idx_push (); + idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#ifdef CONFIG_DEBUG_HIGHMEM
@@ -80,14 +81,17 @@ void *kmap_atomic(struct page *page, enureturn (void *)vaddr; } -EXPORT_SYMBOL (kmap_atomic); +EXPORT_SYMBOL (__kmap_atomic); -void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type) +void __kunmap_atomic (void *kvaddr) {unsigned long vaddr = (unsigned long ) kvaddr &PAGE_MASK ; -unsigned int idx = type +KM_TYPE_NR *smp_processor_id (); +int idx, type;if (kvaddr >= (void *)FIXADDR_START ) { + type =kmap_atomic_idx_pop (); + idx = type +KM_TYPE_NR *smp_processor_id (); +if (cache_is_vivt ())__cpuc_flush_dcache_area ((void *)vaddr,PAGE_SIZE );#ifdef CONFIG_DEBUG_HIGHMEM
@@ -103,15 +107,16 @@ void kunmap_atomic_notypecheck(void *kva }pagefault_enable (); } -EXPORT_SYMBOL (kunmap_atomic_notypecheck); +EXPORT_SYMBOL (__kunmap_atomic); -void *kmap_atomic_pfn (unsigned long pfn,enum km_type type) +void *kmap_atomic_pfn (unsigned long pfn) { -unsigned int idx;unsigned long vaddr; +int idx, type;pagefault_disable (); + type =kmap_atomic_idx_push (); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#ifdef CONFIG_DEBUG_HIGHMEM
arch/frv/include/asm/highmem.h +5 -20
@@ -112,12 +112,11 @@ extern struct page *kmap_atomic_to_page( (void *) damlr; \ }) -static inline void *kmap_atomic (struct page *page,enum km_type type) +static inline void *kmap_atomic_primary (struct page *page,enum km_type type) {unsigned long paddr;pagefault_disable (); -debug_kmap_atomic (type); paddr =page_to_phys (page);switch (type) {
@@ -125,14 +124,6 @@ static inline void *kmap_atomic(struct pcase 1 :return __kmap_atomic_primary (1 , paddr,3 );case 2 :return __kmap_atomic_primary (2 , paddr,4 );case 3 :return __kmap_atomic_primary (3 , paddr,5 ); -case 4 :return __kmap_atomic_primary (4 , paddr,6 ); -case 5 :return __kmap_atomic_primary (5 , paddr,7 ); -case 6 :return __kmap_atomic_primary (6 , paddr,8 ); -case 7 :return __kmap_atomic_primary (7 , paddr,9 ); -case 8 :return __kmap_atomic_primary (8 , paddr,10 ); - - case 9 ... 9 + NR_TLB_LINES - 1: -return __kmap_atomic_secondary (type -9 , paddr);default :BUG ();
@@ -152,22 +143,13 @@ do { \ asmvolatile ("tlbpr %0,gr0,#4,#1" : :"r" (vaddr) :"memory" ); \ }while (0 ) -static inline void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) +static inline void kunmap_atomic_primary(void *kvaddr, enum km_type type) {switch (type) {case 0 :__kunmap_atomic_primary (0 ,2 );break ;case 1 :__kunmap_atomic_primary (1 ,3 );break ;case 2 :__kunmap_atomic_primary (2 ,4 );break ;case 3 :__kunmap_atomic_primary (3 ,5 );break ; -case 4 :__kunmap_atomic_primary (4 ,6 );break ; -case 5 :__kunmap_atomic_primary (5 ,7 );break ; -case 6 :__kunmap_atomic_primary (6 ,8 );break ; -case 7 :__kunmap_atomic_primary (7 ,9 );break ; -case 8 :__kunmap_atomic_primary (8 ,10 );break ; - - case 9 ... 9 + NR_TLB_LINES - 1: -__kunmap_atomic_secondary (type -9 , kvaddr); -break ;default :BUG ();
@@ -175,6 +157,9 @@ static inline void kunmap_atomic_notypecpagefault_enable (); } +void *__kmap_atomic (struct page *page); +void __kunmap_atomic (void *kvaddr); +#endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */
arch/mips/mm/highmem.c +27 -23
117 lines not on this page · raw message
arch/mn10300/include/asm/highmem.h +26 -16
67 lines not on this page · raw message
arch/powerpc/mm/highmem.c +21 -14
@@ -29,17 +29,17 @@* be used in IRQ contexts, so in some (very limited) cases we need * it. */ -void *kmap_atomic_prot (struct page *page,enum km_type type,pgprot_t prot) +void *kmap_atomic_prot (struct page *page,pgprot_t prot) { -unsigned int idx;unsigned long vaddr; +int idx, type;/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ pagefault_disable ();if (!PageHighMem (page))return page_address (page); -debug_kmap_atomic (type); + type =kmap_atomic_idx_push (); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#ifdef CONFIG_DEBUG_HIGHMEM
@@ -52,26 +52,33 @@ void *kmap_atomic_prot(struct page *page }EXPORT_SYMBOL (kmap_atomic_prot); -void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type) +void __kunmap_atomic (void *kvaddr) { -#ifdef CONFIG_DEBUG_HIGHMEM unsigned long vaddr = (unsigned long ) kvaddr &PAGE_MASK ; -enum fixed_addresses idx = type +KM_TYPE_NR *smp_processor_id (); +int type;if (vaddr <__fix_to_virt (FIX_KMAP_END )) {pagefault_enable ();return ; } -BUG_ON (vaddr !=__fix_to_virt (FIX_KMAP_BEGIN + idx)); + type =kmap_atomic_idx_pop (); -/* -* force other mappings to Oops if they'll try to access -* this pte without first remap it -*/ -pte_clear (&init_mm, vaddr, kmap_pte-idx); -local_flush_tlb_page (NULL , vaddr); +#ifdef CONFIG_DEBUG_HIGHMEM + { +unsigned int idx; + + idx = type +KM_TYPE_NR *smp_processor_id (); +BUG_ON (vaddr !=__fix_to_virt (FIX_KMAP_BEGIN + idx)); + +/* +* force other mappings to Oops if they'll try to access +* this pte without first remap it +*/ +pte_clear (&init_mm, vaddr, kmap_pte-idx); +local_flush_tlb_page (NULL , vaddr); + }#endif pagefault_enable (); } -EXPORT_SYMBOL (kunmap_atomic_notypecheck); +EXPORT_SYMBOL (__kunmap_atomic);
arch/sparc/mm/highmem.c +27 -21
88 lines not on this page · raw message
arch/x86/mm/highmem_32.c +41 -33
127 lines not on this page · raw message
include/linux/highmem.h +39 -22
94 lines not on this page · raw message
mm/highmem.c +4 -58
71 lines not on this page · raw message
arch/x86/mm/iomap_32.c +26 -17
81 lines not on this page · raw message
arch/frv/mb93090-mb00/pci-dma.c +2 -2
@@ -61,14 +61,14 @@ int dma_map_sg(struct device *dev, struc dampr2 =__get_DAMPR (2 );for (i =0 ; i < nents; i++) { - vaddr =kmap_atomic (sg_page (&sg[i]), __KM_CACHE); + vaddr =kmap_atomic_primary (sg_page (&sg[i]), __KM_CACHE);frv_dcache_writeback ((unsigned long ) vaddr, (unsigned long ) vaddr +PAGE_SIZE ); } -kunmap_atomic (vaddr, __KM_CACHE); +kunmap_atomic_primary (vaddr, __KM_CACHE);if (dampr2) {__set_DAMPR (2 , dampr2);__set_IAMPR (2 , dampr2);
arch/frv/mm/cache-page.c +4 -4
@@ -26,11 +26,11 @@ void flush_dcache_page(struct page *page dampr2 =__get_DAMPR (2 ); - vaddr =kmap_atomic (page, __KM_CACHE); + vaddr =kmap_atomic_primary (page, __KM_CACHE);frv_dcache_writeback ((unsigned long ) vaddr, (unsigned long ) vaddr +PAGE_SIZE ); -kunmap_atomic (vaddr, __KM_CACHE); +kunmap_atomic_primary (vaddr, __KM_CACHE);if (dampr2) {__set_DAMPR (2 , dampr2);
@@ -54,12 +54,12 @@ void flush_icache_user_range(struct vm_a dampr2 =__get_DAMPR (2 ); - vaddr =kmap_atomic (page, __KM_CACHE); + vaddr =kmap_atomic_primary (page, __KM_CACHE); start = (start & ~PAGE_MASK ) | (unsigned long ) vaddr;frv_cache_wback_inv (start, start + len); -kunmap_atomic (vaddr, __KM_CACHE); +kunmap_atomic_primary (vaddr, __KM_CACHE);if (dampr2) {__set_DAMPR (2 , dampr2);
arch/frv/mm/highmem.c +51 -0
54 lines not on this page · raw message
arch/arm/include/asm/highmem.h +3 -3
@@ -35,9 +35,9 @@ extern void kunmap_high_l1_vipt(struct p#ifdef CONFIG_HIGHMEM extern void *kmap (struct page *page);extern void kunmap (struct page *page); -extern void *kmap_atomic (struct page *page,enum km_type type); -extern void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); -extern void *kmap_atomic_pfn (unsigned long pfn,enum km_type type); +extern void *__kmap_atomic (struct page *page); +extern void __kunmap_atomic (void *kvaddr); +extern void *kmap_atomic_pfn (unsigned long pfn);extern struct page *kmap_atomic_to_page (const void *ptr);#endif
arch/mips/include/asm/highmem.h +6 -12
@@ -45,18 +45,12 @@ extern pte_t *pkmap_page_table;extern void *kmap_high (struct page *page);extern void kunmap_high (struct page *page); -extern void *__kmap (struct page *page); -extern void __kunmap (struct page *page); -extern void *__kmap_atomic (struct page *page,enum km_type type); -extern void __kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); -extern void *kmap_atomic_pfn (unsigned long pfn,enum km_type type); -extern struct page *__kmap_atomic_to_page (void *ptr); - -#define kmap __kmap -#define kunmap __kunmap -#define kmap_atomic __kmap_atomic -#define kunmap_atomic_notypecheck __kunmap_atomic_notypecheck -#define kmap_atomic_to_page __kmap_atomic_to_page +extern void *kmap (struct page *page); +extern void kunmap (struct page *page); +extern void *__kmap_atomic (struct page *page); +extern void __kunmap_atomic (void *kvaddr); +extern void *kmap_atomic_pfn (unsigned long pfn); +extern struct page *kmap_atomic_to_page (void *ptr);#define flush_cache_kmaps () flush_cache_all()
arch/powerpc/include/asm/highmem.h +4 -5
@@ -60,9 +60,8 @@ extern pte_t *pkmap_page_table;extern void *kmap_high (struct page *page);extern void kunmap_high (struct page *page); -extern void *kmap_atomic_prot (struct page *page,enum km_type type, -pgprot_t prot); -extern void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); +extern void *kmap_atomic_prot (struct page *page,pgprot_t prot); +extern void __kunmap_atomic (void *kvaddr);static inline void *kmap (struct page *page) {
@@ -80,9 +79,9 @@ static inline void kunmap(struct page *pkunmap_high (page); } -static inline void *kmap_atomic (struct page *page,enum km_type type) +static inline void *__kmap_atomic (struct page *page) { -return kmap_atomic_prot (page, type, kmap_prot); +return kmap_atomic_prot (page, kmap_prot); }static inline struct page *kmap_atomic_to_page (void *ptr)
arch/sparc/include/asm/highmem.h +2 -2
@@ -70,8 +70,8 @@ static inline void kunmap(struct page *pkunmap_high (page); } -extern void *kmap_atomic (struct page *page,enum km_type type); -extern void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); +extern void *__kmap_atomic (struct page *page); +extern void __kunmap_atomic (void *kvaddr);extern struct page *kmap_atomic_to_page (void *vaddr);#define flush_cache_kmaps () flush_cache_all()
arch/tile/include/asm/highmem.h +5 -5
@@ -60,12 +60,12 @@ void *kmap_fix_kpte(struct page *page, i/* This macro is used only in map_new_virtual() to map "page". */ #define kmap_prot page_to_kpgprot(page) -void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); -void *kmap_atomic_pfn (unsigned long pfn,enum km_type type); -void *kmap_atomic_prot_pfn (unsigned long pfn,enum km_type type,pgprot_t prot); +void *__kmap_atomic (struct page *page); +void __kunmap_atomic (void *kvaddr); +void *kmap_atomic_pfn (unsigned long pfn); +void *kmap_atomic_prot_pfn (unsigned long pfn,pgprot_t prot);struct page *kmap_atomic_to_page (void *ptr); -void *kmap_atomic_prot (struct page *page,enum km_type type,pgprot_t prot); -void *kmap_atomic (struct page *page,enum km_type type); +void *kmap_atomic_prot (struct page *page,pgprot_t prot);void kmap_atomic_fix_kpte (struct page *page,int finished);#define flush_cache_kmaps () do { } while (0)
arch/tile/mm/highmem.c +23 -62
135 lines not on this page · raw message
arch/x86/include/asm/highmem.h +6 -5
@@ -59,11 +59,12 @@ extern void kunmap_high(struct page *pagvoid *kmap (struct page *page);void kunmap (struct page *page); -void *kmap_atomic_prot (struct page *page,enum km_type type,pgprot_t prot); -void *kmap_atomic (struct page *page,enum km_type type); -void kunmap_atomic_notypecheck (void *kvaddr,enum km_type type); -void *kmap_atomic_pfn (unsigned long pfn,enum km_type type); -void *kmap_atomic_prot_pfn (unsigned long pfn,enum km_type type,pgprot_t prot); + +void *kmap_atomic_prot (struct page *page,pgprot_t prot); +void *__kmap_atomic (struct page *page); +void __kunmap_atomic (void *kvaddr); +void *kmap_atomic_pfn (unsigned long pfn); +void *kmap_atomic_prot_pfn (unsigned long pfn,pgprot_t prot);struct page *kmap_atomic_to_page (void *ptr);#define flush_cache_kmaps () do { } while (0)
arch/x86/kernel/crash_dump_32.c +1 -1
@@ -61,7 +61,7 @@ ssize_t copy_oldmem_page(unsigned long pif (!is_crashed_pfn_valid (pfn))return -EFAULT ; - vaddr =kmap_atomic_pfn (pfn,KM_PTE0 ); + vaddr =kmap_atomic_pfn (pfn);if (!userbuf) {memcpy (buf, (vaddr + offset), csize);
arch/x86/include/asm/iomap.h +2 -2
@@ -27,10 +27,10 @@#include <asm/tlbflush.h> void __iomem * -iomap_atomic_prot_pfn (unsigned long pfn,enum km_type type,pgprot_t prot); +iomap_atomic_prot_pfn (unsigned long pfn,pgprot_t prot);void -iounmap_atomic (void __iomem *kvaddr,enum km_type type); +iounmap_atomic (void __iomem *kvaddr);int iomap_create_wc (resource_size_t base,unsigned long size,pgprot_t *prot);
drivers/gpu/drm/i915/i915_gem.c +4 -5
@@ -508,10 +508,10 @@ fast_user_write(struct io_mapping *mappichar *vaddr_atomic;unsigned long unwritten; - vaddr_atomic =io_mapping_map_atomic_wc (mapping, page_base,KM_USER0 ); + vaddr_atomic =io_mapping_map_atomic_wc (mapping, page_base); unwritten =__copy_from_user_inatomic_nocache (vaddr_atomic + page_offset, user_data, length); -io_mapping_unmap_atomic (vaddr_atomic,KM_USER0 ); +io_mapping_unmap_atomic (vaddr_atomic);if (unwritten)return -EFAULT ;return 0 ;
@@ -3331,8 +3331,7 @@ i915_gem_object_pin_and_relocate(struct reloc_offset = obj_priv->gtt_offset + reloc->offset; reloc_page =io_mapping_map_atomic_wc (dev_priv->mm.gtt_mapping, (reloc_offset & - ~(PAGE_SIZE -1 )), -KM_USER0 ); + ~(PAGE_SIZE -1 ))); reloc_entry = (uint32_t __iomem *)(reloc_page + (reloc_offset & (PAGE_SIZE -1 ))); reloc_val = target_obj_priv->gtt_offset + reloc->delta;
@@ -3343,7 +3342,7 @@ i915_gem_object_pin_and_relocate(struct readl(reloc_entry), reloc_val);#endif writel (reloc_val, reloc_entry); -io_mapping_unmap_atomic (reloc_page,KM_USER0 ); +io_mapping_unmap_atomic (reloc_page);/* The updated presumed offset for this entry will be * copied back out to the user.
drivers/gpu/drm/i915/i915_irq.c +2 -3
@@ -456,10 +456,9 @@ i915_error_object_create(struct drm_devilocal_irq_save (flags); s =io_mapping_map_atomic_wc (dev_priv->mm.gtt_mapping, - reloc_offset, -KM_IRQ0 ); + reloc_offset);memcpy_fromio (d, s,PAGE_SIZE ); -io_mapping_unmap_atomic (s,KM_IRQ0 ); +io_mapping_unmap_atomic (s);local_irq_restore (flags); dst->pages[page] = d;
drivers/gpu/drm/i915/intel_overlay.c +2 -3
@@ -187,8 +187,7 @@ static struct overlay_registers *intel_oif (OVERLAY_NONPHYSICAL (overlay->dev)) { regs =io_mapping_map_atomic_wc (dev_priv->mm.gtt_mapping, - overlay->reg_bo->gtt_offset, -KM_USER0 ); + overlay->reg_bo->gtt_offset);if (!regs) {DRM_ERROR ("failed to map overlay regs in GTT\n" );
@@ -203,7 +202,7 @@ static struct overlay_registers *intel_ostatic void intel_overlay_unmap_regs_atomic (struct intel_overlay *overlay) {if (OVERLAY_NONPHYSICAL (overlay->dev)) -io_mapping_unmap_atomic (overlay->virt_addr,KM_USER0 ); +io_mapping_unmap_atomic (overlay->virt_addr); overlay->virt_addr =NULL ;
drivers/gpu/drm/ttm/ttm_bo_util.c +4 -4
@@ -170,7 +170,7 @@ static int ttm_copy_io_ttm_page(struct t src = (void *)((unsigned long )src + (page <<PAGE_SHIFT ));#ifdef CONFIG_X86 - dst =kmap_atomic_prot (d,KM_USER0 , prot); + dst =kmap_atomic_prot (d, prot);#else if (pgprot_val (prot) !=pgprot_val (PAGE_KERNEL )) dst =vmap (&d,1 ,0 , prot);
@@ -183,7 +183,7 @@ static int ttm_copy_io_ttm_page(struct tmemcpy_fromio (dst, src,PAGE_SIZE );#ifdef CONFIG_X86 -kunmap_atomic (dst,KM_USER0 ); +kunmap_atomic (dst);#else if (pgprot_val (prot) !=pgprot_val (PAGE_KERNEL ))vunmap (dst);
@@ -206,7 +206,7 @@ static int ttm_copy_ttm_io_page(struct t dst = (void *)((unsigned long )dst + (page <<PAGE_SHIFT ));#ifdef CONFIG_X86 - src =kmap_atomic_prot (s,KM_USER0 , prot); + src =kmap_atomic_prot (s, prot);#else if (pgprot_val (prot) !=pgprot_val (PAGE_KERNEL )) src =vmap (&s,1 ,0 , prot);
@@ -219,7 +219,7 @@ static int ttm_copy_ttm_io_page(struct tmemcpy_toio (dst, src,PAGE_SIZE );#ifdef CONFIG_X86 -kunmap_atomic (src,KM_USER0 ); +kunmap_atomic (src);#else if (pgprot_val (prot) !=pgprot_val (PAGE_KERNEL ))vunmap (src);
include/linux/io-mapping.h +6 -8
@@ -81,8 +81,7 @@ io_mapping_free(struct io_mapping *mappi/* Atomic map/unmap */ static inline void __iomem *io_mapping_map_atomic_wc (struct io_mapping *mapping, -unsigned long offset, -int slot) +unsigned long offset) {resource_size_t phys_addr;unsigned long pfn;
@@ -90,13 +89,13 @@ io_mapping_map_atomic_wc(struct io_mappiBUG_ON (offset >= mapping->size); phys_addr = mapping->base + offset; pfn = (unsigned long ) (phys_addr >>PAGE_SHIFT ); -return iomap_atomic_prot_pfn (pfn, slot, mapping->prot); +return iomap_atomic_prot_pfn (pfn, mapping->prot); }static inline void -io_mapping_unmap_atomic (void __iomem *vaddr,int slot) +io_mapping_unmap_atomic (void __iomem *vaddr) { -iounmap_atomic (vaddr, slot); +iounmap_atomic (vaddr); } static inline void __iomem *
@@ -137,14 +136,13 @@ io_mapping_free(struct io_mapping *mappi/* Atomic map/unmap */ static inline void __iomem *io_mapping_map_atomic_wc (struct io_mapping *mapping, -unsigned long offset, -int slot) +unsigned long offset) {return ((char __force __iomem *) mapping) + offset; }static inline void -io_mapping_unmap_atomic (void __iomem *vaddr,int slot) +io_mapping_unmap_atomic (void __iomem *vaddr) { }
drivers/gpu/drm/nouveau/nouveau_bios.c +4 -4
@@ -2167,11 +2167,11 @@ peek_fb(struct drm_device *dev, struct iif (off <pci_resource_len (dev->pdev,1 )) {uint8_t __iomem *p = -io_mapping_map_atomic_wc (fb, off &PAGE_MASK ,KM_USER0 ); +io_mapping_map_atomic_wc (fb, off &PAGE_MASK ); val =ioread32 (p + (off & ~PAGE_MASK )); -io_mapping_unmap_atomic (p,KM_USER0 ); +io_mapping_unmap_atomic (p); }return val;
@@ -2183,12 +2183,12 @@ poke_fb(struct drm_device *dev, struct i {if (off <pci_resource_len (dev->pdev,1 )) {uint8_t __iomem *p = -io_mapping_map_atomic_wc (fb, off &PAGE_MASK ,KM_USER0 ); +io_mapping_map_atomic_wc (fb, off &PAGE_MASK );iowrite32 (val, p + (off & ~PAGE_MASK ));wmb (); -io_mapping_unmap_atomic (p,KM_USER0 ); +io_mapping_unmap_atomic (p); } }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Peter Zijlstra
Next version of the
kmap_atomicrework using Andrew's fancy CPP trickery to avoid having to convert the whole tree at once.This is compile tested for i386-allmodconfig, frv, mips-sb1250-swarm, powerpc-ppc6xx_defconfig,
sparc32_defconfig, arm-omap3 (all with HIGHEM=y).
This break on x86, HIGHMEM=n:
arch/x86/mm/iomap_32.c: In function ‘kmap_atomic_prot_pfn’:arch/x86/mm/iomap_32.c:64: error: implicit declaration of function ‘kmap_atomic_idx_push’arch/x86/mm/iomap_32.c: In function ‘iounmap_atomic’:arch/x86/mm/iomap_32.c:101: error: implicit declaration of function ‘kmap_atomic_idx_pop’
The use of the kmap idx there looks a little delicate so I'm not sure how to fix this.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 1/1 mm,x86: fix kmap_atomic_push vs ioremap_32.c
Quoted 8 lines · Chris Wilson
Quoted 6 lines · Peter Zijlstra
Next version of the
kmap_atomicrework using Andrew's fancy CPP trickery to avoid having to convert the whole tree at once.This is compile tested for i386-allmodconfig, frv, mips-sb1250-swarm, powerpc-ppc6xx_defconfig,
sparc32_defconfig, arm-omap3 (all with HIGHEM=y).
Quoted 8 lines
This break on x86, HIGHMEM=n:
arch/x86/mm/iomap_32.c: In function ‘kmap_atomic_prot_pfn’:arch/x86/mm/iomap_32.c:64: error: implicit declaration of function ‘kmap_atomic_idx_push’arch/x86/mm/iomap_32.c: In function ‘iounmap_atomic’:arch/x86/mm/iomap_32.c:101: error: implicit declaration of function ‘kmap_atomic_idx_pop’
Christoph just complained about the same on IRC, the below seems to cure things for i386-defconfig with CONFIG_HIGHMEM=n
---
Subject: mm,x86: fix kmap_atomic_push vs ioremap_32.c
It appears i386 uses kmap_atomic infrastructure regardless of CONFIG_HIGHMEM which results in a compile error when highmem is disabled.
Cure this by providing the needed few bits for both CONFIG_HIGHMEM and CONFIG_X86_32.
--- include/linux/highmem.h | 46 +++++++++++++++++++++++++--------------------- mm/highmem.c | 6 +++++- 2 files changed, 30 insertions(+), 22 deletions(-)
include/linux/highmem.h +25 -21
@@ -37,27 +37,6 @@ extern unsigned long totalhigh_pages;void kmap_flush_unused (void ); -DECLARE_PER_CPU (int, __kmap_atomic_idx); - -static inline int kmap_atomic_idx_push (void ) -{ -int idx =__get_cpu_var (__kmap_atomic_idx)++; -#ifdef CONFIG_DEBUG_HIGHMEM -WARN_ON_ONCE (in_irq () && !irqs_disabled ()); -BUG_ON (idx >KM_TYPE_NR ); -#endif -return idx; -} - -static inline int kmap_atomic_idx_pop (void ) -{ -int idx = --__get_cpu_var (__kmap_atomic_idx); -#ifdef CONFIG_DEBUG_HIGHMEM -BUG_ON (idx <0 ); -#endif -return idx; -} -#else /* CONFIG_HIGHMEM */ static inline unsigned int nr_free_highpages (void ) {return 0 ; }
@@ -95,6 +74,31 @@ static inline void __kunmap_atomic(void *addr)#endif /* CONFIG_HIGHMEM */ +#if defined(CONFIG_HIGHMEM ) || defined(CONFIG_X86_32 ) + +DECLARE_PER_CPU (int, __kmap_atomic_idx); + +static inline int kmap_atomic_idx_push (void ) +{ +int idx =__get_cpu_var (__kmap_atomic_idx)++; +#ifdef CONFIG_DEBUG_HIGHMEM +WARN_ON_ONCE (in_irq () && !irqs_disabled ()); +BUG_ON (idx >KM_TYPE_NR ); +#endif +return idx; +} + +static inline int kmap_atomic_idx_pop (void ) +{ +int idx = --__get_cpu_var (__kmap_atomic_idx); +#ifdef CONFIG_DEBUG_HIGHMEM +BUG_ON (idx <0 ); +#endif +return idx; +} + +#endif +/* * Make both: kmap_atomic(page, idx) and kmap_atomic(page) work. */
mm/highmem.c +5 -1
@@ -29,6 +29,11 @@#include <linux/kgdb.h> #include <asm/tlbflush.h> + +#if defined(CONFIG_HIGHMEM ) || defined(CONFIG_X86_32 ) +DEFINE_PER_CPU (int, __kmap_atomic_idx); +#endif +/* * Virtual_count is not a pure "count". * 0 means that it is not mapped, and has not been mapped
@@ -43,7 +48,6 @@ unsigned long totalhigh_pages __read_mostly;EXPORT_SYMBOL (totalhigh_pages); -DEFINE_PER_CPU (int, __kmap_atomic_idx);EXPORT_PER_CPU_SYMBOL (__kmap_atomic_idx);unsigned int nr_free_highpages (void )
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] mm,x86: fix kmap_atomic_push vs ioremap_32.c
Quoted 2 lines · Peter Zijlstra
Christoph just complained about the same on IRC, the below seems to cure things for i386-defconfig with
CONFIG_HIGHMEM=n
Compiles and boots on the misbehaving box.
Thanks,
-Chris
Signature · 7 lines
Chris Wilson, Intel Open Source Technology Centre -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>