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

TOMOYO Linux Cross Reference
Linux/arch/loongarch/include/asm/percpu.h

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 /arch/loongarch/include/asm/percpu.h (Version linux-6.12-rc7) and /arch/i386/include/asm-i386/percpu.h (Version linux-5.3.18)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 /*                                                
  3  * Copyright (C) 2020-2022 Loongson Technology    
  4  */                                               
  5 #ifndef __ASM_PERCPU_H                            
  6 #define __ASM_PERCPU_H                            
  7                                                   
  8 #include <asm/cmpxchg.h>                          
  9 #include <asm/loongarch.h>                        
 10                                                   
 11 /*                                                
 12  * The "address" (in fact, offset from $r21) o    
 13  * the loading address of main kernel image, b    
 14  * loaded. Tell the compiler this fact when us    
 15  */                                               
 16 #if defined(MODULE) && defined(CONFIG_AS_HAS_E    
 17 # if __has_attribute(model)                       
 18 #  define PER_CPU_ATTRIBUTES __attribute__((mo    
 19 # else                                            
 20 #  error compiler support for the model attrib    
 21 # endif                                           
 22 #endif                                            
 23                                                   
 24 /* Use r21 for fast access */                     
 25 register unsigned long __my_cpu_offset __asm__    
 26                                                   
 27 static inline void set_my_cpu_offset(unsigned     
 28 {                                                 
 29         __my_cpu_offset = off;                    
 30         csr_write64(off, PERCPU_BASE_KS);         
 31 }                                                 
 32                                                   
 33 #define __my_cpu_offset                           
 34 ({                                                
 35         __asm__ __volatile__("":"+r"(__my_cpu_    
 36         __my_cpu_offset;                          
 37 })                                                
 38                                                   
 39 #define PERCPU_OP(op, asm_op, c_op)               
 40 static __always_inline unsigned long __percpu_    
 41                         unsigned long val, int    
 42 {                                                 
 43         unsigned long ret;                        
 44                                                   
 45         switch (size) {                           
 46         case 4:                                   
 47                 __asm__ __volatile__(             
 48                 "am"#asm_op".w" " %[ret], %[va    
 49                 : [ret] "=&r" (ret), [ptr] "+Z    
 50                 : [val] "r" (val));               
 51                 break;                            
 52         case 8:                                   
 53                 __asm__ __volatile__(             
 54                 "am"#asm_op".d" " %[ret], %[va    
 55                 : [ret] "=&r" (ret), [ptr] "+Z    
 56                 : [val] "r" (val));               
 57                 break;                            
 58         default:                                  
 59                 ret = 0;                          
 60                 BUILD_BUG();                      
 61         }                                         
 62                                                   
 63         return ret c_op val;                      
 64 }                                                 
 65                                                   
 66 PERCPU_OP(add, add, +)                            
 67 PERCPU_OP(and, and, &)                            
 68 PERCPU_OP(or, or, |)                              
 69 #undef PERCPU_OP                                  
 70                                                   
 71 static __always_inline unsigned long __percpu_    
 72 {                                                 
 73         switch (size) {                           
 74         case 1:                                   
 75         case 2:                                   
 76                 return __xchg_small((volatile     
 77                                                   
 78         case 4:                                   
 79                 return __xchg_asm("amswap.w",     
 80                                                   
 81         case 8:                                   
 82                 return __xchg_asm("amswap.d",     
 83                                                   
 84         default:                                  
 85                 BUILD_BUG();                      
 86         }                                         
 87                                                   
 88         return 0;                                 
 89 }                                                 
 90                                                   
 91 #define __pcpu_op_1(op)         op ".b "          
 92 #define __pcpu_op_2(op)         op ".h "          
 93 #define __pcpu_op_4(op)         op ".w "          
 94 #define __pcpu_op_8(op)         op ".d "          
 95                                                   
 96 #define _percpu_read(size, _pcp)                  
 97 ({                                                
 98         typeof(_pcp) __pcp_ret;                   
 99                                                   
100         __asm__ __volatile__(                     
101                 __pcpu_op_##size("ldx") "%[ret    
102                 : [ret] "=&r"(__pcp_ret)          
103                 : [ptr] "r"(&(_pcp))              
104                 : "memory");                      
105                                                   
106         __pcp_ret;                                
107 })                                                
108                                                   
109 #define _percpu_write(size, _pcp, _val)           
110 do {                                              
111         __asm__ __volatile__(                     
112                 __pcpu_op_##size("stx") "%[val    
113                 :                                 
114                 : [val] "r"(_val), [ptr] "r"(&    
115                 : "memory");                      
116 } while (0)                                       
117                                                   
118 /* this_cpu_cmpxchg */                            
119 #define _protect_cmpxchg_local(pcp, o, n)         
120 ({                                                
121         typeof(*raw_cpu_ptr(&(pcp))) __ret;       
122         preempt_disable_notrace();                
123         __ret = cmpxchg_local(raw_cpu_ptr(&(pc    
124         preempt_enable_notrace();                 
125         __ret;                                    
126 })                                                
127                                                   
128 #define _pcp_protect(operation, pcp, val)         
129 ({                                                
130         typeof(pcp) __retval;                     
131         preempt_disable_notrace();                
132         __retval = (typeof(pcp))operation(raw_    
133                                           (val    
134         preempt_enable_notrace();                 
135         __retval;                                 
136 })                                                
137                                                   
138 #define _percpu_add(pcp, val) \                   
139         _pcp_protect(__percpu_add, pcp, val)      
140                                                   
141 #define _percpu_add_return(pcp, val) _percpu_a    
142                                                   
143 #define _percpu_and(pcp, val) \                   
144         _pcp_protect(__percpu_and, pcp, val)      
145                                                   
146 #define _percpu_or(pcp, val) \                    
147         _pcp_protect(__percpu_or, pcp, val)       
148                                                   
149 #define _percpu_xchg(pcp, val) ((typeof(pcp))     
150         _pcp_protect(__percpu_xchg, pcp, (unsi    
151                                                   
152 #define this_cpu_add_4(pcp, val) _percpu_add(p    
153 #define this_cpu_add_8(pcp, val) _percpu_add(p    
154                                                   
155 #define this_cpu_add_return_4(pcp, val) _percp    
156 #define this_cpu_add_return_8(pcp, val) _percp    
157                                                   
158 #define this_cpu_and_4(pcp, val) _percpu_and(p    
159 #define this_cpu_and_8(pcp, val) _percpu_and(p    
160                                                   
161 #define this_cpu_or_4(pcp, val) _percpu_or(pcp    
162 #define this_cpu_or_8(pcp, val) _percpu_or(pcp    
163                                                   
164 #define this_cpu_read_1(pcp) _percpu_read(1, p    
165 #define this_cpu_read_2(pcp) _percpu_read(2, p    
166 #define this_cpu_read_4(pcp) _percpu_read(4, p    
167 #define this_cpu_read_8(pcp) _percpu_read(8, p    
168                                                   
169 #define this_cpu_write_1(pcp, val) _percpu_wri    
170 #define this_cpu_write_2(pcp, val) _percpu_wri    
171 #define this_cpu_write_4(pcp, val) _percpu_wri    
172 #define this_cpu_write_8(pcp, val) _percpu_wri    
173                                                   
174 #define this_cpu_xchg_1(pcp, val) _percpu_xchg    
175 #define this_cpu_xchg_2(pcp, val) _percpu_xchg    
176 #define this_cpu_xchg_4(pcp, val) _percpu_xchg    
177 #define this_cpu_xchg_8(pcp, val) _percpu_xchg    
178                                                   
179 #define this_cpu_cmpxchg_1(ptr, o, n) _protect    
180 #define this_cpu_cmpxchg_2(ptr, o, n) _protect    
181 #define this_cpu_cmpxchg_4(ptr, o, n) _protect    
182 #define this_cpu_cmpxchg_8(ptr, o, n) _protect    
183                                                   
184 #include <asm-generic/percpu.h>                   
185                                                   
186 #endif /* __ASM_PERCPU_H */                       
187                                                   

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