Lines Matching refs:cache
43 struct cache *cache; member
117 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 cache->group_id = group_id; in cache_init()
151 INIT_LIST_HEAD(&cache->list); in cache_init()
152 list_add(&cache->list, &cache_list); in cache_init()
155 static struct cache *new_cache(int type, int level, in new_cache()
158 struct cache *cache; in new_cache() local
160 cache = kzalloc(sizeof(*cache), GFP_KERNEL); in new_cache()
161 if (cache) in new_cache()
162 cache_init(cache, type, level, ofnode, group_id); in new_cache()
164 return cache; in new_cache()
167 static void release_cache_debugcheck(struct cache *cache) in release_cache_debugcheck() argument
169 struct cache *iter; in release_cache_debugcheck()
172 WARN_ONCE(iter->next_local == cache, in release_cache_debugcheck()
176 cache->ofnode, in release_cache_debugcheck()
177 cache_type_string(cache)); in release_cache_debugcheck()
180 static void release_cache(struct cache *cache) in release_cache() argument
182 if (!cache) in release_cache()
185 pr_debug("freeing L%d %s cache for %pOFP\n", cache->level, in release_cache()
186 cache_type_string(cache), cache->ofnode); in release_cache()
188 release_cache_debugcheck(cache); in release_cache()
189 list_del(&cache->list); in release_cache()
190 of_node_put(cache->ofnode); in release_cache()
191 kfree(cache); in release_cache()
194 static void cache_cpu_set(struct cache *cache, int cpu) in cache_cpu_set() argument
196 struct cache *next = cache; in cache_cpu_set()
208 static int cache_size(const struct cache *cache, unsigned int *ret) in cache_size() argument
213 propname = cache_type_info[cache->type].size_prop; in cache_size()
215 cache_size = of_get_property(cache->ofnode, propname, NULL); in cache_size()
223 static int cache_size_kb(const struct cache *cache, unsigned int *ret) in cache_size_kb() argument
227 if (cache_size(cache, &size)) in cache_size_kb()
235 static int cache_get_line_size(const struct cache *cache, unsigned int *ret) in cache_get_line_size() argument
240 lim = ARRAY_SIZE(cache_type_info[cache->type].line_size_props); in cache_get_line_size()
245 propname = cache_type_info[cache->type].line_size_props[i]; in cache_get_line_size()
246 line_size = of_get_property(cache->ofnode, propname, NULL); in cache_get_line_size()
258 static int cache_nr_sets(const struct cache *cache, unsigned int *ret) in cache_nr_sets() argument
263 propname = cache_type_info[cache->type].nr_sets_prop; in cache_nr_sets()
265 nr_sets = of_get_property(cache->ofnode, propname, NULL); in cache_nr_sets()
273 static int cache_associativity(const struct cache *cache, unsigned int *ret) in cache_associativity() argument
279 if (cache_nr_sets(cache, &nr_sets)) in cache_associativity()
290 if (cache_get_line_size(cache, &line_size)) in cache_associativity()
292 if (cache_size(cache, &size)) in cache_associativity()
305 static struct cache *cache_find_first_sibling(struct cache *cache) in cache_find_first_sibling() argument
307 struct cache *iter; in cache_find_first_sibling()
309 if (cache->type == CACHE_TYPE_UNIFIED || in cache_find_first_sibling()
310 cache->type == CACHE_TYPE_UNIFIED_D) in cache_find_first_sibling()
311 return cache; in cache_find_first_sibling()
314 if (iter->ofnode == cache->ofnode && in cache_find_first_sibling()
315 iter->group_id == cache->group_id && in cache_find_first_sibling()
316 iter->next_local == cache) in cache_find_first_sibling()
319 return cache; in cache_find_first_sibling()
323 static struct cache *cache_lookup_by_node_group(const struct device_node *node, in cache_lookup_by_node_group()
326 struct cache *cache = NULL; in cache_lookup_by_node_group() local
327 struct cache *iter; in cache_lookup_by_node_group()
333 cache = cache_find_first_sibling(iter); in cache_lookup_by_node_group()
337 return cache; in cache_lookup_by_node_group()
361 static struct cache *cache_do_one_devnode_unified(struct device_node *node, int group_id, in cache_do_one_devnode_unified()
369 static struct cache *cache_do_one_devnode_split(struct device_node *node, int group_id, in cache_do_one_devnode_split()
372 struct cache *dcache, *icache; in cache_do_one_devnode_split()
392 static struct cache *cache_do_one_devnode(struct device_node *node, int group_id, int level) in cache_do_one_devnode()
394 struct cache *cache; in cache_do_one_devnode() local
397 cache = cache_do_one_devnode_unified(node, group_id, level); in cache_do_one_devnode()
399 cache = cache_do_one_devnode_split(node, group_id, level); in cache_do_one_devnode()
401 return cache; in cache_do_one_devnode()
404 static struct cache *cache_lookup_or_instantiate(struct device_node *node, in cache_lookup_or_instantiate()
408 struct cache *cache; in cache_lookup_or_instantiate() local
410 cache = cache_lookup_by_node_group(node, group_id); in cache_lookup_or_instantiate()
412 WARN_ONCE(cache && cache->level != level, in cache_lookup_or_instantiate()
414 cache->level, level); in cache_lookup_or_instantiate()
416 if (!cache) in cache_lookup_or_instantiate()
417 cache = cache_do_one_devnode(node, group_id, level); in cache_lookup_or_instantiate()
419 return cache; in cache_lookup_or_instantiate()
422 static void link_cache_lists(struct cache *smaller, struct cache *bigger) in link_cache_lists()
442 static void do_subsidiary_caches_debugcheck(struct cache *cache) in do_subsidiary_caches_debugcheck() argument
444 WARN_ONCE(cache->level != 1, in do_subsidiary_caches_debugcheck()
446 "%pOFP instead of an L1\n", cache->level, in do_subsidiary_caches_debugcheck()
447 cache_type_string(cache), cache->ofnode); in do_subsidiary_caches_debugcheck()
448 WARN_ONCE(!of_node_is_type(cache->ofnode, "cpu"), in do_subsidiary_caches_debugcheck()
450 "instead of a cpu node\n", cache->ofnode, in do_subsidiary_caches_debugcheck()
451 of_node_get_device_type(cache->ofnode)); in do_subsidiary_caches_debugcheck()
477 static void do_subsidiary_caches(struct cache *cache, unsigned int cpu_id) in do_subsidiary_caches() argument
480 int level = cache->level; in do_subsidiary_caches()
482 do_subsidiary_caches_debugcheck(cache); in do_subsidiary_caches()
484 while ((subcache_node = of_find_next_cache_node(cache->ofnode))) { in do_subsidiary_caches()
485 struct cache *subcache; in do_subsidiary_caches()
495 link_cache_lists(cache, subcache); in do_subsidiary_caches()
496 cache = subcache; in do_subsidiary_caches()
500 static struct cache *cache_chain_instantiate(unsigned int cpu_id) in cache_chain_instantiate()
503 struct cache *cpu_cache = NULL; in cache_chain_instantiate()
566 index->cache->level, cache_type_string(index->cache)); in cache_index_release()
580 static struct cache *index_kobj_to_cache(struct kobject *k) in index_kobj_to_cache()
586 return index->cache; in index_kobj_to_cache()
592 struct cache *cache; in size_show() local
594 cache = index_kobj_to_cache(k); in size_show()
596 if (cache_size_kb(cache, &size_kb)) in size_show()
609 struct cache *cache; in line_size_show() local
611 cache = index_kobj_to_cache(k); in line_size_show()
613 if (cache_get_line_size(cache, &line_size)) in line_size_show()
625 struct cache *cache; in nr_sets_show() local
627 cache = index_kobj_to_cache(k); in nr_sets_show()
629 if (cache_nr_sets(cache, &nr_sets)) in nr_sets_show()
641 struct cache *cache; in associativity_show() local
643 cache = index_kobj_to_cache(k); in associativity_show()
645 if (cache_associativity(cache, &associativity)) in associativity_show()
656 struct cache *cache; in type_show() local
658 cache = index_kobj_to_cache(k); in type_show()
660 return sprintf(buf, "%s\n", cache_type_string(cache)); in type_show()
669 struct cache *cache; in level_show() local
672 cache = index->cache; in level_show()
674 return sprintf(buf, "%d\n", cache->level); in level_show()
684 struct cache *cache; in show_shared_cpumap() local
688 cache = index->cache; in show_shared_cpumap()
690 mask = &cache->shared_cpu_map; in show_shared_cpumap()
747 struct cache *cache; in cacheinfo_create_index_opt_attrs() local
755 cache = dir->cache; in cacheinfo_create_index_opt_attrs()
756 cache_type = cache_type_string(cache); in cacheinfo_create_index_opt_attrs()
773 attr->attr.name, cache->ofnode, in cacheinfo_create_index_opt_attrs()
779 attr->attr.name, cache->ofnode, cache_type); in cacheinfo_create_index_opt_attrs()
785 static void cacheinfo_create_index_dir(struct cache *cache, int index, in cacheinfo_create_index_dir() argument
795 index_dir->cache = cache; in cacheinfo_create_index_dir()
811 struct cache *cache_list) in cacheinfo_sysfs_populate()
814 struct cache *cache; in cacheinfo_sysfs_populate() local
821 cache = cache_list; in cacheinfo_sysfs_populate()
822 while (cache) { in cacheinfo_sysfs_populate()
823 cacheinfo_create_index_dir(cache, index, cache_dir); in cacheinfo_sysfs_populate()
825 cache = cache->next_local; in cacheinfo_sysfs_populate()
831 struct cache *cache; in cacheinfo_cpu_online() local
833 cache = cache_chain_instantiate(cpu_id); in cacheinfo_cpu_online()
834 if (!cache) in cacheinfo_cpu_online()
837 cacheinfo_sysfs_populate(cpu_id, cache); in cacheinfo_cpu_online()
845 static struct cache *cache_lookup_by_cpu(unsigned int cpu_id) in cache_lookup_by_cpu()
848 struct cache *cache; in cache_lookup_by_cpu() local
857 cache = cache_lookup_by_node_group(cpu_node, group_id); in cache_lookup_by_cpu()
860 return cache; in cache_lookup_by_cpu()
890 static void cache_cpu_clear(struct cache *cache, int cpu) in cache_cpu_clear() argument
892 while (cache) { in cache_cpu_clear()
893 struct cache *next = cache->next_local; in cache_cpu_clear()
895 WARN_ONCE(!cpumask_test_cpu(cpu, &cache->shared_cpu_map), in cache_cpu_clear()
897 cpu, cache->ofnode, in cache_cpu_clear()
898 cache_type_string(cache)); in cache_cpu_clear()
900 cpumask_clear_cpu(cpu, &cache->shared_cpu_map); in cache_cpu_clear()
904 if (cpumask_empty(&cache->shared_cpu_map)) in cache_cpu_clear()
905 release_cache(cache); in cache_cpu_clear()
907 cache = next; in cache_cpu_clear()
914 struct cache *cache; in cacheinfo_cpu_offline() local
928 cache = cache_lookup_by_cpu(cpu_id); in cacheinfo_cpu_offline()
929 if (cache) in cacheinfo_cpu_offline()
930 cache_cpu_clear(cache, cpu_id); in cacheinfo_cpu_offline()