• Home
  • Raw
  • Download

Lines Matching refs:cache

43 	struct cache *cache;  member
117 struct cache { struct
123 struct cache *next_local; /* next cache of >= level */ argument
138 static const char *cache_type_string(const struct cache *cache) in cache_type_string() argument
140 return cache_type_info[cache->type].name; in cache_type_string()
143 static void cache_init(struct cache *cache, int type, int level, in cache_init() argument
146 cache->type = type; in cache_init()
147 cache->level = level; in cache_init()
148 cache->ofnode = of_node_get(ofnode); in cache_init()
149 INIT_LIST_HEAD(&cache->list); in cache_init()
150 list_add(&cache->list, &cache_list); in cache_init()
153 static struct cache *new_cache(int type, int level, struct device_node *ofnode) in new_cache()
155 struct cache *cache; in new_cache() local
157 cache = kzalloc(sizeof(*cache), GFP_KERNEL); in new_cache()
158 if (cache) in new_cache()
159 cache_init(cache, type, level, ofnode); in new_cache()
161 return cache; in new_cache()
164 static void release_cache_debugcheck(struct cache *cache) in release_cache_debugcheck() argument
166 struct cache *iter; in release_cache_debugcheck()
169 WARN_ONCE(iter->next_local == cache, in release_cache_debugcheck()
173 cache->ofnode->full_name, in release_cache_debugcheck()
174 cache_type_string(cache)); in release_cache_debugcheck()
177 static void release_cache(struct cache *cache) in release_cache() argument
179 if (!cache) in release_cache()
182 pr_debug("freeing L%d %s cache for %s\n", cache->level, in release_cache()
183 cache_type_string(cache), cache->ofnode->full_name); in release_cache()
185 release_cache_debugcheck(cache); in release_cache()
186 list_del(&cache->list); in release_cache()
187 of_node_put(cache->ofnode); in release_cache()
188 kfree(cache); in release_cache()
191 static void cache_cpu_set(struct cache *cache, int cpu) in cache_cpu_set() argument
193 struct cache *next = cache; in cache_cpu_set()
205 static int cache_size(const struct cache *cache, unsigned int *ret) in cache_size() argument
210 propname = cache_type_info[cache->type].size_prop; in cache_size()
212 cache_size = of_get_property(cache->ofnode, propname, NULL); in cache_size()
220 static int cache_size_kb(const struct cache *cache, unsigned int *ret) in cache_size_kb() argument
224 if (cache_size(cache, &size)) in cache_size_kb()
232 static int cache_get_line_size(const struct cache *cache, unsigned int *ret) in cache_get_line_size() argument
237 lim = ARRAY_SIZE(cache_type_info[cache->type].line_size_props); in cache_get_line_size()
242 propname = cache_type_info[cache->type].line_size_props[i]; in cache_get_line_size()
243 line_size = of_get_property(cache->ofnode, propname, NULL); in cache_get_line_size()
255 static int cache_nr_sets(const struct cache *cache, unsigned int *ret) in cache_nr_sets() argument
260 propname = cache_type_info[cache->type].nr_sets_prop; in cache_nr_sets()
262 nr_sets = of_get_property(cache->ofnode, propname, NULL); in cache_nr_sets()
270 static int cache_associativity(const struct cache *cache, unsigned int *ret) in cache_associativity() argument
276 if (cache_nr_sets(cache, &nr_sets)) in cache_associativity()
287 if (cache_get_line_size(cache, &line_size)) in cache_associativity()
289 if (cache_size(cache, &size)) in cache_associativity()
302 static struct cache *cache_find_first_sibling(struct cache *cache) in cache_find_first_sibling() argument
304 struct cache *iter; in cache_find_first_sibling()
306 if (cache->type == CACHE_TYPE_UNIFIED || in cache_find_first_sibling()
307 cache->type == CACHE_TYPE_UNIFIED_D) in cache_find_first_sibling()
308 return cache; in cache_find_first_sibling()
311 if (iter->ofnode == cache->ofnode && iter->next_local == cache) in cache_find_first_sibling()
314 return cache; in cache_find_first_sibling()
318 static struct cache *cache_lookup_by_node(const struct device_node *node) in cache_lookup_by_node()
320 struct cache *cache = NULL; in cache_lookup_by_node() local
321 struct cache *iter; in cache_lookup_by_node()
326 cache = cache_find_first_sibling(iter); in cache_lookup_by_node()
330 return cache; in cache_lookup_by_node()
356 static struct cache *cache_do_one_devnode_unified(struct device_node *node, int level) in cache_do_one_devnode_unified()
363 static struct cache *cache_do_one_devnode_split(struct device_node *node, in cache_do_one_devnode_split()
366 struct cache *dcache, *icache; in cache_do_one_devnode_split()
386 static struct cache *cache_do_one_devnode(struct device_node *node, int level) in cache_do_one_devnode()
388 struct cache *cache; in cache_do_one_devnode() local
391 cache = cache_do_one_devnode_unified(node, level); in cache_do_one_devnode()
393 cache = cache_do_one_devnode_split(node, level); in cache_do_one_devnode()
395 return cache; in cache_do_one_devnode()
398 static struct cache *cache_lookup_or_instantiate(struct device_node *node, in cache_lookup_or_instantiate()
401 struct cache *cache; in cache_lookup_or_instantiate() local
403 cache = cache_lookup_by_node(node); in cache_lookup_or_instantiate()
405 WARN_ONCE(cache && cache->level != level, in cache_lookup_or_instantiate()
407 cache->level, level); in cache_lookup_or_instantiate()
409 if (!cache) in cache_lookup_or_instantiate()
410 cache = cache_do_one_devnode(node, level); in cache_lookup_or_instantiate()
412 return cache; in cache_lookup_or_instantiate()
415 static void link_cache_lists(struct cache *smaller, struct cache *bigger) in link_cache_lists()
426 static void do_subsidiary_caches_debugcheck(struct cache *cache) in do_subsidiary_caches_debugcheck() argument
428 WARN_ON_ONCE(cache->level != 1); in do_subsidiary_caches_debugcheck()
429 WARN_ON_ONCE(strcmp(cache->ofnode->type, "cpu")); in do_subsidiary_caches_debugcheck()
432 static void do_subsidiary_caches(struct cache *cache) in do_subsidiary_caches() argument
435 int level = cache->level; in do_subsidiary_caches()
437 do_subsidiary_caches_debugcheck(cache); in do_subsidiary_caches()
439 while ((subcache_node = of_find_next_cache_node(cache->ofnode))) { in do_subsidiary_caches()
440 struct cache *subcache; in do_subsidiary_caches()
448 link_cache_lists(cache, subcache); in do_subsidiary_caches()
449 cache = subcache; in do_subsidiary_caches()
453 static struct cache *cache_chain_instantiate(unsigned int cpu_id) in cache_chain_instantiate()
456 struct cache *cpu_cache = NULL; in cache_chain_instantiate()
516 index->cache->level, cache_type_string(index->cache)); in cache_index_release()
530 static struct cache *index_kobj_to_cache(struct kobject *k) in index_kobj_to_cache()
536 return index->cache; in index_kobj_to_cache()
542 struct cache *cache; in size_show() local
544 cache = index_kobj_to_cache(k); in size_show()
546 if (cache_size_kb(cache, &size_kb)) in size_show()
559 struct cache *cache; in line_size_show() local
561 cache = index_kobj_to_cache(k); in line_size_show()
563 if (cache_get_line_size(cache, &line_size)) in line_size_show()
575 struct cache *cache; in nr_sets_show() local
577 cache = index_kobj_to_cache(k); in nr_sets_show()
579 if (cache_nr_sets(cache, &nr_sets)) in nr_sets_show()
591 struct cache *cache; in associativity_show() local
593 cache = index_kobj_to_cache(k); in associativity_show()
595 if (cache_associativity(cache, &associativity)) in associativity_show()
606 struct cache *cache; in type_show() local
608 cache = index_kobj_to_cache(k); in type_show()
610 return sprintf(buf, "%s\n", cache_type_string(cache)); in type_show()
619 struct cache *cache; in level_show() local
622 cache = index->cache; in level_show()
624 return sprintf(buf, "%d\n", cache->level); in level_show()
633 struct cache *cache; in shared_cpu_map_show() local
637 cache = index->cache; in shared_cpu_map_show()
640 cpumask_pr_args(&cache->shared_cpu_map)); in shared_cpu_map_show()
684 struct cache *cache; in cacheinfo_create_index_opt_attrs() local
692 cache = dir->cache; in cacheinfo_create_index_opt_attrs()
693 cache_name = cache->ofnode->full_name; in cacheinfo_create_index_opt_attrs()
694 cache_type = cache_type_string(cache); in cacheinfo_create_index_opt_attrs()
723 static void cacheinfo_create_index_dir(struct cache *cache, int index, in cacheinfo_create_index_dir() argument
733 index_dir->cache = cache; in cacheinfo_create_index_dir()
751 struct cache *cache_list) in cacheinfo_sysfs_populate()
754 struct cache *cache; in cacheinfo_sysfs_populate() local
761 cache = cache_list; in cacheinfo_sysfs_populate()
762 while (cache) { in cacheinfo_sysfs_populate()
763 cacheinfo_create_index_dir(cache, index, cache_dir); in cacheinfo_sysfs_populate()
765 cache = cache->next_local; in cacheinfo_sysfs_populate()
771 struct cache *cache; in cacheinfo_cpu_online() local
773 cache = cache_chain_instantiate(cpu_id); in cacheinfo_cpu_online()
774 if (!cache) in cacheinfo_cpu_online()
777 cacheinfo_sysfs_populate(cpu_id, cache); in cacheinfo_cpu_online()
785 static struct cache *cache_lookup_by_cpu(unsigned int cpu_id) in cache_lookup_by_cpu()
788 struct cache *cache; in cache_lookup_by_cpu() local
795 cache = cache_lookup_by_node(cpu_node); in cache_lookup_by_cpu()
798 return cache; in cache_lookup_by_cpu()
828 static void cache_cpu_clear(struct cache *cache, int cpu) in cache_cpu_clear() argument
830 while (cache) { in cache_cpu_clear()
831 struct cache *next = cache->next_local; in cache_cpu_clear()
833 WARN_ONCE(!cpumask_test_cpu(cpu, &cache->shared_cpu_map), in cache_cpu_clear()
835 cpu, cache->ofnode->full_name, in cache_cpu_clear()
836 cache_type_string(cache)); in cache_cpu_clear()
838 cpumask_clear_cpu(cpu, &cache->shared_cpu_map); in cache_cpu_clear()
842 if (cpumask_empty(&cache->shared_cpu_map)) in cache_cpu_clear()
843 release_cache(cache); in cache_cpu_clear()
845 cache = next; in cache_cpu_clear()
852 struct cache *cache; in cacheinfo_cpu_offline() local
866 cache = cache_lookup_by_cpu(cpu_id); in cacheinfo_cpu_offline()
867 if (cache) in cacheinfo_cpu_offline()
868 cache_cpu_clear(cache, cpu_id); in cacheinfo_cpu_offline()