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

TOMOYO Linux Cross Reference
Linux/arch/arm64/kernel/cacheinfo.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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/arm64/kernel/cacheinfo.c (Version linux-6.12-rc7) and /arch/i386/kernel/cacheinfo.c (Version linux-2.6.0)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  *  ARM64 cacheinfo support                       
  4  *                                                
  5  *  Copyright (C) 2015 ARM Ltd.                   
  6  *  All Rights Reserved                           
  7  */                                               
  8                                                   
  9 #include <linux/acpi.h>                           
 10 #include <linux/cacheinfo.h>                      
 11 #include <linux/of.h>                             
 12                                                   
 13 #define MAX_CACHE_LEVEL                 7         
 14                                                   
 15 int cache_line_size(void)                         
 16 {                                                 
 17         if (coherency_max_size != 0)              
 18                 return coherency_max_size;        
 19                                                   
 20         return cache_line_size_of_cpu();          
 21 }                                                 
 22 EXPORT_SYMBOL_GPL(cache_line_size);               
 23                                                   
 24 static inline enum cache_type get_cache_type(i    
 25 {                                                 
 26         u64 clidr;                                
 27                                                   
 28         if (level > MAX_CACHE_LEVEL)              
 29                 return CACHE_TYPE_NOCACHE;        
 30         clidr = read_sysreg(clidr_el1);           
 31         return CLIDR_CTYPE(clidr, level);         
 32 }                                                 
 33                                                   
 34 static void ci_leaf_init(struct cacheinfo *thi    
 35                          enum cache_type type,    
 36 {                                                 
 37         this_leaf->level = level;                 
 38         this_leaf->type = type;                   
 39 }                                                 
 40                                                   
 41 static void detect_cache_level(unsigned int *l    
 42 {                                                 
 43         unsigned int ctype, level, leaves;        
 44                                                   
 45         for (level = 1, leaves = 0; level <= M    
 46                 ctype = get_cache_type(level);    
 47                 if (ctype == CACHE_TYPE_NOCACH    
 48                         level--;                  
 49                         break;                    
 50                 }                                 
 51                 /* Separate instruction and da    
 52                 leaves += (ctype == CACHE_TYPE    
 53         }                                         
 54                                                   
 55         *level_p = level;                         
 56         *leaves_p = leaves;                       
 57 }                                                 
 58                                                   
 59 int early_cache_level(unsigned int cpu)           
 60 {                                                 
 61         struct cpu_cacheinfo *this_cpu_ci = ge    
 62                                                   
 63         detect_cache_level(&this_cpu_ci->num_l    
 64                                                   
 65         return 0;                                 
 66 }                                                 
 67                                                   
 68 int init_cache_level(unsigned int cpu)            
 69 {                                                 
 70         unsigned int level, leaves;               
 71         int fw_level, ret;                        
 72         struct cpu_cacheinfo *this_cpu_ci = ge    
 73                                                   
 74         detect_cache_level(&level, &leaves);      
 75                                                   
 76         if (acpi_disabled) {                      
 77                 fw_level = of_find_last_cache_    
 78         } else {                                  
 79                 ret = acpi_get_cache_info(cpu,    
 80                 if (ret < 0)                      
 81                         fw_level = 0;             
 82         }                                         
 83                                                   
 84         if (level < fw_level) {                   
 85                 /*                                
 86                  * some external caches not sp    
 87                  * the information may be avai    
 88                  * only unified external cache    
 89                  */                               
 90                 leaves += (fw_level - level);     
 91                 level = fw_level;                 
 92         }                                         
 93                                                   
 94         this_cpu_ci->num_levels = level;          
 95         this_cpu_ci->num_leaves = leaves;         
 96         return 0;                                 
 97 }                                                 
 98                                                   
 99 int populate_cache_leaves(unsigned int cpu)       
100 {                                                 
101         unsigned int level, idx;                  
102         enum cache_type type;                     
103         struct cpu_cacheinfo *this_cpu_ci = ge    
104         struct cacheinfo *this_leaf = this_cpu    
105                                                   
106         for (idx = 0, level = 1; level <= this    
107              idx < this_cpu_ci->num_leaves; id    
108                 type = get_cache_type(level);     
109                 if (type == CACHE_TYPE_SEPARAT    
110                         ci_leaf_init(this_leaf    
111                         ci_leaf_init(this_leaf    
112                 } else {                          
113                         ci_leaf_init(this_leaf    
114                 }                                 
115         }                                         
116         return 0;                                 
117 }                                                 
118                                                   

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