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

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

Version: ~ [ linux-5.15-rc5 ] ~ [ linux-5.14.11 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.72 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.152 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.210 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.250 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.286 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.288 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ 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 /*
  2  * MIPS cacheinfo support
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU General Public License version 2 as
  6  * published by the Free Software Foundation.
  7  *
  8  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  9  * kind, whether express or implied; without even the implied warranty
 10  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 11  * GNU General Public License for more details.
 12  *
 13  * You should have received a copy of the GNU General Public License
 14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 15  */
 16 #include <linux/cacheinfo.h>
 17 
 18 /* Populates leaf and increments to next leaf */
 19 #define populate_cache(cache, leaf, c_level, c_type)            \
 20 do {                                                            \
 21         leaf->type = c_type;                                    \
 22         leaf->level = c_level;                                  \
 23         leaf->coherency_line_size = c->cache.linesz;            \
 24         leaf->number_of_sets = c->cache.sets;                   \
 25         leaf->ways_of_associativity = c->cache.ways;            \
 26         leaf->size = c->cache.linesz * c->cache.sets *          \
 27                 c->cache.ways;                                  \
 28         leaf++;                                                 \
 29 } while (0)
 30 
 31 static int __init_cache_level(unsigned int cpu)
 32 {
 33         struct cpuinfo_mips *c = &current_cpu_data;
 34         struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 35         int levels = 0, leaves = 0;
 36 
 37         /*
 38          * If Dcache is not set, we assume the cache structures
 39          * are not properly initialized.
 40          */
 41         if (c->dcache.waysize)
 42                 levels += 1;
 43         else
 44                 return -ENOENT;
 45 
 46 
 47         leaves += (c->icache.waysize) ? 2 : 1;
 48 
 49         if (c->scache.waysize) {
 50                 levels++;
 51                 leaves++;
 52         }
 53 
 54         if (c->tcache.waysize) {
 55                 levels++;
 56                 leaves++;
 57         }
 58 
 59         this_cpu_ci->num_levels = levels;
 60         this_cpu_ci->num_leaves = leaves;
 61         return 0;
 62 }
 63 
 64 static int __populate_cache_leaves(unsigned int cpu)
 65 {
 66         struct cpuinfo_mips *c = &current_cpu_data;
 67         struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 68         struct cacheinfo *this_leaf = this_cpu_ci->info_list;
 69 
 70         if (c->icache.waysize) {
 71                 populate_cache(dcache, this_leaf, 1, CACHE_TYPE_DATA);
 72                 populate_cache(icache, this_leaf, 1, CACHE_TYPE_INST);
 73         } else {
 74                 populate_cache(dcache, this_leaf, 1, CACHE_TYPE_UNIFIED);
 75         }
 76 
 77         if (c->scache.waysize)
 78                 populate_cache(scache, this_leaf, 2, CACHE_TYPE_UNIFIED);
 79 
 80         if (c->tcache.waysize)
 81                 populate_cache(tcache, this_leaf, 3, CACHE_TYPE_UNIFIED);
 82 
 83         return 0;
 84 }
 85 
 86 DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
 87 DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
 88 

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