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

TOMOYO Linux Cross Reference
Linux/arch/loongarch/kernel/kfpu.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 /arch/loongarch/kernel/kfpu.c (Version linux-6.12-rc7) and /arch/sparc/kernel/kfpu.c (Version linux-6.6.60)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * Copyright (C) 2023 Loongson Technology Corp    
  4  */                                               
  5                                                   
  6 #include <linux/cpu.h>                            
  7 #include <linux/init.h>                           
  8 #include <asm/fpu.h>                              
  9 #include <asm/smp.h>                              
 10                                                   
 11 static unsigned int euen_mask = CSR_EUEN_FPEN;    
 12                                                   
 13 /*                                                
 14  * The critical section between kernel_fpu_beg    
 15  * is non-reentrant. It is the caller's respon    
 16  * See drivers/gpu/drm/amd/display/amdgpu_dm/d    
 17  */                                               
 18 static DEFINE_PER_CPU(bool, in_kernel_fpu);       
 19 static DEFINE_PER_CPU(unsigned int, euen_curre    
 20                                                   
 21 void kernel_fpu_begin(void)                       
 22 {                                                 
 23         unsigned int *euen_curr;                  
 24                                                   
 25         preempt_disable();                        
 26                                                   
 27         WARN_ON(this_cpu_read(in_kernel_fpu));    
 28                                                   
 29         this_cpu_write(in_kernel_fpu, true);      
 30         euen_curr = this_cpu_ptr(&euen_current    
 31                                                   
 32         *euen_curr = csr_xchg32(euen_mask, eue    
 33                                                   
 34 #ifdef CONFIG_CPU_HAS_LASX                        
 35         if (*euen_curr & CSR_EUEN_LASXEN)         
 36                 _save_lasx(&current->thread.fp    
 37         else                                      
 38 #endif                                            
 39 #ifdef CONFIG_CPU_HAS_LSX                         
 40         if (*euen_curr & CSR_EUEN_LSXEN)          
 41                 _save_lsx(&current->thread.fpu    
 42         else                                      
 43 #endif                                            
 44         if (*euen_curr & CSR_EUEN_FPEN)           
 45                 _save_fp(&current->thread.fpu)    
 46                                                   
 47         write_fcsr(LOONGARCH_FCSR0, 0);           
 48 }                                                 
 49 EXPORT_SYMBOL_GPL(kernel_fpu_begin);              
 50                                                   
 51 void kernel_fpu_end(void)                         
 52 {                                                 
 53         unsigned int *euen_curr;                  
 54                                                   
 55         WARN_ON(!this_cpu_read(in_kernel_fpu))    
 56                                                   
 57         euen_curr = this_cpu_ptr(&euen_current    
 58                                                   
 59 #ifdef CONFIG_CPU_HAS_LASX                        
 60         if (*euen_curr & CSR_EUEN_LASXEN)         
 61                 _restore_lasx(&current->thread    
 62         else                                      
 63 #endif                                            
 64 #ifdef CONFIG_CPU_HAS_LSX                         
 65         if (*euen_curr & CSR_EUEN_LSXEN)          
 66                 _restore_lsx(&current->thread.    
 67         else                                      
 68 #endif                                            
 69         if (*euen_curr & CSR_EUEN_FPEN)           
 70                 _restore_fp(&current->thread.f    
 71                                                   
 72         *euen_curr = csr_xchg32(*euen_curr, eu    
 73                                                   
 74         this_cpu_write(in_kernel_fpu, false);     
 75                                                   
 76         preempt_enable();                         
 77 }                                                 
 78 EXPORT_SYMBOL_GPL(kernel_fpu_end);                
 79                                                   
 80 static int __init init_euen_mask(void)            
 81 {                                                 
 82         if (cpu_has_lsx)                          
 83                 euen_mask |= CSR_EUEN_LSXEN;      
 84                                                   
 85         if (cpu_has_lasx)                         
 86                 euen_mask |= CSR_EUEN_LASXEN;     
 87                                                   
 88         return 0;                                 
 89 }                                                 
 90 arch_initcall(init_euen_mask);                    
 91                                                   

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