88 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
99 */
1010#include <linux/init.h>
11+ #include <linux/highmem.h>
1112#include <linux/kernel.h>
1213#include <linux/linkage.h>
1314#include <linux/sched.h>
@@ -318,23 +319,6 @@ static void __init r4k_blast_scache_setup(void)
318319 r4k_blast_scache = blast_scache128 ;
319320}
320321
321- /*
322- * This is former mm's flush_cache_all() which really should be
323- * flush_cache_vunmap these days ...
324- */
325- static inline void local_r4k_flush_cache_all (void * args )
326- {
327- r4k_blast_dcache ();
328- }
329-
330- static void r4k_flush_cache_all (void )
331- {
332- if (!cpu_has_dc_aliases )
333- return ;
334-
335- r4k_on_each_cpu (local_r4k_flush_cache_all , NULL , 1 , 1 );
336- }
337-
338322static inline void local_r4k___flush_cache_all (void * args )
339323{
340324#if defined(CONFIG_CPU_LOONGSON2 )
@@ -423,13 +407,14 @@ static inline void local_r4k_flush_cache_page(void *args)
423407 struct flush_cache_page_args * fcp_args = args ;
424408 struct vm_area_struct * vma = fcp_args -> vma ;
425409 unsigned long addr = fcp_args -> addr ;
426- unsigned long paddr = fcp_args -> pfn << PAGE_SHIFT ;
410+ struct page * page = pfn_to_page ( fcp_args -> pfn ) ;
427411 int exec = vma -> vm_flags & VM_EXEC ;
428412 struct mm_struct * mm = vma -> vm_mm ;
429413 pgd_t * pgdp ;
430414 pud_t * pudp ;
431415 pmd_t * pmdp ;
432416 pte_t * ptep ;
417+ void * vaddr ;
433418
434419 /*
435420 * If ownes no valid ASID yet, cannot possibly have gotten
@@ -451,43 +436,40 @@ static inline void local_r4k_flush_cache_page(void *args)
451436 if (!(pte_val (* ptep ) & _PAGE_PRESENT ))
452437 return ;
453438
454- /*
455- * Doing flushes for another ASID than the current one is
456- * too difficult since stupid R4k caches do a TLB translation
457- * for every cache flush operation. So we do indexed flushes
458- * in that case, which doesn't overly flush the cache too much.
459- */
460- if ((mm == current -> active_mm ) && (pte_val (* ptep ) & _PAGE_VALID )) {
461- if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc )) {
462- r4k_blast_dcache_page (addr );
463- if (exec && !cpu_icache_snoops_remote_store )
464- r4k_blast_scache_page (addr );
465- }
466- if (exec )
467- r4k_blast_icache_page (addr );
468-
469- return ;
439+ if ((mm == current -> active_mm ) && (pte_val (* ptep ) & _PAGE_VALID ))
440+ vaddr = NULL ;
441+ else {
442+ /*
443+ * Use kmap_coherent or kmap_atomic to do flushes for
444+ * another ASID than the current one.
445+ */
446+ if (cpu_has_dc_aliases )
447+ vaddr = kmap_coherent (page , addr );
448+ else
449+ vaddr = kmap_atomic (page , KM_USER0 );
450+ addr = (unsigned long )vaddr ;
470451 }
471452
472- /*
473- * Do indexed flush, too much work to get the (possible) TLB refills
474- * to work correctly.
475- */
476453 if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc )) {
477- r4k_blast_dcache_page_indexed (cpu_has_pindexed_dcache ?
478- paddr : addr );
479- if (exec && !cpu_icache_snoops_remote_store ) {
480- r4k_blast_scache_page_indexed (paddr );
481- }
454+ r4k_blast_dcache_page (addr );
455+ if (exec && !cpu_icache_snoops_remote_store )
456+ r4k_blast_scache_page (addr );
482457 }
483458 if (exec ) {
484- if (cpu_has_vtag_icache && mm == current -> active_mm ) {
459+ if (vaddr && cpu_has_vtag_icache && mm == current -> active_mm ) {
485460 int cpu = smp_processor_id ();
486461
487462 if (cpu_context (cpu , mm ) != 0 )
488463 drop_mmu_context (mm , cpu );
489464 } else
490- r4k_blast_icache_page_indexed (addr );
465+ r4k_blast_icache_page (addr );
466+ }
467+
468+ if (vaddr ) {
469+ if (cpu_has_dc_aliases )
470+ kunmap_coherent ();
471+ else
472+ kunmap_atomic (vaddr , KM_USER0 );
491473 }
492474}
493475
@@ -1279,7 +1261,7 @@ void __init r4k_cache_init(void)
12791261 PAGE_SIZE - 1 );
12801262 else
12811263 shm_align_mask = PAGE_SIZE - 1 ;
1282- flush_cache_all = r4k_flush_cache_all ;
1264+ flush_cache_all = cache_noop ;
12831265 __flush_cache_all = r4k___flush_cache_all ;
12841266 flush_cache_mm = r4k_flush_cache_mm ;
12851267 flush_cache_page = r4k_flush_cache_page ;
0 commit comments