+ static void r4k_flush_cache_range(struct vm_area_struct *vma,
+ unsigned long start, unsigned long end)
+ {
+- if (!cpu_has_dc_aliases)
++ if (!cpu_has_dc_aliases && cpu_use_kmap_coherent)
+ return;
+
+ r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
+@@ -377,6 +415,7 @@
+ static inline void local_r4k_flush_cache_mm(void * args)
+ {
+ struct mm_struct *mm = args;
++ unsigned long flags;
+
+ if (!cpu_context(smp_processor_id(), mm))
+ return;
+@@ -395,12 +434,15 @@
+ return;
+ }
+
++ local_irq_save(flags);
+ r4k_blast_dcache();
++ r4k_blast_icache();
++ local_irq_restore(flags);
+ }
+
+ static void r4k_flush_cache_mm(struct mm_struct *mm)
+ {
+- if (!cpu_has_dc_aliases)
++ if (!cpu_has_dc_aliases && cpu_use_kmap_coherent)
+ return;
+
+ r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1);
+@@ -420,6 +462,7 @@
+ unsigned long paddr = fcp_args->pfn << PAGE_SHIFT;
+ int exec = vma->vm_flags & VM_EXEC;
+ struct mm_struct *mm = vma->vm_mm;
++ unsigned long flags;
+ pgd_t *pgdp;
+ pud_t *pudp;
+ pmd_t *pmdp;
+@@ -451,8 +494,9 @@
+ * for every cache flush operation. So we do indexed flushes
+ * in that case, which doesn't overly flush the cache too much.
+ */
++ local_irq_save(flags);
+ if ((mm == current->active_mm) && (pte_val(*ptep) & _PAGE_VALID)) {
+- if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
++ if (!cpu_use_kmap_coherent || cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
+ r4k_blast_dcache_page(addr);
+ if (exec && !cpu_icache_snoops_remote_store)
+ r4k_blast_scache_page(addr);
+@@ -460,14 +504,14 @@
+ if (exec)
+ r4k_blast_icache_page(addr);
+
+- return;
++ goto done;
+ }
+
+ /*
+ * Do indexed flush, too much work to get the (possible) TLB refills
+ * to work correctly.
+ */
+- if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
++ if (!cpu_use_kmap_coherent || cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
+ r4k_blast_dcache_page_indexed(cpu_has_pindexed_dcache ?
+ paddr : addr);
+ if (exec && !cpu_icache_snoops_remote_store) {
+@@ -483,6 +527,8 @@
+ } else
+ r4k_blast_icache_page_indexed(addr);
+ }
++done:
++ local_irq_restore(flags);
+ }
+
+ static void r4k_flush_cache_page(struct vm_area_struct *vma,
+@@ -499,7 +545,11 @@
+
+ static inline void local_r4k_flush_data_cache_page(void * addr)
+ {
++ unsigned long flags;
++
++ local_irq_save(flags);
+ r4k_blast_dcache_page((unsigned long) addr);
++ local_irq_restore(flags);
+ }
+
+ static void r4k_flush_data_cache_page(unsigned long addr)
+@@ -542,6 +592,9 @@
+