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

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

Diff markup

Differences between /arch/riscv/kernel/cacheinfo.c (Version linux-6.12-rc7) and /arch/i386/kernel/cacheinfo.c (Version ccs-tools-1.8.12)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * Copyright (C) 2017 SiFive                      
  4  */                                               
  5                                                   
  6 #include <linux/acpi.h>                           
  7 #include <linux/cpu.h>                            
  8 #include <linux/of.h>                             
  9 #include <asm/cacheinfo.h>                        
 10                                                   
 11 static struct riscv_cacheinfo_ops *rv_cache_op    
 12                                                   
 13 void riscv_set_cacheinfo_ops(struct riscv_cach    
 14 {                                                 
 15         rv_cache_ops = ops;                       
 16 }                                                 
 17 EXPORT_SYMBOL_GPL(riscv_set_cacheinfo_ops);       
 18                                                   
 19 const struct attribute_group *                    
 20 cache_get_priv_group(struct cacheinfo *this_le    
 21 {                                                 
 22         if (rv_cache_ops && rv_cache_ops->get_    
 23                 return rv_cache_ops->get_priv_    
 24         return NULL;                              
 25 }                                                 
 26                                                   
 27 static struct cacheinfo *get_cacheinfo(u32 lev    
 28 {                                                 
 29         /*                                        
 30          * Using raw_smp_processor_id() elides    
 31          * is really indicative of a larger pr    
 32          * that cores have a homonogenous view    
 33          * happens to be the case for the curr    
 34          * likely won't be true in general.  S    
 35          * correct information for these syste    
 36          * just eliding the check for now.        
 37          */                                       
 38         struct cpu_cacheinfo *this_cpu_ci = ge    
 39         struct cacheinfo *this_leaf;              
 40         int index;                                
 41                                                   
 42         for (index = 0; index < this_cpu_ci->n    
 43                 this_leaf = this_cpu_ci->info_    
 44                 if (this_leaf->level == level     
 45                         return this_leaf;         
 46         }                                         
 47                                                   
 48         return NULL;                              
 49 }                                                 
 50                                                   
 51 uintptr_t get_cache_size(u32 level, enum cache    
 52 {                                                 
 53         struct cacheinfo *this_leaf = get_cach    
 54                                                   
 55         return this_leaf ? this_leaf->size : 0    
 56 }                                                 
 57                                                   
 58 uintptr_t get_cache_geometry(u32 level, enum c    
 59 {                                                 
 60         struct cacheinfo *this_leaf = get_cach    
 61                                                   
 62         return this_leaf ? (this_leaf->ways_of    
 63                             this_leaf->coheren    
 64                            0;                     
 65 }                                                 
 66                                                   
 67 static void ci_leaf_init(struct cacheinfo *thi    
 68                          enum cache_type type,    
 69 {                                                 
 70         this_leaf->level = level;                 
 71         this_leaf->type = type;                   
 72 }                                                 
 73                                                   
 74 int init_cache_level(unsigned int cpu)            
 75 {                                                 
 76         return init_of_cache_level(cpu);          
 77 }                                                 
 78                                                   
 79 int populate_cache_leaves(unsigned int cpu)       
 80 {                                                 
 81         struct cpu_cacheinfo *this_cpu_ci = ge    
 82         struct cacheinfo *this_leaf = this_cpu    
 83         struct device_node *np, *prev;            
 84         int levels = 1, level = 1;                
 85                                                   
 86         if (!acpi_disabled) {                     
 87                 int ret, fw_levels, split_leve    
 88                                                   
 89                 ret = acpi_get_cache_info(cpu,    
 90                 if (ret)                          
 91                         return ret;               
 92                                                   
 93                 BUG_ON((split_levels > fw_leve    
 94                        (split_levels + fw_leve    
 95                                                   
 96                 for (; level <= this_cpu_ci->n    
 97                         if (level <= split_lev    
 98                                 ci_leaf_init(t    
 99                                 ci_leaf_init(t    
100                         } else {                  
101                                 ci_leaf_init(t    
102                         }                         
103                 }                                 
104                 return 0;                         
105         }                                         
106                                                   
107         np = of_cpu_device_node_get(cpu);         
108         if (!np)                                  
109                 return -ENOENT;                   
110                                                   
111         if (of_property_read_bool(np, "cache-s    
112                 ci_leaf_init(this_leaf++, CACH    
113         if (of_property_read_bool(np, "i-cache    
114                 ci_leaf_init(this_leaf++, CACH    
115         if (of_property_read_bool(np, "d-cache    
116                 ci_leaf_init(this_leaf++, CACH    
117                                                   
118         prev = np;                                
119         while ((np = of_find_next_cache_node(n    
120                 of_node_put(prev);                
121                 prev = np;                        
122                 if (!of_device_is_compatible(n    
123                         break;                    
124                 if (of_property_read_u32(np, "    
125                         break;                    
126                 if (level <= levels)              
127                         break;                    
128                 if (of_property_read_bool(np,     
129                         ci_leaf_init(this_leaf    
130                 if (of_property_read_bool(np,     
131                         ci_leaf_init(this_leaf    
132                 if (of_property_read_bool(np,     
133                         ci_leaf_init(this_leaf    
134                 levels = level;                   
135         }                                         
136         of_node_put(np);                          
137                                                   
138         return 0;                                 
139 }                                                 
140                                                   

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