Lines Matching refs:cache

44 	struct cache *cache;  member
118 struct cache { struct
124 struct cache *next_local; /* next cache of >= level */ argument
139 static const char *cache_type_string(const struct cache *cache) in cache_type_string() argument
141 return cache_type_info[cache->type].name; in cache_type_string()
144 static void cache_init(struct cache *cache, int type, int level, in cache_init() argument
147 cache->type = type; in cache_init()
148 cache->level = level; in cache_init()
149 cache->ofnode = of_node_get(ofnode); in cache_init()
150 INIT_LIST_HEAD(&cache->list); in cache_init()
151 list_add(&cache->list, &cache_list); in cache_init()
154 static struct cache *new_cache(int type, int level, struct device_node *ofnode) in new_cache()
156 struct cache *cache; in new_cache() local
158 cache = kzalloc(sizeof(*cache), GFP_KERNEL); in new_cache()
159 if (cache) in new_cache()
160 cache_init(cache, type, level, ofnode); in new_cache()
162 return cache; in new_cache()
165 static void release_cache_debugcheck(struct cache *cache) in release_cache_debugcheck() argument
167 struct cache *iter; in release_cache_debugcheck()
170 WARN_ONCE(iter->next_local == cache, in release_cache_debugcheck()
174 cache->ofnode, in release_cache_debugcheck()
175 cache_type_string(cache)); in release_cache_debugcheck()
178 static void release_cache(struct cache *cache) in release_cache() argument
180 if (!cache) in release_cache()
183 pr_debug("freeing L%d %s cache for %pOFP\n", cache->level, in release_cache()
184 cache_type_string(cache), cache->ofnode); in release_cache()
186 release_cache_debugcheck(cache); in release_cache()
187 list_del(&cache->list); in release_cache()
188 of_node_put(cache->ofnode); in release_cache()
189 kfree(cache); in release_cache()
192 static void cache_cpu_set(struct cache *cache, int cpu) in cache_cpu_set() argument
194 struct cache *next = cache; in cache_cpu_set()
206 static int cache_size(const struct cache *cache, unsigned int *ret) in cache_size() argument
211 propname = cache_type_info[cache->type].size_prop; in cache_size()
213 cache_size = of_get_property(cache->ofnode, propname, NULL); in cache_size()
221 static int cache_size_kb(const struct cache *cache, unsigned int *ret) in cache_size_kb() argument
225 if (cache_size(cache, &size)) in cache_size_kb()
233 static int cache_get_line_size(const struct cache *cache, unsigned int *ret) in cache_get_line_size() argument
238 lim = ARRAY_SIZE(cache_type_info[cache->type].line_size_props); in cache_get_line_size()
243 propname = cache_type_info[cache->type].line_size_props[i]; in cache_get_line_size()
244 line_size = of_get_property(cache->ofnode, propname, NULL); in cache_get_line_size()
256 static int cache_nr_sets(const struct cache *cache, unsigned int *ret) in cache_nr_sets() argument
261 propname = cache_type_info[cache->type].nr_sets_prop; in cache_nr_sets()
263 nr_sets = of_get_property(cache->ofnode, propname, NULL); in cache_nr_sets()
271 static int cache_associativity(const struct cache *cache, unsigned int *ret) in cache_associativity() argument
277 if (cache_nr_sets(cache, &nr_sets)) in cache_associativity()
288 if (cache_get_line_size(cache, &line_size)) in cache_associativity()
290 if (cache_size(cache, &size)) in cache_associativity()
303 static struct cache *cache_find_first_sibling(struct cache *cache) in cache_find_first_sibling() argument
305 struct cache *iter; in cache_find_first_sibling()
307 if (cache->type == CACHE_TYPE_UNIFIED || in cache_find_first_sibling()
308 cache->type == CACHE_TYPE_UNIFIED_D) in cache_find_first_sibling()
309 return cache; in cache_find_first_sibling()
312 if (iter->ofnode == cache->ofnode && iter->next_local == cache) in cache_find_first_sibling()
315 return cache; in cache_find_first_sibling()
319 static struct cache *cache_lookup_by_node(const struct device_node *node) in cache_lookup_by_node()
321 struct cache *cache = NULL; in cache_lookup_by_node() local
322 struct cache *iter; in cache_lookup_by_node()
327 cache = cache_find_first_sibling(iter); in cache_lookup_by_node()
331 return cache; in cache_lookup_by_node()
355 static struct cache *cache_do_one_devnode_unified(struct device_node *node, int level) in cache_do_one_devnode_unified()
362 static struct cache *cache_do_one_devnode_split(struct device_node *node, in cache_do_one_devnode_split()
365 struct cache *dcache, *icache; in cache_do_one_devnode_split()
385 static struct cache *cache_do_one_devnode(struct device_node *node, int level) in cache_do_one_devnode()
387 struct cache *cache; in cache_do_one_devnode() local
390 cache = cache_do_one_devnode_unified(node, level); in cache_do_one_devnode()
392 cache = cache_do_one_devnode_split(node, level); in cache_do_one_devnode()
394 return cache; in cache_do_one_devnode()
397 static struct cache *cache_lookup_or_instantiate(struct device_node *node, in cache_lookup_or_instantiate()
400 struct cache *cache; in cache_lookup_or_instantiate() local
402 cache = cache_lookup_by_node(node); in cache_lookup_or_instantiate()
404 WARN_ONCE(cache && cache->level != level, in cache_lookup_or_instantiate()
406 cache->level, level); in cache_lookup_or_instantiate()
408 if (!cache) in cache_lookup_or_instantiate()
409 cache = cache_do_one_devnode(node, level); in cache_lookup_or_instantiate()
411 return cache; in cache_lookup_or_instantiate()
414 static void link_cache_lists(struct cache *smaller, struct cache *bigger) in link_cache_lists()
434 static void do_subsidiary_caches_debugcheck(struct cache *cache) in do_subsidiary_caches_debugcheck() argument
436 WARN_ONCE(cache->level != 1, in do_subsidiary_caches_debugcheck()
438 "%pOFP instead of an L1\n", cache->level, in do_subsidiary_caches_debugcheck()
439 cache_type_string(cache), cache->ofnode); in do_subsidiary_caches_debugcheck()
440 WARN_ONCE(!of_node_is_type(cache->ofnode, "cpu"), in do_subsidiary_caches_debugcheck()
442 "instead of a cpu node\n", cache->ofnode, in do_subsidiary_caches_debugcheck()
443 of_node_get_device_type(cache->ofnode)); in do_subsidiary_caches_debugcheck()
446 static void do_subsidiary_caches(struct cache *cache) in do_subsidiary_caches() argument
449 int level = cache->level; in do_subsidiary_caches()
451 do_subsidiary_caches_debugcheck(cache); in do_subsidiary_caches()
453 while ((subcache_node = of_find_next_cache_node(cache->ofnode))) { in do_subsidiary_caches()
454 struct cache *subcache; in do_subsidiary_caches()
462 link_cache_lists(cache, subcache); in do_subsidiary_caches()
463 cache = subcache; in do_subsidiary_caches()
467 static struct cache *cache_chain_instantiate(unsigned int cpu_id) in cache_chain_instantiate()
470 struct cache *cpu_cache = NULL; in cache_chain_instantiate()
530 index->cache->level, cache_type_string(index->cache)); in cache_index_release()
544 static struct cache *index_kobj_to_cache(struct kobject *k) in index_kobj_to_cache()
550 return index->cache; in index_kobj_to_cache()
556 struct cache *cache; in size_show() local
558 cache = index_kobj_to_cache(k); in size_show()
560 if (cache_size_kb(cache, &size_kb)) in size_show()
573 struct cache *cache; in line_size_show() local
575 cache = index_kobj_to_cache(k); in line_size_show()
577 if (cache_get_line_size(cache, &line_size)) in line_size_show()
589 struct cache *cache; in nr_sets_show() local
591 cache = index_kobj_to_cache(k); in nr_sets_show()
593 if (cache_nr_sets(cache, &nr_sets)) in nr_sets_show()
605 struct cache *cache; in associativity_show() local
607 cache = index_kobj_to_cache(k); in associativity_show()
609 if (cache_associativity(cache, &associativity)) in associativity_show()
620 struct cache *cache; in type_show() local
622 cache = index_kobj_to_cache(k); in type_show()
624 return sprintf(buf, "%s\n", cache_type_string(cache)); in type_show()
633 struct cache *cache; in level_show() local
636 cache = index->cache; in level_show()
638 return sprintf(buf, "%d\n", cache->level); in level_show()
659 static const struct cpumask *get_big_core_shared_cpu_map(int cpu, struct cache *cache) in get_big_core_shared_cpu_map() argument
661 if (cache->level == 1) in get_big_core_shared_cpu_map()
664 return &cache->shared_cpu_map; in get_big_core_shared_cpu_map()
671 struct cache *cache; in show_shared_cpumap() local
676 cache = index->cache; in show_shared_cpumap()
680 mask = get_big_core_shared_cpu_map(cpu, cache); in show_shared_cpumap()
682 mask = &cache->shared_cpu_map; in show_shared_cpumap()
739 struct cache *cache; in cacheinfo_create_index_opt_attrs() local
747 cache = dir->cache; in cacheinfo_create_index_opt_attrs()
748 cache_type = cache_type_string(cache); in cacheinfo_create_index_opt_attrs()
765 attr->attr.name, cache->ofnode, in cacheinfo_create_index_opt_attrs()
771 attr->attr.name, cache->ofnode, cache_type); in cacheinfo_create_index_opt_attrs()
777 static void cacheinfo_create_index_dir(struct cache *cache, int index, in cacheinfo_create_index_dir() argument
787 index_dir->cache = cache; in cacheinfo_create_index_dir()
803 struct cache *cache_list) in cacheinfo_sysfs_populate()
806 struct cache *cache; in cacheinfo_sysfs_populate() local
813 cache = cache_list; in cacheinfo_sysfs_populate()
814 while (cache) { in cacheinfo_sysfs_populate()
815 cacheinfo_create_index_dir(cache, index, cache_dir); in cacheinfo_sysfs_populate()
817 cache = cache->next_local; in cacheinfo_sysfs_populate()
823 struct cache *cache; in cacheinfo_cpu_online() local
825 cache = cache_chain_instantiate(cpu_id); in cacheinfo_cpu_online()
826 if (!cache) in cacheinfo_cpu_online()
829 cacheinfo_sysfs_populate(cpu_id, cache); in cacheinfo_cpu_online()
837 static struct cache *cache_lookup_by_cpu(unsigned int cpu_id) in cache_lookup_by_cpu()
840 struct cache *cache; in cache_lookup_by_cpu() local
847 cache = cache_lookup_by_node(cpu_node); in cache_lookup_by_cpu()
850 return cache; in cache_lookup_by_cpu()
880 static void cache_cpu_clear(struct cache *cache, int cpu) in cache_cpu_clear() argument
882 while (cache) { in cache_cpu_clear()
883 struct cache *next = cache->next_local; in cache_cpu_clear()
885 WARN_ONCE(!cpumask_test_cpu(cpu, &cache->shared_cpu_map), in cache_cpu_clear()
887 cpu, cache->ofnode, in cache_cpu_clear()
888 cache_type_string(cache)); in cache_cpu_clear()
890 cpumask_clear_cpu(cpu, &cache->shared_cpu_map); in cache_cpu_clear()
894 if (cpumask_empty(&cache->shared_cpu_map)) in cache_cpu_clear()
895 release_cache(cache); in cache_cpu_clear()
897 cache = next; in cache_cpu_clear()
904 struct cache *cache; in cacheinfo_cpu_offline() local
918 cache = cache_lookup_by_cpu(cpu_id); in cacheinfo_cpu_offline()
919 if (cache) in cacheinfo_cpu_offline()
920 cache_cpu_clear(cache, cpu_id); in cacheinfo_cpu_offline()