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

TOMOYO Linux Cross Reference
Linux/arch/mips/kernel/cacheinfo.c

Version: ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * MIPS cacheinfo support
  4  */
  5 #include <linux/cacheinfo.h>
  6 
  7 /* Populates leaf and increments to next leaf */
  8 #define populate_cache(cache, leaf, c_level, c_type)            \
  9 do {                                                            \
 10         leaf->type = c_type;                                    \
 11         leaf->level = c_level;                                  \
 12         leaf->coherency_line_size = c->cache.linesz;            \
 13         leaf->number_of_sets = c->cache.sets;                   \
 14         leaf->ways_of_associativity = c->cache.ways;            \
 15         leaf->size = c->cache.linesz * c->cache.sets *          \
 16                 c->cache.ways;                                  \
 17         leaf++;                                                 \
 18 } while (0)
 19 
 20 static int __init_cache_level(unsigned int cpu)
 21 {
 22         struct cpuinfo_mips *c = &current_cpu_data;
 23         struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 24         int levels = 0, leaves = 0;
 25 
 26         /*
 27          * If Dcache is not set, we assume the cache structures
 28          * are not properly initialized.
 29          */
 30         if (c->dcache.waysize)
 31                 levels += 1;
 32         else
 33                 return -ENOENT;
 34 
 35 
 36         leaves += (c->icache.waysize) ? 2 : 1;
 37 
 38         if (c->scache.waysize) {
 39                 levels++;
 40                 leaves++;
 41         }
 42 
 43         if (c->tcache.waysize) {
 44                 levels++;
 45                 leaves++;
 46         }
 47 
 48         this_cpu_ci->num_levels = levels;
 49         this_cpu_ci->num_leaves = leaves;
 50         return 0;
 51 }
 52 
 53 static int __populate_cache_leaves(unsigned int cpu)
 54 {
 55         struct cpuinfo_mips *c = &current_cpu_data;
 56         struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 57         struct cacheinfo *this_leaf = this_cpu_ci->info_list;
 58 
 59         if (c->icache.waysize) {
 60                 populate_cache(dcache, this_leaf, 1, CACHE_TYPE_DATA);
 61                 populate_cache(icache, this_leaf, 1, CACHE_TYPE_INST);
 62         } else {
 63                 populate_cache(dcache, this_leaf, 1, CACHE_TYPE_UNIFIED);
 64         }
 65 
 66         if (c->scache.waysize)
 67                 populate_cache(scache, this_leaf, 2, CACHE_TYPE_UNIFIED);
 68 
 69         if (c->tcache.waysize)
 70                 populate_cache(tcache, this_leaf, 3, CACHE_TYPE_UNIFIED);
 71 
 72         this_cpu_ci->cpu_map_populated = true;
 73 
 74         return 0;
 75 }
 76 
 77 DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
 78 DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
 79 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp