aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/kernel/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/parisc/kernel/cache.c')
-rw-r--r--arch/parisc/kernel/cache.c88
1 files changed, 81 insertions, 7 deletions
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index d9cbb4b22c9f..ec63de95cbd9 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -469,8 +469,66 @@ void flush_cache_all(void)
469 on_each_cpu(cacheflush_h_tmp_function, NULL, 1); 469 on_each_cpu(cacheflush_h_tmp_function, NULL, 1);
470} 470}
471 471
472static inline unsigned long mm_total_size(struct mm_struct *mm)
473{
474 struct vm_area_struct *vma;
475 unsigned long usize = 0;
476
477 for (vma = mm->mmap; vma; vma = vma->vm_next)
478 usize += vma->vm_end - vma->vm_start;
479 return usize;
480}
481
482static inline pte_t *get_ptep(pgd_t *pgd, unsigned long addr)
483{
484 pte_t *ptep = NULL;
485
486 if (!pgd_none(*pgd)) {
487 pud_t *pud = pud_offset(pgd, addr);
488 if (!pud_none(*pud)) {
489 pmd_t *pmd = pmd_offset(pud, addr);
490 if (!pmd_none(*pmd))
491 ptep = pte_offset_map(pmd, addr);
492 }
493 }
494 return ptep;
495}
496
472void flush_cache_mm(struct mm_struct *mm) 497void flush_cache_mm(struct mm_struct *mm)
473{ 498{
499 /* Flushing the whole cache on each cpu takes forever on
500 rp3440, etc. So, avoid it if the mm isn't too big. */
501 if (mm_total_size(mm) < parisc_cache_flush_threshold) {
502 struct vm_area_struct *vma;
503
504 if (mm->context == mfsp(3)) {
505 for (vma = mm->mmap; vma; vma = vma->vm_next) {
506 flush_user_dcache_range_asm(vma->vm_start,
507 vma->vm_end);
508 if (vma->vm_flags & VM_EXEC)
509 flush_user_icache_range_asm(
510 vma->vm_start, vma->vm_end);
511 }
512 } else {
513 pgd_t *pgd = mm->pgd;
514
515 for (vma = mm->mmap; vma; vma = vma->vm_next) {
516 unsigned long addr;
517
518 for (addr = vma->vm_start; addr < vma->vm_end;
519 addr += PAGE_SIZE) {
520 pte_t *ptep = get_ptep(pgd, addr);
521 if (ptep != NULL) {
522 pte_t pte = *ptep;
523 __flush_cache_page(vma, addr,
524 page_to_phys(pte_page(pte)));
525 }
526 }
527 }
528 }
529 return;
530 }
531
474#ifdef CONFIG_SMP 532#ifdef CONFIG_SMP
475 flush_cache_all(); 533 flush_cache_all();
476#else 534#else
@@ -496,20 +554,36 @@ flush_user_icache_range(unsigned long start, unsigned long end)
496 flush_instruction_cache(); 554 flush_instruction_cache();
497} 555}
498 556
499
500void flush_cache_range(struct vm_area_struct *vma, 557void flush_cache_range(struct vm_area_struct *vma,
501 unsigned long start, unsigned long end) 558 unsigned long start, unsigned long end)
502{ 559{
503 int sr3;
504
505 BUG_ON(!vma->vm_mm->context); 560 BUG_ON(!vma->vm_mm->context);
506 561
507 sr3 = mfsp(3); 562 if ((end - start) < parisc_cache_flush_threshold) {
508 if (vma->vm_mm->context == sr3) { 563 if (vma->vm_mm->context == mfsp(3)) {
509 flush_user_dcache_range(start,end); 564 flush_user_dcache_range_asm(start, end);
510 flush_user_icache_range(start,end); 565 if (vma->vm_flags & VM_EXEC)
566 flush_user_icache_range_asm(start, end);
567 } else {
568 unsigned long addr;
569 pgd_t *pgd = vma->vm_mm->pgd;
570
571 for (addr = start & PAGE_MASK; addr < end;
572 addr += PAGE_SIZE) {
573 pte_t *ptep = get_ptep(pgd, addr);
574 if (ptep != NULL) {
575 pte_t pte = *ptep;
576 flush_cache_page(vma,
577 addr, pte_pfn(pte));
578 }
579 }
580 }
511 } else { 581 } else {
582#ifdef CONFIG_SMP
512 flush_cache_all(); 583 flush_cache_all();
584#else
585 flush_cache_all_local();
586#endif
513 } 587 }
514} 588}
515 589