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

TOMOYO Linux Cross Reference
Linux/kernel/iomem.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /kernel/iomem.c (Version linux-6.12-rc7) and /kernel/iomem.c (Version linux-2.6.32.71)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 #include <linux/device.h>                         
  3 #include <linux/types.h>                          
  4 #include <linux/io.h>                             
  5 #include <linux/mm.h>                             
  6 #include <linux/ioremap.h>                        
  7                                                   
  8 #ifndef arch_memremap_wb                          
  9 static void *arch_memremap_wb(resource_size_t     
 10 {                                                 
 11 #ifdef ioremap_cache                              
 12         return (__force void *)ioremap_cache(o    
 13 #else                                             
 14         return (__force void *)ioremap(offset,    
 15 #endif                                            
 16 }                                                 
 17 #endif                                            
 18                                                   
 19 #ifndef arch_memremap_can_ram_remap               
 20 static bool arch_memremap_can_ram_remap(resour    
 21                                         unsign    
 22 {                                                 
 23         return true;                              
 24 }                                                 
 25 #endif                                            
 26                                                   
 27 static void *try_ram_remap(resource_size_t off    
 28                            unsigned long flags    
 29 {                                                 
 30         unsigned long pfn = PHYS_PFN(offset);     
 31                                                   
 32         /* In the simple case just return the     
 33         if (pfn_valid(pfn) && !PageHighMem(pfn    
 34             arch_memremap_can_ram_remap(offset    
 35                 return __va(offset);              
 36                                                   
 37         return NULL; /* fallback to arch_memre    
 38 }                                                 
 39                                                   
 40 /**                                               
 41  * memremap() - remap an iomem_resource as cac    
 42  * @offset: iomem resource start address          
 43  * @size: size of remap                           
 44  * @flags: any of MEMREMAP_WB, MEMREMAP_WT, ME    
 45  *                MEMREMAP_ENC, MEMREMAP_DEC      
 46  *                                                
 47  * memremap() is "ioremap" for cases where it     
 48  * being mapped does not have i/o side effects    
 49  * annotation is not applicable. In the case o    
 50  * mapping types will be attempted in the orde    
 51  * them succeeds.                                 
 52  *                                                
 53  * MEMREMAP_WB - matches the default mapping f    
 54  * the architecture.  This is usually a read-a    
 55  * Moreover, if MEMREMAP_WB is specified and t    
 56  * memremap() will bypass establishing a new m    
 57  * a pointer into the direct map.                 
 58  *                                                
 59  * MEMREMAP_WT - establish a mapping whereby w    
 60  * cache or are written through to memory and     
 61  * cache-dirty state with respect to program v    
 62  * map System RAM with this mapping type will     
 63  *                                                
 64  * MEMREMAP_WC - establish a writecombine mapp    
 65  * be coalesced together (e.g. in the CPU's wr    
 66  * uncached. Attempts to map System RAM with t    
 67  */                                               
 68 void *memremap(resource_size_t offset, size_t     
 69 {                                                 
 70         int is_ram = region_intersects(offset,    
 71                                        IORESOU    
 72         void *addr = NULL;                        
 73                                                   
 74         if (!flags)                               
 75                 return NULL;                      
 76                                                   
 77         if (is_ram == REGION_MIXED) {             
 78                 WARN_ONCE(1, "memremap attempt    
 79                                 &offset, (unsi    
 80                 return NULL;                      
 81         }                                         
 82                                                   
 83         /* Try all mapping types requested unt    
 84         if (flags & MEMREMAP_WB) {                
 85                 /*                                
 86                  * MEMREMAP_WB is special in t    
 87                  * from the direct map.  Some     
 88                  * capability of memremap() to    
 89                  * the requested range is pote    
 90                  */                               
 91                 if (is_ram == REGION_INTERSECT    
 92                         addr = try_ram_remap(o    
 93                 if (!addr)                        
 94                         addr = arch_memremap_w    
 95         }                                         
 96                                                   
 97         /*                                        
 98          * If we don't have a mapping yet and     
 99          * present then we will be attempting     
100          * address mapping.  Enforce that this    
101          * System RAM.                            
102          */                                       
103         if (!addr && is_ram == REGION_INTERSEC    
104                 WARN_ONCE(1, "memremap attempt    
105                                 &offset, (unsi    
106                 return NULL;                      
107         }                                         
108                                                   
109         if (!addr && (flags & MEMREMAP_WT))       
110                 addr = ioremap_wt(offset, size    
111                                                   
112         if (!addr && (flags & MEMREMAP_WC))       
113                 addr = ioremap_wc(offset, size    
114                                                   
115         return addr;                              
116 }                                                 
117 EXPORT_SYMBOL(memremap);                          
118                                                   
119 void memunmap(void *addr)                         
120 {                                                 
121         if (is_ioremap_addr(addr))                
122                 iounmap((void __iomem *) addr)    
123 }                                                 
124 EXPORT_SYMBOL(memunmap);                          
125                                                   
126 static void devm_memremap_release(struct devic    
127 {                                                 
128         memunmap(*(void **)res);                  
129 }                                                 
130                                                   
131 static int devm_memremap_match(struct device *    
132 {                                                 
133         return *(void **)res == match_data;       
134 }                                                 
135                                                   
136 void *devm_memremap(struct device *dev, resour    
137                 size_t size, unsigned long fla    
138 {                                                 
139         void **ptr, *addr;                        
140                                                   
141         ptr = devres_alloc_node(devm_memremap_    
142                         dev_to_node(dev));        
143         if (!ptr)                                 
144                 return ERR_PTR(-ENOMEM);          
145                                                   
146         addr = memremap(offset, size, flags);     
147         if (addr) {                               
148                 *ptr = addr;                      
149                 devres_add(dev, ptr);             
150         } else {                                  
151                 devres_free(ptr);                 
152                 return ERR_PTR(-ENXIO);           
153         }                                         
154                                                   
155         return addr;                              
156 }                                                 
157 EXPORT_SYMBOL(devm_memremap);                     
158                                                   
159 void devm_memunmap(struct device *dev, void *a    
160 {                                                 
161         WARN_ON(devres_release(dev, devm_memre    
162                                 devm_memremap_    
163 }                                                 
164 EXPORT_SYMBOL(devm_memunmap);                     
165                                                   

~ [ 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