···156156157157 while (count--)158158 *buf++ = *p;159159-160160- flush_dcache_all();161159}162160163161void r7780rp_insl(unsigned long port, void *dst, unsigned long count)···202204203205 while (count--)204206 *p = *buf++;205205-206206- flush_dcache_all();207207}208208209209void r7780rp_outsl(unsigned long port, const void *src, unsigned long count)
-3
arch/sh/kernel/io_generic.c
···1414#include <linux/module.h>1515#include <linux/io.h>1616#include <asm/machvec.h>1717-#include <asm/cacheflush.h>18171918#ifdef CONFIG_CPU_SH32019/* SH3 has a PCMCIA bug that needs a dummy read from area 6 for a···9596 while (count--)9697 *buf++ = *port_addr;97989898- flush_dcache_all();9999 dummy_read();100100}101101···169171 while (count--)170172 *port_addr = *buf++;171173172172- flush_dcache_all();173174 dummy_read();174175}175176
+1-11
arch/sh/mm/cache-sh4.c
···237237/*238238 * Write back & invalidate the D-cache of the page.239239 * (To avoid "alias" issues)240240- *241241- * This uses a lazy write-back on UP, which is explicitly242242- * disabled on SMP.243240 */244241void flush_dcache_page(struct page *page)245242{246246-#ifndef CONFIG_SMP247247- struct address_space *mapping = page_mapping(page);248248-249249- if (mapping && !mapping_mapped(mapping))250250- set_bit(PG_dcache_dirty, &page->flags);251251- else252252-#endif253253- {243243+ if (test_bit(PG_mapped, &page->flags)) {254244 unsigned long phys = PHYSADDR(page_address(page));255245 unsigned long addr = CACHE_OC_ADDRESS_ARRAY;256246 int i, n;
+3-6
arch/sh/mm/cache-sh7705.c
···33 *44 * Copyright (C) 1999, 2000 Niibe Yutaka55 * Copyright (C) 2004 Alex Song66- * Copyright (C) 2006 Paul Mundt76 *87 * This file is subject to the terms and conditions of the GNU General Public98 * License. See the file "COPYING" in the main directory of this archive109 * for more details.1010+ *1111 */1212#include <linux/init.h>1313#include <linux/mman.h>···51515252 if ((data & v) == v)5353 ctrl_outl(data & ~v, addr);5454+5455 }55565657 addrstart += current_cpu_data.dcache.way_incr;···128127 */129128void flush_dcache_page(struct page *page)130129{131131- struct address_space *mapping = page_mapping(page);132132-133133- if (mapping && !mapping_mapped(mapping))134134- set_bit(PG_dcache_dirty, &page->flags);135135- else130130+ if (test_bit(PG_mapped, &page->flags))136131 __flush_dcache_page(PHYSADDR(page_address(page)));137132}138133
+22
arch/sh/mm/pg-sh4.c
···2323 */2424void clear_user_page(void *to, unsigned long address, struct page *page)2525{2626+ __set_bit(PG_mapped, &page->flags);2627 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)2728 clear_page(to);2829 else {···5958void copy_user_page(void *to, void *from, unsigned long address,6059 struct page *page)6160{6161+ __set_bit(PG_mapped, &page->flags);6262 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)6363 copy_page(to, from);6464 else {···8381 pte_clear(&init_mm, p3_addr, pte);8482 mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);8583 }8484+}8585+8686+/*8787+ * For SH-4, we have our own implementation for ptep_get_and_clear8888+ */8989+inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)9090+{9191+ pte_t pte = *ptep;9292+9393+ pte_clear(mm, addr, ptep);9494+ if (!pte_not_present(pte)) {9595+ unsigned long pfn = pte_pfn(pte);9696+ if (pfn_valid(pfn)) {9797+ struct page *page = pfn_to_page(pfn);9898+ struct address_space *mapping = page_mapping(page);9999+ if (!mapping || !mapping_writably_mapped(mapping))100100+ __clear_bit(PG_mapped, &page->flags);101101+ }102102+ }103103+ return pte;86104}
+29-2
arch/sh/mm/pg-sh7705.c
···77 * This file is subject to the terms and conditions of the GNU General Public88 * License. See the file "COPYING" in the main directory of this archive99 * for more details.1010+ *1011 */1212+1113#include <linux/init.h>1214#include <linux/mman.h>1315#include <linux/mm.h>···7674{7775 struct page *page = virt_to_page(to);78767777+ __set_bit(PG_mapped, &page->flags);7978 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) {8079 clear_page(to);8180 __flush_wback_region(to, PAGE_SIZE);···9592 * @from: P1 address9693 * @address: U0 address to be mapped9794 */9898-void copy_user_page(void *to, void *from, unsigned long address,9999- struct page *pg)9595+void copy_user_page(void *to, void *from, unsigned long address, struct page *pg)10096{10197 struct page *page = virt_to_page(to);102989999+100100+ __set_bit(PG_mapped, &page->flags);103101 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) {104102 copy_page(to, from);105103 __flush_wback_region(to, PAGE_SIZE);···112108 __flush_wback_region(to, PAGE_SIZE);113109 }114110}111111+112112+/*113113+ * For SH7705, we have our own implementation for ptep_get_and_clear114114+ * Copied from pg-sh4.c115115+ */116116+inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)117117+{118118+ pte_t pte = *ptep;119119+120120+ pte_clear(mm, addr, ptep);121121+ if (!pte_not_present(pte)) {122122+ unsigned long pfn = pte_pfn(pte);123123+ if (pfn_valid(pfn)) {124124+ struct page *page = pfn_to_page(pfn);125125+ struct address_space *mapping = page_mapping(page);126126+ if (!mapping || !mapping_writably_mapped(mapping))127127+ __clear_bit(PG_mapped, &page->flags);128128+ }129129+ }130130+131131+ return pte;132132+}133133+
+1-54
arch/sh/mm/tlb-flush.c
···22 * TLB flushing operations for SH with an MMU.33 *44 * Copyright (C) 1999 Niibe Yutaka55- * Copyright (C) 2003 - 2006 Paul Mundt55+ * Copyright (C) 2003 Paul Mundt66 *77 * This file is subject to the terms and conditions of the GNU General Public88 * License. See the file "COPYING" in the main directory of this archive99 * for more details.1010 */1111#include <linux/mm.h>1212-#include <linux/io.h>1312#include <asm/mmu_context.h>1413#include <asm/tlbflush.h>1515-#include <asm/cacheflush.h>16141715void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)1816{···136138 status |= 0x04;137139 ctrl_outl(status, MMUCR);138140 ctrl_barrier();139139- local_irq_restore(flags);140140-}141141-142142-void update_mmu_cache(struct vm_area_struct *vma,143143- unsigned long address, pte_t pte)144144-{145145- unsigned long flags;146146- unsigned long pteval;147147- unsigned long vpn;148148- struct page *page;149149- unsigned long pfn = pte_pfn(pte);150150- struct address_space *mapping;151151-152152- if (!pfn_valid(pfn))153153- return;154154-155155- page = pfn_to_page(pfn);156156- mapping = page_mapping(page);157157- if (mapping) {158158- unsigned long phys = pte_val(pte) & PTE_PHYS_MASK;159159- int dirty = test_and_clear_bit(PG_dcache_dirty, &page->flags);160160-161161- if (dirty)162162- __flush_wback_region((void *)P1SEGADDR(phys),163163- PAGE_SIZE);164164- }165165-166166- local_irq_save(flags);167167-168168- /* Set PTEH register */169169- vpn = (address & MMU_VPN_MASK) | get_asid();170170- ctrl_outl(vpn, MMU_PTEH);171171-172172- pteval = pte_val(pte);173173-174174-#ifdef CONFIG_CPU_HAS_PTEA175175- /* Set PTEA register */176176- /* TODO: make this look less hacky */177177- ctrl_outl(((pteval >> 28) & 0xe) | (pteval & 0x1), MMU_PTEA);178178-#endif179179-180180- /* Set PTEL register */181181- pteval &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */182182-#if defined(CONFIG_SH_WRITETHROUGH) && defined(CONFIG_CPU_SH4)183183- pteval |= _PAGE_WT;184184-#endif185185- /* conveniently, we want all the software flags to be 0 anyway */186186- ctrl_outl(pteval, MMU_PTEL);187187-188188- /* Load the TLB */189189- asm volatile("ldtlb": /* no output */ : /* no input */ : "memory");190141 local_irq_restore(flags);191142}
+62-1
arch/sh/mm/tlb-sh3.c
···88 *99 * Released under the terms of the GNU GPL v2.0.1010 */1111-#include <linux/io.h>1111+#include <linux/signal.h>1212+#include <linux/sched.h>1313+#include <linux/kernel.h>1414+#include <linux/errno.h>1515+#include <linux/string.h>1616+#include <linux/types.h>1717+#include <linux/ptrace.h>1818+#include <linux/mman.h>1919+#include <linux/mm.h>2020+#include <linux/smp.h>2121+#include <linux/smp_lock.h>2222+#include <linux/interrupt.h>2323+1224#include <asm/system.h>2525+#include <asm/io.h>2626+#include <asm/uaccess.h>2727+#include <asm/pgalloc.h>1328#include <asm/mmu_context.h>2929+#include <asm/cacheflush.h>3030+3131+void update_mmu_cache(struct vm_area_struct * vma,3232+ unsigned long address, pte_t pte)3333+{3434+ unsigned long flags;3535+ unsigned long pteval;3636+ unsigned long vpn;3737+3838+ /* Ptrace may call this routine. */3939+ if (vma && current->active_mm != vma->vm_mm)4040+ return;4141+4242+#if defined(CONFIG_SH7705_CACHE_32KB)4343+ {4444+ struct page *page = pte_page(pte);4545+ unsigned long pfn = pte_pfn(pte);4646+4747+ if (pfn_valid(pfn) && !test_bit(PG_mapped, &page->flags)) {4848+ unsigned long phys = pte_val(pte) & PTE_PHYS_MASK;4949+5050+ __flush_wback_region((void *)P1SEGADDR(phys),5151+ PAGE_SIZE);5252+ __set_bit(PG_mapped, &page->flags);5353+ }5454+ }5555+#endif5656+5757+ local_irq_save(flags);5858+5959+ /* Set PTEH register */6060+ vpn = (address & MMU_VPN_MASK) | get_asid();6161+ ctrl_outl(vpn, MMU_PTEH);6262+6363+ pteval = pte_val(pte);6464+6565+ /* Set PTEL register */6666+ pteval &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */6767+ /* conveniently, we want all the software flags to be 0 anyway */6868+ ctrl_outl(pteval, MMU_PTEL);6969+7070+ /* Load the TLB */7171+ asm volatile("ldtlb": /* no output */ : /* no input */ : "memory");7272+ local_irq_restore(flags);7373+}14741575void local_flush_tlb_one(unsigned long asid, unsigned long page)1676{···9434 for (i = 0; i < ways; i++)9535 ctrl_outl(data, addr + (i << 8));9636}3737+
+67-1
arch/sh/mm/tlb-sh4.c
···88 *99 * Released under the terms of the GNU GPL v2.0.1010 */1111-#include <linux/io.h>1111+#include <linux/signal.h>1212+#include <linux/sched.h>1313+#include <linux/kernel.h>1414+#include <linux/errno.h>1515+#include <linux/string.h>1616+#include <linux/types.h>1717+#include <linux/ptrace.h>1818+#include <linux/mman.h>1919+#include <linux/mm.h>2020+#include <linux/smp.h>2121+#include <linux/smp_lock.h>2222+#include <linux/interrupt.h>2323+1224#include <asm/system.h>2525+#include <asm/io.h>2626+#include <asm/uaccess.h>2727+#include <asm/pgalloc.h>1328#include <asm/mmu_context.h>2929+#include <asm/cacheflush.h>3030+3131+void update_mmu_cache(struct vm_area_struct * vma,3232+ unsigned long address, pte_t pte)3333+{3434+ unsigned long flags;3535+ unsigned long pteval;3636+ unsigned long vpn;3737+ struct page *page;3838+ unsigned long pfn;3939+4040+ /* Ptrace may call this routine. */4141+ if (vma && current->active_mm != vma->vm_mm)4242+ return;4343+4444+ pfn = pte_pfn(pte);4545+ if (pfn_valid(pfn)) {4646+ page = pfn_to_page(pfn);4747+ if (!test_bit(PG_mapped, &page->flags)) {4848+ unsigned long phys = pte_val(pte) & PTE_PHYS_MASK;4949+ __flush_wback_region((void *)P1SEGADDR(phys), PAGE_SIZE);5050+ __set_bit(PG_mapped, &page->flags);5151+ }5252+ }5353+5454+ local_irq_save(flags);5555+5656+ /* Set PTEH register */5757+ vpn = (address & MMU_VPN_MASK) | get_asid();5858+ ctrl_outl(vpn, MMU_PTEH);5959+6060+ pteval = pte_val(pte);6161+6262+ /* Set PTEA register */6363+ if (cpu_data->flags & CPU_HAS_PTEA)6464+ /* TODO: make this look less hacky */6565+ ctrl_outl(((pteval >> 28) & 0xe) | (pteval & 0x1), MMU_PTEA);6666+6767+ /* Set PTEL register */6868+ pteval &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */6969+#ifdef CONFIG_SH_WRITETHROUGH7070+ pteval |= _PAGE_WT;7171+#endif7272+ /* conveniently, we want all the software flags to be 0 anyway */7373+ ctrl_outl(pteval, MMU_PTEL);7474+7575+ /* Load the TLB */7676+ asm volatile("ldtlb": /* no output */ : /* no input */ : "memory");7777+ local_irq_restore(flags);7878+}14791580void local_flush_tlb_one(unsigned long asid, unsigned long page)1681{···9328 ctrl_outl(data, addr);9429 back_to_P1();9530}3131+
-3
include/asm-sh/cacheflush.h
···30303131#define HAVE_ARCH_UNMAPPED_AREA32323333-/* Page flag for lazy dcache write-back for the aliasing UP caches */3434-#define PG_dcache_dirty PG_arch_13535-3633#endif /* __KERNEL__ */3734#endif /* __ASM_SH_CACHEFLUSH_H */
+2
include/asm-sh/cpu-sh3/cacheflush.h
···3636 /* 32KB cache, 4kb PAGE sizes need to check bit 12 */3737#define CACHE_ALIAS 0x0000100038383939+#define PG_mapped PG_arch_14040+3941void flush_cache_all(void);4042void flush_cache_mm(struct mm_struct *mm);4143#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
+2
include/asm-sh/cpu-sh4/cacheflush.h
···3939/* Initialization of P3 area for copy_user_page */4040void p3_cache_init(void);41414242+#define PG_mapped PG_arch_14343+4244#endif /* __ASM_CPU_SH4_CACHEFLUSH_H */