Generic ioremap_page_range: introduction
Subsystems (9)
cover Generic ioremap_page_range: introduction
Since no one seemed to have any serious objections, here's a complete patchset with an updated ioremap_page_range() based on suggestions from Dave Hansen, Paul Mackerras and David Miller.
This also updates all architectures that were relatively trivial to convert. Most of remaining architectures implement ioremap() as a no-op or something close. Exceptions are m68k, powerpc and sparc.
m68k has some CPU-dependent logic in the middle of the loop.
powerpc could probably use generic ioremap_page_range(), but doing so would probably increase the code size, as the map_page() functions have other users in addition to ioremap().
sparc seems to do something completely different than everyone else.
I'll post the implementation as well as one patch per architecture conversion right after this. I haven't compile-tested most of the architecture changes, but it compiles and runs on AVR32.
Overall diffstat below.
Haavard
arch/alpha/kernel/proto.h | 15 +++++- arch/alpha/mm/Makefile | 2 - arch/alpha/mm/remap.c | 86 -------------------------------- arch/arm/mm/ioremap.c | 95 ++---------------------------------- arch/avr32/mm/ioremap.c | 120 ++------------------------------------------- arch/cris/mm/ioremap.c | 88 +-------------------------------- arch/i386/mm/ioremap.c | 85 ++------------------------------ arch/m32r/mm/ioremap.c | 93 +++-------------------------------- arch/mips/mm/ioremap.c | 95 +++--------------------------------- arch/parisc/mm/ioremap.c | 111 +++--------------------------------------- arch/s390/mm/ioremap.c | 84 +------------------------------- arch/sh/mm/ioremap.c | 97 +++--------------------------------- arch/sh64/mm/ioremap.c | 100 +++----------------------------------- arch/x86_64/mm/ioremap.c | 110 ++--------------------------------------- include/linux/io.h | 4 ++ lib/Makefile | 2 - lib/ioremap.c | 91 ++++++++++++++++++++++++++++++++++ 17 files changed, 174 insertions(+), 1104 deletions(-)
PATCH 1/13 Generic ioremap_page_range: implementation
This patch adds a generic implementation of ioremap_page_range() in lib/ioremap.c based on the i386 implementation. It differs from the i386 version in the following ways:
* The PTE flags are passed as a pgprot_t argument and must be determined up front by the arch-specific code. No additional PTE flags are added.
* Uses set_pte_at() instead of set_pte()
* Doesn't call flush_cache_all() and flush_tlb_all(). Instead, it calls flush_cache_vmap() after all PTEs have been set up.
--- include/linux/io.h | 4 ++ lib/Makefile | 2 + lib/ioremap.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletions(-)
include/linux/io.h +4 -0
@@ -19,8 +19,12 @@ #ifndef _LINUX_IO_H#define _LINUX_IO_H#include <asm/io.h> +#include <asm/page.h> void __iowrite32_copy (void __iomem *to,const void *from,size_t count);void __iowrite64_copy (void __iomem *to,const void *from,size_t count); +int ioremap_page_range (unsigned long addr,unsigned long end, +unsigned long phys_addr,pgprot_t prot); +#endif /* _LINUX_IO_H */
lib/Makefile +1 -1
@@ -5,7 +5,7 @@ # lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \ bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \ idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \ - sha1.o + sha1.o ioremap.o lib-$(CONFIG_SMP) += cpumask.o
lib/ioremap.c new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
1.4.0
PATCH 2/13 Generic ioremap_page_range: alpha conversion
Convert Alpha to use generic ioremap_page_range() by turning __alpha_remap_area_pages() into an inline wrapper around ioremap_page_range().
--- arch/alpha/kernel/proto.h | 15 ++++++-- arch/alpha/mm/Makefile | 2 + arch/alpha/mm/remap.c | 86 --------------------------------------------- 3 files changed, 13 insertions(+), 90 deletions(-)
arch/alpha/kernel/proto.h +12 -3
@@ -1,5 +1,7 @@#include <linux/interrupt.h> +#include <linux/io.h> +#include <asm/pgtable.h> /* Prototypes of functions used across modules here in this directory. */
@@ -181,9 +183,16 @@ extern void titan_dispatch_irqs(u64, strextern void switch_to_system_map (void );extern void srm_paging_stop (void ); -/* ../mm/remap.c */ -extern int __alpha_remap_area_pages (unsigned long ,unsigned long , -unsigned long ,unsigned long ); +static inline int +__alpha_remap_area_pages (unsigned long address,unsigned long phys_addr, +unsigned long size,unsigned long flags) +{ +pgprot_t prot; + + prot =__pgprot (_PAGE_VALID | _PAGE_ASM | _PAGE_KRE + | _PAGE_KWE | flags); +return ioremap_page_range (address, address + size, phys_addr, prot); +}/* irq.c */
arch/alpha/mm/Makefile +1 -1
@@ -4,6 +4,6 @@ # EXTRA_CFLAGS := -Werror -obj-y := init.o fault.o extable.o remap.o +obj-y := init.o fault.o extable.o obj-$(CONFIG_DISCONTIGMEM) += numa.o
arch/alpha/mm/remap.c deleted +0 -86
86 lines not on this page · raw message
Signature · 1 line
1.4.0
PATCH 3/13 Generic ioremap_page_range: arm conversion
Convert ARM to use generic ioremap_page_range()
--- arch/arm/mm/ioremap.c | 95 +++---------------------------------------------- 1 files changed, 5 insertions(+), 90 deletions(-)
arch/arm/mm/ioremap.c +5 -90
@@ -22,11 +22,11 @@*/ #include <linux/module.h> #include <linux/errno.h> +#include <linux/io.h> #include <linux/mm.h> #include <linux/vmalloc.h> #include <asm/cacheflush.h> -#include <asm/io.h> #include <asm/mmu_context.h> #include <asm/pgalloc.h> #include <asm/tlbflush.h>
@@ -38,94 +38,6 @@ #include <asm/sizes.h>*/ #define VM_ARM_SECTION_MAPPING 0x80000000 -static inline void -remap_area_pte (pte_t * pte,unsigned long address,unsigned long size, -unsigned long phys_addr,pgprot_t pgprot) -{ -unsigned long end; - - address &= ~PMD_MASK ; - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; -BUG_ON (address >= end); -do { -if (!pte_none (*pte)) - goto bad; - -set_pte (pte,pfn_pte (phys_addr >>PAGE_SHIFT , pgprot)); - address +=PAGE_SIZE ; - phys_addr +=PAGE_SIZE ; - pte++; - }while (address && (address < end)); -return ; - - bad: -printk ("remap_area_pte: page already exists\n" ); -BUG (); -} - -static inline int -remap_area_pmd (pmd_t * pmd,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; -pgprot_t pgprot; - - address &= ~PGDIR_MASK ; - end = address + size; - -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - - phys_addr -= address; -BUG_ON (address >= end); - - pgprot =__pgprot (L_PTE_PRESENT |L_PTE_YOUNG |L_PTE_DIRTY |L_PTE_WRITE | flags); -do { -pte_t * pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; -remap_area_pte (pte, address, end - address, address + phys_addr, pgprot); - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -static int -remap_area_pages (unsigned long start,unsigned long pfn, -unsigned long size,unsigned long flags) -{ -unsigned long address = start; -unsigned long end = start + size; -unsigned long phys_addr =__pfn_to_phys (pfn); -int err =0 ; -pgd_t * dir; - - phys_addr -= address; - dir =pgd_offset (&init_mm, address); -BUG_ON (address >= end); -do { -pmd_t *pmd =pmd_alloc (&init_mm, dir, address); -if (!pmd) { - err = -ENOMEM ; -break ; - } -if (remap_area_pmd (pmd, address, end - address, - phys_addr + address, flags)) { - err = -ENOMEM ; -break ; - } - - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - dir++; - }while (address && (address < end)); - -return err; -} - -void __check_kvm_seq (struct mm_struct *mm) {unsigned int seq;
@@ -326,7 +238,10 @@ #ifndef CONFIG_SMP err =remap_area_sections (addr, pfn, size, flags); } else#endif - err =remap_area_pages (addr, pfn, size, flags); + err =ioremap_page_range (addr, addr + size, pfn <<PAGE_SHIFT , +__pgprot (L_PTE_PRESENT |L_PTE_YOUNG + |L_PTE_DIRTY |L_PTE_WRITE + | flags));if (err) {vunmap ((void *)addr);
Signature · 1 line
1.4.0
PATCH 4/13 Generic ioremap_page_range: avr32 conversion
Convert AVR32 to use generic ioremap_page_range()
--- arch/avr32/mm/ioremap.c | 120 ++--------------------------------------------- 1 files changed, 6 insertions(+), 114 deletions(-)
arch/avr32/mm/ioremap.c +6 -114
@@ -7,119 +7,11 @@*/ #include <linux/vmalloc.h> #include <linux/module.h> +#include <linux/io.h> -#include <asm/io.h> #include <asm/pgtable.h> -#include <asm/cacheflush.h> -#include <asm/tlbflush.h> #include <asm/addrspace.h> -static inline int remap_area_pte (pte_t *pte,unsigned long address, -unsigned long end,unsigned long phys_addr, -pgprot_t prot) -{ -unsigned long pfn; - - pfn = phys_addr >>PAGE_SHIFT ; -do { -WARN_ON (!pte_none (*pte)); - -set_pte (pte,pfn_pte (pfn, prot)); - address +=PAGE_SIZE ; - pfn++; - pte++; - }while (address && (address < end)); - -return 0 ; -} - -static inline int remap_area_pmd (pmd_t *pmd,unsigned long address, -unsigned long end,unsigned long phys_addr, -pgprot_t prot) -{ -unsigned long next; - - phys_addr -= address; - -do { -pte_t *pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; - - next = (address +PMD_SIZE ) &PMD_MASK ; -if (remap_area_pte (pte, address, next, - address + phys_addr, prot)) -return -ENOMEM ; - - address = next; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -static int remap_area_pud (pud_t *pud,unsigned long address, -unsigned long end,unsigned long phys_addr, -pgprot_t prot) -{ -unsigned long next; - - phys_addr -= address; - -do { -pmd_t *pmd =pmd_alloc (&init_mm, pud, address); -if (!pmd) -return -ENOMEM ; - next = (address +PUD_SIZE ) &PUD_MASK ; -if (remap_area_pmd (pmd, address, next, - phys_addr + address, prot)) -return -ENOMEM ; - - address = next; - pud++; - }while (address && address < end); - -return 0 ; -} - -static int remap_area_pages (unsigned long address,unsigned long phys_addr, -size_t size,pgprot_t prot) -{ -unsigned long end = address + size; -unsigned long next; -pgd_t *pgd; -int err =0 ; - - phys_addr -= address; - - pgd =pgd_offset_k (address); -flush_cache_all (); -BUG_ON (address >= end); - -spin_lock (&init_mm.page_table_lock); -do { -pud_t *pud =pud_alloc (&init_mm, pgd, address); - - err = -ENOMEM ; -if (!pud) -break ; - - next = (address +PGDIR_SIZE ) &PGDIR_MASK ; -if (next < address || next > end) - next = end; - err =remap_area_pud (pud, address, next, - phys_addr + address, prot); -if (err) -break ; - - address = next; - pgd++; - }while (address && (address < end)); - -spin_unlock (&init_mm.page_table_lock); -flush_tlb_all (); -return err; -} -/* * Re-map an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access physical
@@ -128,7 +20,7 @@ static int remap_area_pages(unsigned lonvoid __iomem *__ioremap (unsigned long phys_addr,size_t size,unsigned long flags) { -void *addr; +unsigned long addr;struct vm_struct *area;unsigned long offset, last_addr;pgprot_t prot;
@@ -159,7 +51,7 @@ void __iomem *__ioremap(unsigned long ph phys_addr &=PAGE_MASK ; size =PAGE_ALIGN (last_addr +1 ) - phys_addr; - prot =__pgprot (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY + prot =__pgprot (_PAGE_PRESENT | _PAGE_GLOBAL | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_TYPE_SMALL | flags);/*
@@ -169,9 +61,9 @@ void __iomem *__ioremap(unsigned long phif (!area)return NULL ; area->phys_addr = phys_addr; - addr = area->addr; -if (remap_area_pages ((unsigned long )addr, phys_addr, size, prot)) { -vunmap (addr); + addr = (unsigned long )area->addr; +if (ioremap_page_range (addr, addr + size, phys_addr, prot)) { +vunmap ((void *)addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 5/13 Generic ioremap_page_range: cris conversion
Convert CRIS to use generic ioremap_page_range()
--- arch/cris/mm/ioremap.c | 88 ++---------------------------------------------- 1 files changed, 3 insertions(+), 85 deletions(-)
arch/cris/mm/ioremap.c +3 -85
@@ -10,93 +10,10 @@*/ #include <linux/vmalloc.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/pgalloc.h> -#include <asm/cacheflush.h> -#include <asm/tlbflush.h> #include <asm/arch/memmap.h> -static inline void remap_area_pte (pte_t * pte,unsigned long address,unsigned long size, -unsigned long phys_addr,pgprot_t prot) -{ -unsigned long end; - - address &= ~PMD_MASK ; - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; -if (address >= end) -BUG (); -do { -if (!pte_none (*pte)) { -printk ("remap_area_pte: page already exists\n" ); -BUG (); - } -set_pte (pte,mk_pte_phys (phys_addr, prot)); - address +=PAGE_SIZE ; - phys_addr +=PAGE_SIZE ; - pte++; - }while (address && (address < end)); -} - -static inline int remap_area_pmd (pmd_t * pmd,unsigned long address,unsigned long size, -unsigned long phys_addr,pgprot_t prot) -{ -unsigned long end; - - address &= ~PGDIR_MASK ; - end = address + size; -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - phys_addr -= address; -if (address >= end) -BUG (); -do { -pte_t * pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; -remap_area_pte (pte, address, end - address, address + phys_addr, prot); - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -static int remap_area_pages (unsigned long address,unsigned long phys_addr, -unsigned long size,pgprot_t prot) -{ -int error; -pgd_t * dir; -unsigned long end = address + size; - - phys_addr -= address; - dir =pgd_offset (&init_mm, address); -flush_cache_all (); -if (address >= end) -BUG (); -do { -pud_t *pud; -pmd_t *pmd; - - error = -ENOMEM ; - pud =pud_alloc (&init_mm, dir, address); -if (!pud) -break ; - pmd =pmd_alloc (&init_mm, pud, address); - -if (!pmd) -break ; -if (remap_area_pmd (pmd, address, end - address, - phys_addr + address, prot)) -break ; - error =0 ; - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - dir++; - }while (address && (address < end)); -flush_tlb_all (); -return error; -} -/* * Generic mapping function (not visible outside): */
@@ -135,7 +52,8 @@ void __iomem * __ioremap_prot(unsigned lif (!area)return NULL ; addr = (void __iomem *)area->addr; -if (remap_area_pages ((unsigned long ) addr, phys_addr, size, prot)) { +if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, + phys_addr, prot)) {vfree ((void __force *)addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 6/13 Generic ioremap_page_range: i386 conversion
Convert i386 to use generic ioremap_page_range()
--- arch/i386/mm/ioremap.c | 85 +++--------------------------------------------- 1 files changed, 6 insertions(+), 79 deletions(-)
arch/i386/mm/ioremap.c +6 -79
@@ -12,91 +12,14 @@ #include <linux/vmalloc.h>#include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/fixmap.h> -#include <asm/cacheflush.h> #include <asm/tlbflush.h> #include <asm/pgtable.h> #define ISA_START_ADDRESS 0xa0000#define ISA_END_ADDRESS 0x100000 -static int ioremap_pte_range (pmd_t *pmd,unsigned long addr, -unsigned long end,unsigned long phys_addr,unsigned long flags) -{ -pte_t *pte; -unsigned long pfn; - - pfn = phys_addr >>PAGE_SHIFT ; - pte =pte_alloc_kernel (pmd, addr); -if (!pte) -return -ENOMEM ; -do { -BUG_ON (!pte_none (*pte)); -set_pte (pte,pfn_pte (pfn,__pgprot (_PAGE_PRESENT | _PAGE_RW | - _PAGE_DIRTY | _PAGE_ACCESSED | flags))); - pfn++; - }while (pte++, addr +=PAGE_SIZE , addr != end); -return 0 ; -} - -static inline int ioremap_pmd_range (pud_t *pud,unsigned long addr, -unsigned long end,unsigned long phys_addr,unsigned long flags) -{ -pmd_t *pmd; -unsigned long next; - - phys_addr -= addr; - pmd =pmd_alloc (&init_mm, pud, addr); -if (!pmd) -return -ENOMEM ; -do { - next =pmd_addr_end (addr, end); -if (ioremap_pte_range (pmd, addr, next, phys_addr + addr, flags)) -return -ENOMEM ; - }while (pmd++, addr = next, addr != end); -return 0 ; -} - -static inline int ioremap_pud_range (pgd_t *pgd,unsigned long addr, -unsigned long end,unsigned long phys_addr,unsigned long flags) -{ -pud_t *pud; -unsigned long next; - - phys_addr -= addr; - pud =pud_alloc (&init_mm, pgd, addr); -if (!pud) -return -ENOMEM ; -do { - next =pud_addr_end (addr, end); -if (ioremap_pmd_range (pud, addr, next, phys_addr + addr, flags)) -return -ENOMEM ; - }while (pud++, addr = next, addr != end); -return 0 ; -} - -static int ioremap_page_range (unsigned long addr, -unsigned long end,unsigned long phys_addr,unsigned long flags) -{ -pgd_t *pgd; -unsigned long next; -int err; - -BUG_ON (addr >= end); -flush_cache_all (); - phys_addr -= addr; - pgd =pgd_offset_k (addr); -do { - next =pgd_addr_end (addr, end); - err =ioremap_pud_range (pgd, addr, next, phys_addr+addr, flags); -if (err) -break ; - }while (pgd++, addr = next, addr != end); -flush_tlb_all (); -return err; -} -/* * Generic mapping function (not visible outside): */
@@ -115,6 +38,7 @@ void __iomem * __ioremap(unsigned long pvoid __iomem * addr;struct vm_struct * area;unsigned long offset, last_addr; +pgprot_t prot;/* Don't allow wraparound or zero size */ last_addr = phys_addr + size -1 ;
@@ -142,6 +66,9 @@ void __iomem * __ioremap(unsigned long preturn NULL ; } + prot =__pgprot (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY + | _PAGE_ACCESSED | flags); +/* * Mappings have to be page-aligned */
@@ -158,7 +85,7 @@ void __iomem * __ioremap(unsigned long p area->phys_addr = phys_addr; addr = (void __iomem *) area->addr;if (ioremap_page_range ((unsigned long ) addr, - (unsigned long ) addr + size, phys_addr, flags)) { + (unsigned long ) addr + size, phys_addr, prot)) {vunmap ((void __force *) addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 7/13 Generic ioremap_page_range: m32r conversion
Convert m32r to use generic ioremap_page_range()
--- arch/m32r/mm/ioremap.c | 93 ++++-------------------------------------------- 1 files changed, 7 insertions(+), 86 deletions(-)
arch/m32r/mm/ioremap.c +7 -86
@@ -20,92 +20,8 @@ #include <asm/addrspace.h>#include <asm/byteorder.h> #include <linux/vmalloc.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/pgalloc.h> -#include <asm/cacheflush.h> -#include <asm/tlbflush.h> - -static inline void -remap_area_pte (pte_t * pte,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; -unsigned long pfn; -pgprot_t pgprot =__pgprot (_PAGE_GLOBAL | _PAGE_PRESENT | _PAGE_READ - | _PAGE_WRITE | flags); - - address &= ~PMD_MASK ; - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; -if (address >= end) -BUG (); - pfn = phys_addr >>PAGE_SHIFT ; -do { -if (!pte_none (*pte)) { -printk ("remap_area_pte: page already exists\n" ); -BUG (); - } -set_pte (pte,pfn_pte (pfn, pgprot)); - address +=PAGE_SIZE ; - pfn++; - pte++; - }while (address && (address < end)); -} - -static inline int -remap_area_pmd (pmd_t * pmd,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; - - address &= ~PGDIR_MASK ; - end = address + size; -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - phys_addr -= address; -if (address >= end) -BUG (); -do { -pte_t * pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; -remap_area_pte (pte, address, end - address, address + phys_addr, flags); - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -static int -remap_area_pages (unsigned long address,unsigned long phys_addr, -unsigned long size,unsigned long flags) -{ -int error; -pgd_t * dir; -unsigned long end = address + size; - - phys_addr -= address; - dir =pgd_offset (&init_mm, address); -flush_cache_all (); -if (address >= end) -BUG (); -do { -pmd_t *pmd; - pmd =pmd_alloc (&init_mm, dir, address); - error = -ENOMEM ; -if (!pmd) -break ; -if (remap_area_pmd (pmd, address, end - address, - phys_addr + address, flags)) -break ; - error =0 ; - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - dir++; - }while (address && (address < end)); -flush_tlb_all (); -return error; -}/* * Generic mapping function (not visible outside):
@@ -129,6 +45,7 @@ __ioremap(unsigned long phys_addr, unsigvoid __iomem * addr;struct vm_struct * area;unsigned long offset, last_addr; +pgprot_t pgprot;/* Don't allow wraparound or zero size */ last_addr = phys_addr + size -1 ;
@@ -157,6 +74,9 @@ __ioremap(unsigned long phys_addr, unsigreturn NULL ; } + pgprot =__pgprot (_PAGE_GLOBAL | _PAGE_PRESENT | _PAGE_READ + | _PAGE_WRITE | flags); +/* * Mappings have to be page-aligned */
@@ -172,7 +92,8 @@ __ioremap(unsigned long phys_addr, unsigreturn NULL ; area->phys_addr = phys_addr; addr = (void __iomem *) area->addr; -if (remap_area_pages ((unsigned long )addr, phys_addr, size, flags)) { +if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, + phys_addr, pgprot)) {vunmap ((void __force *) addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 8/13 Generic ioremap_page_range: mips conversion
Convert MIPS to use generic ioremap_page_range()
--- arch/mips/mm/ioremap.c | 95 ++++-------------------------------------------- 1 files changed, 7 insertions(+), 88 deletions(-)
arch/mips/mm/ioremap.c +7 -88
@@ -11,93 +11,7 @@ #include <asm/addrspace.h>#include <asm/byteorder.h> #include <linux/vmalloc.h> -#include <asm/cacheflush.h> -#include <asm/io.h> -#include <asm/tlbflush.h> - -static inline void remap_area_pte (pte_t * pte,unsigned long address, -phys_t size,phys_t phys_addr,unsigned long flags) -{ -phys_t end; -unsigned long pfn; -pgprot_t pgprot =__pgprot (_PAGE_GLOBAL | _PAGE_PRESENT | __READABLE - | __WRITEABLE | flags); - - address &= ~PMD_MASK ; - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; -if (address >= end) -BUG (); - pfn = phys_addr >>PAGE_SHIFT ; -do { -if (!pte_none (*pte)) { -printk ("remap_area_pte: page already exists\n" ); -BUG (); - } -set_pte (pte,pfn_pte (pfn, pgprot)); - address +=PAGE_SIZE ; - pfn++; - pte++; - }while (address && (address < end)); -} - -static inline int remap_area_pmd (pmd_t * pmd,unsigned long address, -phys_t size,phys_t phys_addr,unsigned long flags) -{ -phys_t end; - - address &= ~PGDIR_MASK ; - end = address + size; -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - phys_addr -= address; -if (address >= end) -BUG (); -do { -pte_t * pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; -remap_area_pte (pte, address, end - address, address + phys_addr, flags); - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -static int remap_area_pages (unsigned long address,phys_t phys_addr, -phys_t size,unsigned long flags) -{ -int error; -pgd_t * dir; -unsigned long end = address + size; - - phys_addr -= address; - dir =pgd_offset (&init_mm, address); -flush_cache_all (); -if (address >= end) -BUG (); -do { -pud_t *pud; -pmd_t *pmd; - - error = -ENOMEM ; - pud =pud_alloc (&init_mm, dir, address); -if (!pud) -break ; - pmd =pmd_alloc (&init_mm, pud, address); -if (!pmd) -break ; -if (remap_area_pmd (pmd, address, end - address, - phys_addr + address, flags)) -break ; - error =0 ; - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - dir++; - }while (address && (address < end)); -flush_tlb_all (); -return error; -} +#include <linux/io.h> /* * Generic mapping function (not visible outside):
@@ -121,6 +35,7 @@ void __iomem * __ioremap(phys_t phys_addunsigned long offset;phys_t last_addr;void * addr; +pgprot_t pgprot; phys_addr =fixup_bigphys_addr (phys_addr, size);
@@ -152,6 +67,9 @@ void __iomem * __ioremap(phys_t phys_addreturn NULL ; } + pgprot =__pgprot (_PAGE_GLOBAL | _PAGE_PRESENT | __READABLE + | __WRITEABLE | flags); +/* * Mappings have to be page-aligned */
@@ -166,7 +84,8 @@ void __iomem * __ioremap(phys_t phys_addif (!area)return NULL ; addr = area->addr; -if (remap_area_pages ((unsigned long ) addr, phys_addr, size, flags)) { +if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, + phys_addr, pgprot)) {vunmap (addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 9/13 Generic ioremap_page_range: parisc conversion
Convert parisc to use generic ioremap_page_range()
--- arch/parisc/mm/ioremap.c | 111 +++------------------------------------------- 1 files changed, 7 insertions(+), 104 deletions(-)
arch/parisc/mm/ioremap.c +7 -104
@@ -9,110 +9,8 @@#include <linux/vmalloc.h> #include <linux/errno.h> #include <linux/module.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/pgalloc.h> -#include <asm/tlbflush.h> -#include <asm/cacheflush.h> - -static inline void -remap_area_pte (pte_t *pte,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end, pfn; -pgprot_t pgprot =__pgprot (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | - _PAGE_ACCESSED | flags); - - address &= ~PMD_MASK ; - - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; - -BUG_ON (address >= end); - - pfn = phys_addr >>PAGE_SHIFT ; -do { -BUG_ON (!pte_none (*pte)); - -set_pte (pte,pfn_pte (pfn, pgprot)); - - address +=PAGE_SIZE ; - pfn++; - pte++; - }while (address && (address < end)); -} - -static inline int -remap_area_pmd (pmd_t *pmd,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; - - address &= ~PGDIR_MASK ; - - end = address + size; -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - -BUG_ON (address >= end); - - phys_addr -= address; -do { -pte_t *pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; - -remap_area_pte (pte, address, end - address, - address + phys_addr, flags); - - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); - -return 0 ; -} - -static int -remap_area_pages (unsigned long address,unsigned long phys_addr, -unsigned long size,unsigned long flags) -{ -pgd_t *dir; -int error =0 ; -unsigned long end = address + size; - -BUG_ON (address >= end); - - phys_addr -= address; - dir =pgd_offset_k (address); - -flush_cache_all (); - -do { -pud_t *pud; -pmd_t *pmd; - - error = -ENOMEM ; - pud =pud_alloc (&init_mm, dir, address); -if (!pud) -break ; - - pmd =pmd_alloc (&init_mm, pud, address); -if (!pmd) -break ; - -if (remap_area_pmd (pmd, address, end - address, - phys_addr + address, flags)) -break ; - - error =0 ; - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - dir++; - }while (address && (address < end)); - -flush_tlb_all (); - -return error; -}/* * Generic mapping function (not visible outside):
@@ -131,6 +29,7 @@ void __iomem * __ioremap(unsigned long pvoid *addr;struct vm_struct *area;unsigned long offset, last_addr; +pgprot_t pgprot;#ifdef CONFIG_EISA unsigned long end = phys_addr + size -1 ;
@@ -164,6 +63,9 @@ #endif } } + pgprot =__pgprot (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | + _PAGE_ACCESSED | flags); +/* * Mappings have to be page-aligned */
@@ -179,7 +81,8 @@ #endifreturn NULL ; addr = area->addr; -if (remap_area_pages ((unsigned long ) addr, phys_addr, size, flags)) { +if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, + phys_addr, pgprot)) {vfree (addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 10/13 Generic ioremap_page_range: s390 conversion
Convert S390 to use generic ioremap_page_range()
--- arch/s390/mm/ioremap.c | 84 ++---------------------------------------------- 1 files changed, 3 insertions(+), 81 deletions(-)
arch/s390/mm/ioremap.c +3 -81
@@ -15,87 +15,8 @@#include <linux/vmalloc.h> #include <linux/mm.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/pgalloc.h> -#include <asm/cacheflush.h> -#include <asm/tlbflush.h> - -static inline void remap_area_pte (pte_t * pte,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; -unsigned long pfn; - - address &= ~PMD_MASK ; - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; -if (address >= end) -BUG (); - pfn = phys_addr >>PAGE_SHIFT ; -do { -if (!pte_none (*pte)) { -printk ("remap_area_pte: page already exists\n" ); -BUG (); - } -set_pte (pte,pfn_pte (pfn,__pgprot (flags))); - address +=PAGE_SIZE ; - pfn++; - pte++; - }while (address && (address < end)); -} - -static inline int remap_area_pmd (pmd_t * pmd,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; - - address &= ~PGDIR_MASK ; - end = address + size; -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - phys_addr -= address; -if (address >= end) -BUG (); -do { -pte_t * pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; -remap_area_pte (pte, address, end - address, address + phys_addr, flags); - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -static int remap_area_pages (unsigned long address,unsigned long phys_addr, -unsigned long size,unsigned long flags) -{ -int error; -pgd_t * dir; -unsigned long end = address + size; - - phys_addr -= address; - dir =pgd_offset (&init_mm, address); -flush_cache_all (); -if (address >= end) -BUG (); -do { -pmd_t *pmd; - pmd =pmd_alloc (&init_mm, dir, address); - error = -ENOMEM ; -if (!pmd) -break ; -if (remap_area_pmd (pmd, address, end - address, - phys_addr + address, flags)) -break ; - error =0 ; - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - dir++; - }while (address && (address < end)); -flush_tlb_all (); -return 0 ; -}/* * Generic mapping function (not visible outside):
@@ -122,7 +43,8 @@ void * __ioremap(unsigned long phys_addrif (!area)return NULL ; addr = area->addr; -if (remap_area_pages ((unsigned long ) addr, phys_addr, size, flags)) { +if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, + phys_addr,__pgprot (flags))) {vfree (addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 11/13 Generic ioremap_page_range: sh conversion
Convert SH to use generic ioremap_page_range()
--- arch/sh/mm/ioremap.c | 97 ++++---------------------------------------------- 1 files changed, 7 insertions(+), 90 deletions(-)
arch/sh/mm/ioremap.c +7 -90
@@ -15,98 +15,10 @@#include <linux/vmalloc.h> #include <linux/module.h> #include <linux/mm.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/page.h> #include <asm/pgalloc.h> #include <asm/addrspace.h> -#include <asm/cacheflush.h> -#include <asm/tlbflush.h> - -static inline void remap_area_pte (pte_t * pte,unsigned long address, -unsigned long size,unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; -unsigned long pfn; -pgprot_t pgprot =__pgprot (_PAGE_PRESENT | _PAGE_RW | - _PAGE_DIRTY | _PAGE_ACCESSED | - _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | flags); - - address &= ~PMD_MASK ; - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; -if (address >= end) -BUG (); - pfn = phys_addr >>PAGE_SHIFT ; -do { -if (!pte_none (*pte)) { -printk ("remap_area_pte: page already exists\n" ); -BUG (); - } -set_pte (pte,pfn_pte (pfn, pgprot)); - address +=PAGE_SIZE ; - pfn++; - pte++; - }while (address && (address < end)); -} - -static inline int remap_area_pmd (pmd_t * pmd,unsigned long address, -unsigned long size,unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; - - address &= ~PGDIR_MASK ; - end = address + size; -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - phys_addr -= address; -if (address >= end) -BUG (); -do { -pte_t * pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; -remap_area_pte (pte, address, end - address, address + phys_addr, flags); - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -int remap_area_pages (unsigned long address,unsigned long phys_addr, -unsigned long size,unsigned long flags) -{ -int error; -pgd_t * dir; -unsigned long end = address + size; - - phys_addr -= address; - dir =pgd_offset_k (address); -flush_cache_all (); -if (address >= end) -BUG (); -do { -pud_t *pud; -pmd_t *pmd; - - error = -ENOMEM ; - - pud =pud_alloc (&init_mm, dir, address); -if (!pud) -break ; - pmd =pmd_alloc (&init_mm, pud, address); -if (!pmd) -break ; -if (remap_area_pmd (pmd, address, end - address, - phys_addr + address, flags)) -break ; - error =0 ; - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - dir++; - }while (address && (address < end)); -flush_tlb_all (); -return error; -}/* * Remap an arbitrary physical address space into the kernel virtual
@@ -122,6 +34,7 @@ void __iomem *__ioremap(unsigned long ph {struct vm_struct * area;unsigned long offset, last_addr, addr, orig_addr; +pgprot_t pgprot;/* Don't allow wraparound or zero size */ last_addr = phys_addr + size -1 ;
@@ -177,8 +90,12 @@ #ifdef CONFIG_32BIT }#endif + pgprot =__pgprot (_PAGE_PRESENT | _PAGE_RW | + _PAGE_DIRTY | _PAGE_ACCESSED | + _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | flags); +if (likely (size)) -if (remap_area_pages (addr, phys_addr, size, flags)) { +if (ioremap_page_range (addr, addr + size, phys_addr, pgprot)) {vunmap ((void *)orig_addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 12/13 Generic ioremap_page_range: sh64 conversion
Convert SH64 to use generic ioremap_page_range()
--- arch/sh64/mm/ioremap.c | 100 ++++-------------------------------------------- 1 files changed, 8 insertions(+), 92 deletions(-)
arch/sh64/mm/ioremap.c +8 -92
@@ -18,7 +18,7 @@ #include <linux/slab.h>#include <linux/vmalloc.h> #include <linux/sched.h> #include <linux/string.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/pgalloc.h> #include <asm/tlbflush.h> #include <linux/ioport.h>
@@ -28,96 +28,6 @@ #include <linux/proc_fs.h>static void shmedia_mapioaddr (unsigned long ,unsigned long );static unsigned long shmedia_ioremap (struct resource *,u32 ,int ); -static inline void remap_area_pte (pte_t * pte,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; -unsigned long pfn; -pgprot_t pgprot =__pgprot (_PAGE_PRESENT | _PAGE_READ | - _PAGE_WRITE | _PAGE_DIRTY | - _PAGE_ACCESSED | _PAGE_SHARED | flags); - - address &= ~PMD_MASK ; - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; -if (address >= end) -BUG (); - - pfn = phys_addr >>PAGE_SHIFT ; - -pr_debug (" %s: pte %p address %lx size %lx phys_addr %lx\n" , - __FUNCTION__,pte,address,size,phys_addr); - -do { -if (!pte_none (*pte)) { -printk ("remap_area_pte: page already exists\n" ); -BUG (); - } - -set_pte (pte,pfn_pte (pfn, pgprot)); - address +=PAGE_SIZE ; - pfn++; - pte++; - }while (address && (address < end)); -} - -static inline int remap_area_pmd (pmd_t * pmd,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; - - address &= ~PGDIR_MASK ; - end = address + size; - -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - - phys_addr -= address; - -if (address >= end) -BUG (); - -do { -pte_t * pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; -remap_area_pte (pte, address, end - address, address + phys_addr, flags); - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -static int remap_area_pages (unsigned long address,unsigned long phys_addr, -unsigned long size,unsigned long flags) -{ -int error; -pgd_t * dir; -unsigned long end = address + size; - - phys_addr -= address; - dir =pgd_offset_k (address); -flush_cache_all (); -if (address >= end) -BUG (); -do { -pmd_t *pmd =pmd_alloc (&init_mm, dir, address); - error = -ENOMEM ; -if (!pmd) -break ; -if (remap_area_pmd (pmd, address, end - address, - phys_addr + address, flags)) { -break ; - } - error =0 ; - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - dir++; - }while (address && (address < end)); -flush_tlb_all (); -return 0 ; -} -/* * Generic mapping function (not visible outside): */
@@ -136,12 +46,17 @@ void * __ioremap(unsigned long phys_addrvoid * addr;struct vm_struct * area;unsigned long offset, last_addr; +pgprot_t pgprot;/* Don't allow wraparound or zero size */ last_addr = phys_addr + size -1 ;if (!size || last_addr < phys_addr)return NULL ; + pgprot =__pgprot (_PAGE_PRESENT | _PAGE_READ | + _PAGE_WRITE | _PAGE_DIRTY | + _PAGE_ACCESSED | _PAGE_SHARED | flags); +/* * Mappings have to be page-aligned */
@@ -158,7 +73,8 @@ void * __ioremap(unsigned long phys_addrreturn NULL ; area->phys_addr = phys_addr; addr = area->addr; -if (remap_area_pages ((unsigned long )addr, phys_addr, size, flags)) { +if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, + phys_addr, pgprot)) {vunmap (addr);return NULL ; }
Signature · 1 line
1.4.0
PATCH 13/13 Generic ioremap_page_range: x86_64 conversion
Convert x86_64 to use generic ioremap_page_range()
--- arch/x86_64/mm/ioremap.c | 110 +++------------------------------------------- 1 files changed, 6 insertions(+), 104 deletions(-)
arch/x86_64/mm/ioremap.c +6 -104
@@ -12,117 +12,15 @@ #include <linux/vmalloc.h>#include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/pgalloc.h> #include <asm/fixmap.h> -#include <asm/cacheflush.h> #include <asm/tlbflush.h> #include <asm/proto.h> #define ISA_START_ADDRESS 0xa0000#define ISA_END_ADDRESS 0x100000 -static inline void remap_area_pte (pte_t * pte,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; -unsigned long pfn; - - address &= ~PMD_MASK ; - end = address + size; -if (end >PMD_SIZE ) - end =PMD_SIZE ; -if (address >= end) -BUG (); - pfn = phys_addr >>PAGE_SHIFT ; -do { -if (!pte_none (*pte)) { -printk ("remap_area_pte: page already exists\n" ); -BUG (); - } -set_pte (pte,pfn_pte (pfn,__pgprot (_PAGE_PRESENT | _PAGE_RW | - _PAGE_GLOBAL | _PAGE_DIRTY | _PAGE_ACCESSED | flags))); - address +=PAGE_SIZE ; - pfn++; - pte++; - }while (address && (address < end)); -} - -static inline int remap_area_pmd (pmd_t * pmd,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; - - address &= ~PUD_MASK ; - end = address + size; -if (end >PUD_SIZE ) - end =PUD_SIZE ; - phys_addr -= address; -if (address >= end) -BUG (); -do { -pte_t * pte =pte_alloc_kernel (pmd, address); -if (!pte) -return -ENOMEM ; -remap_area_pte (pte, address, end - address, address + phys_addr, flags); - address = (address +PMD_SIZE ) &PMD_MASK ; - pmd++; - }while (address && (address < end)); -return 0 ; -} - -static inline int remap_area_pud (pud_t * pud,unsigned long address,unsigned long size, -unsigned long phys_addr,unsigned long flags) -{ -unsigned long end; - - address &= ~PGDIR_MASK ; - end = address + size; -if (end >PGDIR_SIZE ) - end =PGDIR_SIZE ; - phys_addr -= address; -if (address >= end) -BUG (); -do { -pmd_t * pmd =pmd_alloc (&init_mm, pud, address); -if (!pmd) -return -ENOMEM ; -remap_area_pmd (pmd, address, end - address, address + phys_addr, flags); - address = (address +PUD_SIZE ) &PUD_MASK ; - pud++; - }while (address && (address < end)); -return 0 ; -} - -static int remap_area_pages (unsigned long address,unsigned long phys_addr, -unsigned long size,unsigned long flags) -{ -int error; -pgd_t *pgd; -unsigned long end = address + size; - - phys_addr -= address; - pgd =pgd_offset_k (address); -flush_cache_all (); -if (address >= end) -BUG (); -do { -pud_t *pud; - pud =pud_alloc (&init_mm, pgd, address); - error = -ENOMEM ; -if (!pud) -break ; -if (remap_area_pud (pud, address, end - address, - phys_addr + address, flags)) -break ; - error =0 ; - address = (address +PGDIR_SIZE ) &PGDIR_MASK ; - pgd++; - }while (address && (address < end)); -flush_tlb_all (); -return error; -} -/* * Fix up the linear direct mapping of the kernel to avoid cache attribute * conflicts.
@@ -165,6 +63,7 @@ void __iomem * __ioremap(unsigned long pvoid * addr;struct vm_struct * area;unsigned long offset, last_addr; +pgprot_t pgprot;/* Don't allow wraparound or zero size */ last_addr = phys_addr + size -1 ;
@@ -194,6 +93,8 @@ #ifdef CONFIG_FLATMEM }#endif + pgprot =__pgprot (_PAGE_PRESENT | _PAGE_RW | _PAGE_GLOBAL + | _PAGE_DIRTY | _PAGE_ACCESSED | flags);/* * Mappings have to be page-aligned */
@@ -209,7 +110,8 @@ #endifreturn NULL ; area->phys_addr = phys_addr; addr = area->addr; -if (remap_area_pages ((unsigned long ) addr, phys_addr, size, flags)) { +if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, + phys_addr, pgprot)) {remove_vm_area ((void *)(PAGE_MASK & (unsigned long ) addr));return NULL ; }
Signature · 1 line
1.4.0
Re: [PATCH 13/13] Generic ioremap_page_range: x86_64 conversion
Quoted 1 line · Haavard Skinnemoen
Convert
x86_64to use genericioremap_page_range()
Ok for me. Also i386.
But linux-arch is normally not for patches, just for discussion. You should send the mails directly to the responsible people, probably cc l-k.
-Andi
Re: [PATCH 13/13] Generic ioremap_page_range: x86_64 conversion
Quoted 6 lines · Andi Kleen
Quoted 1 line · Haavard Skinnemoen
Convert
x86_64to use genericioremap_page_range()But linux-arch is normally not for patches, just for discussion. You should send the mails directly to the responsible people, probably cc l-k.
Erm, no, please let's continue posting patches like this to this list. For me, it's nice having the important stuff right here, so I don't need to search the archives.
MfG, JBG
Signature · 3 lines
Jan-Benedict Glaw [email protected] +49-172-7608481 Signature of: ...und wenn Du denkst, es geht nicht mehr, the second : kommt irgendwo ein Lichtlein her.
Re: [PATCH 9/13] Generic ioremap_page_range: parisc conversion
In reply to Haavard SkinnemoenQuoted 4 lines · Haavard Skinnemoen
Convert parisc to use generic
ioremap_page_range()Signed-off-by Haavard Skinnemoen <[email protected]>
Looks good. Nice to see such a big reduction in LoC.
Re: [PATCH 9/13] Generic ioremap_page_range: parisc conversion
In reply to Haavard SkinnemoenQuoted 6 lines · Haavard Skinnemoen
Convert parisc to use generic
ioremap_page_range()arch/parisc/mm/ioremap.c +0
-4-static int -remap_area_pages (unsigned long address,unsigned long phys_addr, -unsigned long size,unsigned long flags) -{
[...]
Quoted 2 lines
(quoted diff) +0
-2- flush_cache_all(); -
[..]
arch/parisc/mm/ioremap.c line 112
Quoted 4 lines
arch/parisc/mm/ioremap.c +0
-3- }while (address && (address < end)); - -flush_tlb_all ();
On second thought, you've compressed two different flushes into flush_cache_vmap[1] where flush_tlb_all used to be...
I don't think this would be a problem because we're creating a new mapping, but James will probably prove my assumption wrong as usual. :)
[1 - flush_cache_vmap is just a flush_cache_all on the arches
I've looked at with VI-caches.]
Cheers,
Kyle M.
Re: [PATCH 9/13] Generic ioremap_page_range: parisc conversion
Quoted 2 lines · On Tue, 8 Aug 2006 10:48:50 -0400 Kyle McMartin <[email protected]> wrote:
On second thought, you've compressed two different flushes into flush_cache_vmap[1] where
flush_tlb_allused to be...
Yes, that's intentional. I did mention this as one of the differences from i386 in the "implementation" part of this series, but I should perhaps have mentioned it explicitly in each of the arch-specific patches as well?
Quoted 3 lines
I don't think this would be a problem because we're creating a new mapping, but James will probably prove my assumption wrong as usual. :)
That's indeed the reasoning behind the change -- ioremap_pte_range() contains BUG_ON(!pte_none(*pte)) so we should never touch existing mappings.
Also, the only difference I can see between ioremap() and vmap() is that ioremap() maps a contiguous range of physical addresses while vmap() maps an array of 'struct page's. So the cache- and tlb-flushing requirements should be the same, right?
Haavard
Re: [PATCH 9/13] Generic ioremap_page_range: parisc conversion
In reply to Kyle McMartinQuoted 9 lines · Kyle McMartin
On second thought, you've compressed two different flushes into flush_cache_vmap[1] where
flush_tlb_allused to be...I don't think this would be a problem because we're creating a new mapping, but James will probably prove my assumption wrong as usual. :)
[1 -
flush_cache_vmapis just aflush_cache_allon the arches
I've looked at with VI-caches.]
The problem the flush_tlb_all() is trying to solve is to avoid stale tlb entries in the ioremap area. We're just being conservative by flushing on both map and unmap. Technically what vmalloc/vfree does (only flush the tlb on unmap) is just fine because it means that the only tlb entries in the remap area must belong to in-use mappings.
James
From: Haavard Skinnemoen <[email protected]>
Date: Tue, 08 Aug 2006 14:23:02 +0200
Quoted 1 line
sparc seems to do something completely different than everyone else.
Yes, we map in huge pages when possible.
I really don't expect you to try to abstract
that in your generic routines. :-)