xtensa: add highmem support
Max Filippov
maintainercover xtensa: add highmem support
Hi Chris and everybody,
this series adds highmem support for xtensa (currently only for cores with non-aliased caches).
Please review.
Max Filippov (2):
xtensa: optimize local_flush_tlb_kernel_range
xtensa: add HIGHMEM support
arch/xtensa/Kconfig | 18 ++++++++++ arch/xtensa/include/asm/fixmap.h | 58 ++++++++++++++++++++++++++++++ arch/xtensa/include/asm/highmem.h | 45 +++++++++++++++++++++++- arch/xtensa/include/asm/pgtable.h | 4 +++ arch/xtensa/include/asm/tlbflush.h | 11 +++--- arch/xtensa/kernel/smp.c | 15 ++++++++ arch/xtensa/mm/Makefile | 1 + arch/xtensa/mm/cache.c | 7 +++- arch/xtensa/mm/highmem.c | 72 ++++++++++++++++++++++++++++++++++++++ arch/xtensa/mm/init.c | 45 ++++++++++++++++-------- arch/xtensa/mm/mmu.c | 36 +++++++++++++++++++ arch/xtensa/mm/tlb.c | 15 ++++++++ 12 files changed, 304 insertions(+), 23 deletions(-) create mode 100644 arch/xtensa/include/asm/fixmap.h create mode 100644 arch/xtensa/mm/highmem.c
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 1/2 xtensa: optimize local_flush_tlb_kernel_range
Don't flush whole TLB if only a small kernel range is requested.
--- arch/xtensa/include/asm/tlbflush.h | 11 ++++------- arch/xtensa/kernel/smp.c | 15 +++++++++++++++ arch/xtensa/mm/tlb.c | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 7 deletions(-)
arch/xtensa/include/asm/tlbflush.h +4 -7
@@ -36,6 +36,7 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page);void local_flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end); +void local_flush_tlb_kernel_range (unsigned long start,unsigned long end);#ifdef CONFIG_SMP
@@ -44,12 +45,7 @@ void flush_tlb_mm(struct mm_struct *);void flush_tlb_page (struct vm_area_struct *,unsigned long );void flush_tlb_range (struct vm_area_struct *,unsigned long ,unsigned long ); - -static inline void flush_tlb_kernel_range (unsigned long start, -unsigned long end) -{ -flush_tlb_all (); -} +void flush_tlb_kernel_range (unsigned long start,unsigned long end);#else /* !CONFIG_SMP */
@@ -58,7 +54,8 @@ static inline void flush_tlb_kernel_range(unsigned long start,#define flush_tlb_page (vma, page) local_flush_tlb_page(vma, page)#define flush_tlb_range (vma, vmaddr, end) local_flush_tlb_range(vma, vmaddr, \ end) -#define flush_tlb_kernel_range (start, end) local_flush_tlb_all() +#define flush_tlb_kernel_range (start, end) local_flush_tlb_kernel_range(start, \ + end)#endif /* CONFIG_SMP */
arch/xtensa/kernel/smp.c +15 -0
@@ -496,6 +496,21 @@ void flush_tlb_range(struct vm_area_struct *vma,on_each_cpu (ipi_flush_tlb_range, &fd,1 ); } +static void ipi_flush_tlb_kernel_range (void *arg) +{ +struct flush_data *fd = arg; +local_flush_tlb_kernel_range (fd->addr1, fd->addr2); +} + +void flush_tlb_kernel_range (unsigned long start,unsigned long end) +{ +struct flush_data fd = { + .addr1 = start, + .addr2 = end, + }; +on_each_cpu (ipi_flush_tlb_kernel_range, &fd,1 ); +} +/* Cache flush functions */ static void ipi_flush_cache_all (void *arg)
arch/xtensa/mm/tlb.c +15 -0
@@ -149,6 +149,21 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)local_irq_restore (flags); } +void local_flush_tlb_kernel_range (unsigned long start,unsigned long end) +{ +if (end > start && start >=TASK_SIZE && end <=PAGE_OFFSET && + end - start < _TLB_ENTRIES <<PAGE_SHIFT ) { + start &=PAGE_MASK ; +while (start < end) { +invalidate_itlb_mapping (start); +invalidate_dtlb_mapping (start); + start +=PAGE_SIZE ; + } + }else { +local_flush_tlb_all (); + } +} +#ifdef CONFIG_DEBUG_TLB_SANITY static unsigned get_pte_for_vaddr (unsigned vaddr)
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 2/2 xtensa: add HIGHMEM support
In reply to Max FilippovIntroduce fixmap area just below the vmalloc region. Use it for atomic mapping of high memory pages.
High memory on cores with cache aliasing is not supported and is still to be implemented. Fail build for such configurations for now.
--- arch/xtensa/Kconfig | 18 ++++++++++ arch/xtensa/include/asm/fixmap.h | 58 +++++++++++++++++++++++++++++++ arch/xtensa/include/asm/highmem.h | 45 +++++++++++++++++++++++- arch/xtensa/include/asm/pgtable.h | 4 +++ arch/xtensa/mm/Makefile | 1 + arch/xtensa/mm/cache.c | 7 +++- arch/xtensa/mm/highmem.c | 72 +++++++++++++++++++++++++++++++++++++++ arch/xtensa/mm/init.c | 45 ++++++++++++++++-------- arch/xtensa/mm/mmu.c | 36 ++++++++++++++++++++ 9 files changed, 270 insertions(+), 16 deletions(-) create mode 100644 arch/xtensa/include/asm/fixmap.h create mode 100644 arch/xtensa/mm/highmem.c
arch/xtensa/Kconfig +18 -0
@@ -218,6 +218,24 @@ config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX If in doubt, say Y. +config HIGHMEM + bool "High Memory Support" + help + Linux can use the full amount of RAM in the system by + default. However, the default MMUv2 setup only maps the + lowermost 128 MB of memory linearly to the areas starting + at 0xd0000000 (cached) and 0xd8000000 (uncached). + When there are more than 128 MB memory in the system not + all of it can be "permanently mapped" by the kernel. + The physical memory that's not permanently mapped is called + "high memory". + + If you are compiling a kernel which will never run on a + machine with more than 128 MB total physical RAM, answer + N here. + + If unsure, say Y. + endmenu config XTENSA_CALIBRATE_CCOUNT
arch/xtensa/include/asm/fixmap.h new file +58 -0
58 lines not on this page · raw message
arch/xtensa/include/asm/highmem.h +44 -1
55 lines not on this page · raw message
arch/xtensa/include/asm/pgtable.h +4 -0
@@ -310,6 +310,10 @@ set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval)update_pte (ptep, pteval); } +static inline void set_pte (pte_t *ptep,pte_t pteval) +{ +update_pte (ptep, pteval); +}static inline void set_pmd (pmd_t *pmdp,pmd_t pmdval)
arch/xtensa/mm/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-y := init.o cache.o misc.o obj-$(CONFIG_MMU) += fault.o mmu.o tlb.o +obj-$(CONFIG_HIGHMEM) += highmem.o
arch/xtensa/mm/cache.c +6 -1
@@ -59,6 +59,10 @@* */ +#if (DCACHE_WAY_SIZE >PAGE_SIZE ) && defined(CONFIG_HIGHMEM ) +#error "HIGHMEM is not supported on cores with aliasing cache." +#endif +#if (DCACHE_WAY_SIZE >PAGE_SIZE ) &&XCHAL_DCACHE_IS_WRITEBACK /*
@@ -179,10 +183,11 @@ update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)#else if (!PageReserved (page) && !test_bit (PG_arch_1, &page->flags) && (vma->vm_flags &VM_EXEC ) !=0 ) { -unsigned long paddr = (unsigned long )page_address (page); +unsigned long paddr = (unsigned long )kmap_atomic (page);__flush_dcache_page (paddr);__invalidate_icache_page (paddr);set_bit (PG_arch_1, &page->flags); +kunmap_atomic ((void *)paddr); }#endif }
arch/xtensa/mm/highmem.c new file +72 -0
72 lines not on this page · raw message
arch/xtensa/mm/init.c +31 -14
72 lines not on this page · raw message
arch/xtensa/mm/mmu.c +36 -0
@@ -3,6 +3,7 @@* * Extracted from init.c */ +#include <linux/bootmem.h> #include <linux/percpu.h> #include <linux/init.h> #include <linux/string.h>
@@ -16,9 +17,44 @@#include <asm/initialize_mmu.h> #include <asm/io.h> +#if defined(CONFIG_HIGHMEM ) +static void *__init init_pmd (unsigned long vaddr) +{ +pgd_t *pgd =pgd_offset_k (vaddr); +pmd_t *pmd =pmd_offset (pgd, vaddr); + +if (pmd_none (*pmd)) { +unsigned i; +pte_t *pte =alloc_bootmem_low_pages (PAGE_SIZE ); + +for (i =0 ; i <1024 ; i++) +pte_clear (NULL ,0 , pte + i); + +set_pmd (pmd,__pmd (((unsigned long )pte) &PAGE_MASK )); +BUG_ON (pte !=pte_offset_kernel (pmd,0 )); +pr_debug ("%s: vaddr: 0x%08lx, pmd: 0x%p, pte: 0x%p\n" , + __func__, vaddr, pmd, pte); +return pte; + }else { +return pte_offset_kernel (pmd,0 ); + } +} + +static void __init fixedrange_init (void ) +{ +BUILD_BUG_ON (FIXADDR_SIZE >PMD_SIZE ); +init_pmd (__fix_to_virt (__end_of_fixed_addresses -1 ) &PMD_MASK ); +} +#endif +void __init paging_init (void ) {memset (swapper_pg_dir,0 ,PAGE_SIZE ); +#ifdef CONFIG_HIGHMEM +fixedrange_init (); + pkmap_page_table =init_pmd (PKMAP_BASE ); +kmap_init (); +#endif }/*
Signature · 1 line
1.8.1.4