~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sh/mm/cache-sh7705.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/sh/mm/cache-sh7705.c (Architecture ppc) and /arch/sparc/mm/cache-sh7705.c (Architecture sparc)


  1 /*                                                  1 
  2  * arch/sh/mm/cache-sh7705.c                      
  3  *                                                
  4  * Copyright (C) 1999, 2000  Niibe Yutaka         
  5  * Copyright (C) 2004  Alex Song                  
  6  *                                                
  7  * This file is subject to the terms and condi    
  8  * License.  See the file "COPYING" in the mai    
  9  * for more details.                              
 10  *                                                
 11  */                                               
 12 #include <linux/init.h>                           
 13 #include <linux/mman.h>                           
 14 #include <linux/mm.h>                             
 15 #include <linux/fs.h>                             
 16 #include <linux/pagemap.h>                        
 17 #include <linux/threads.h>                        
 18 #include <asm/addrspace.h>                        
 19 #include <asm/page.h>                             
 20 #include <asm/processor.h>                        
 21 #include <asm/cache.h>                            
 22 #include <asm/io.h>                               
 23 #include <linux/uaccess.h>                        
 24 #include <asm/mmu_context.h>                      
 25 #include <asm/cacheflush.h>                       
 26                                                   
 27 /*                                                
 28  * The 32KB cache on the SH7705 suffers from t    
 29  * as SH4 CPUs                                    
 30  */                                               
 31 static inline void cache_wback_all(void)          
 32 {                                                 
 33         unsigned long ways, waysize, addrstart    
 34                                                   
 35         ways = current_cpu_data.dcache.ways;      
 36         waysize = current_cpu_data.dcache.sets    
 37         waysize <<= current_cpu_data.dcache.en    
 38                                                   
 39         addrstart = CACHE_OC_ADDRESS_ARRAY;       
 40                                                   
 41         do {                                      
 42                 unsigned long addr;               
 43                                                   
 44                 for (addr = addrstart;            
 45                      addr < addrstart + waysiz    
 46                      addr += current_cpu_data.    
 47                         unsigned long data;       
 48                         int v = SH_CACHE_UPDAT    
 49                                                   
 50                         data = __raw_readl(add    
 51                                                   
 52                         if ((data & v) == v)      
 53                                 __raw_writel(d    
 54                                                   
 55                 }                                 
 56                                                   
 57                 addrstart += current_cpu_data.    
 58         } while (--ways);                         
 59 }                                                 
 60                                                   
 61 /*                                                
 62  * Write back the range of D-cache, and purge     
 63  *                                                
 64  * Called from kernel/module.c:sys_init_module    
 65  */                                               
 66 static void sh7705_flush_icache_range(void *ar    
 67 {                                                 
 68         struct flusher_data *data = args;         
 69         unsigned long start, end;                 
 70                                                   
 71         start = data->addr1;                      
 72         end = data->addr2;                        
 73                                                   
 74         __flush_wback_region((void *)start, en    
 75 }                                                 
 76                                                   
 77 /*                                                
 78  * Writeback&Invalidate the D-cache of the pag    
 79  */                                               
 80 static void __flush_dcache_page(unsigned long     
 81 {                                                 
 82         unsigned long ways, waysize, addrstart    
 83         unsigned long flags;                      
 84                                                   
 85         phys |= SH_CACHE_VALID;                   
 86                                                   
 87         /*                                        
 88          * Here, phys is the physical address     
 89          * tags in the cache for those with th    
 90          * (by masking off the lowest 2 bits o    
 91          * derived from the offset within in t    
 92          * entries are invalidated.               
 93          *                                        
 94          * Since 2 bits of the cache index are    
 95          * number, knowing this would reduce t    
 96          * searched by a factor of 4. However     
 97          * potential cache aliasing, therefore    
 98          * possible.                              
 99          */                                       
100         local_irq_save(flags);                    
101         jump_to_uncached();                       
102                                                   
103         ways = current_cpu_data.dcache.ways;      
104         waysize = current_cpu_data.dcache.sets    
105         waysize <<= current_cpu_data.dcache.en    
106                                                   
107         addrstart = CACHE_OC_ADDRESS_ARRAY;       
108                                                   
109         do {                                      
110                 unsigned long addr;               
111                                                   
112                 for (addr = addrstart;            
113                      addr < addrstart + waysiz    
114                      addr += current_cpu_data.    
115                         unsigned long data;       
116                                                   
117                         data = __raw_readl(add    
118                         if (data == phys) {       
119                                 data &= ~(SH_C    
120                                 __raw_writel(d    
121                         }                         
122                 }                                 
123                                                   
124                 addrstart += current_cpu_data.    
125         } while (--ways);                         
126                                                   
127         back_to_cached();                         
128         local_irq_restore(flags);                 
129 }                                                 
130                                                   
131 /*                                                
132  * Write back & invalidate the D-cache of the     
133  * (To avoid "alias" issues)                      
134  */                                               
135 static void sh7705_flush_dcache_folio(void *ar    
136 {                                                 
137         struct folio *folio = arg;                
138         struct address_space *mapping = folio_    
139                                                   
140         if (mapping && !mapping_mapped(mapping    
141                 clear_bit(PG_dcache_clean, &fo    
142         else {                                    
143                 unsigned long pfn = folio_pfn(    
144                 unsigned int i, nr = folio_nr_    
145                                                   
146                 for (i = 0; i < nr; i++)          
147                         __flush_dcache_page((p    
148         }                                         
149 }                                                 
150                                                   
151 static void sh7705_flush_cache_all(void *args)    
152 {                                                 
153         unsigned long flags;                      
154                                                   
155         local_irq_save(flags);                    
156         jump_to_uncached();                       
157                                                   
158         cache_wback_all();                        
159         back_to_cached();                         
160         local_irq_restore(flags);                 
161 }                                                 
162                                                   
163 /*                                                
164  * Write back and invalidate I/D-caches for th    
165  *                                                
166  * ADDRESS: Virtual Address (U0 address)          
167  */                                               
168 static void sh7705_flush_cache_page(void *args    
169 {                                                 
170         struct flusher_data *data = args;         
171         unsigned long pfn = data->addr2;          
172                                                   
173         __flush_dcache_page(pfn << PAGE_SHIFT)    
174 }                                                 
175                                                   
176 /*                                                
177  * This is called when a page-cache page is ab    
178  * user process' address space.  It offers an     
179  * port to ensure d-cache/i-cache coherency if    
180  *                                                
181  * Not entirely sure why this is necessary on     
182  * without it we get occasional "Memory fault"    
183  */                                               
184 static void sh7705_flush_icache_folio(void *ar    
185 {                                                 
186         struct folio *folio = arg;                
187         __flush_purge_region(folio_address(fol    
188 }                                                 
189                                                   
190 void __init sh7705_cache_init(void)               
191 {                                                 
192         local_flush_icache_range        = sh77    
193         local_flush_dcache_folio        = sh77    
194         local_flush_cache_all           = sh77    
195         local_flush_cache_mm            = sh77    
196         local_flush_cache_dup_mm        = sh77    
197         local_flush_cache_range         = sh77    
198         local_flush_cache_page          = sh77    
199         local_flush_icache_folio        = sh77    
200 }                                                 
201                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php