Lines Matching +full:cache +full:- +full:unified
1 // SPDX-License-Identifier: GPL-2.0
3 * cacheinfo support - processor cache information via sysfs
26 #define cache_leaves(cpu) (ci_cacheinfo(cpu)->num_leaves)
27 #define per_cpu_cacheinfo(cpu) (ci_cacheinfo(cpu)->info_list)
38 return sib_leaf->fw_token == this_leaf->fw_token; in cache_leaves_are_shared()
41 /* OF properties to query for a given cache type */
50 .size_prop = "cache-size",
51 .line_size_props = { "cache-line-size",
52 "cache-block-size", },
53 .nr_sets_prop = "cache-sets",
55 .size_prop = "i-cache-size",
56 .line_size_props = { "i-cache-line-size",
57 "i-cache-block-size", },
58 .nr_sets_prop = "i-cache-sets",
60 .size_prop = "d-cache-size",
61 .line_size_props = { "d-cache-line-size",
62 "d-cache-block-size", },
63 .nr_sets_prop = "d-cache-sets",
79 ct_idx = get_cacheinfo_idx(this_leaf->type); in cache_size()
82 of_property_read_u32(np, propname, &this_leaf->size); in cache_size()
85 /* not cache_line_size() because that's a macro in include/linux/cache.h */
91 ct_idx = get_cacheinfo_idx(this_leaf->type); in cache_get_line_size()
102 this_leaf->coherency_line_size = line_size; in cache_get_line_size()
113 ct_idx = get_cacheinfo_idx(this_leaf->type); in cache_nr_sets()
116 of_property_read_u32(np, propname, &this_leaf->number_of_sets); in cache_nr_sets()
121 unsigned int line_size = this_leaf->coherency_line_size; in cache_associativity()
122 unsigned int nr_sets = this_leaf->number_of_sets; in cache_associativity()
123 unsigned int size = this_leaf->size; in cache_associativity()
126 * If the cache is fully associative, there is no need to in cache_associativity()
130 this_leaf->ways_of_associativity = (size / nr_sets) / line_size; in cache_associativity()
136 return of_property_read_bool(np, "cache-unified"); in cache_node_is_unified()
143 * init_cache_level must setup the cache level correctly in cache_of_set_props()
145 * if type is NONE at this stage, it should be unified in cache_of_set_props()
147 if (this_leaf->type == CACHE_TYPE_NOCACHE && in cache_of_set_props()
149 this_leaf->type = CACHE_TYPE_UNIFIED; in cache_of_set_props()
165 if (this_cpu_ci->info_list->fw_token) { in cache_setup_of_node()
171 return -ENODEV; in cache_setup_of_node()
173 np = cpu_dev->of_node; in cache_setup_of_node()
176 return -ENOENT; in cache_setup_of_node()
180 this_leaf = this_cpu_ci->info_list + index; in cache_setup_of_node()
181 if (this_leaf->level != 1) in cache_setup_of_node()
188 this_leaf->fw_token = np; in cache_setup_of_node()
193 return -ENOENT; in cache_setup_of_node()
203 * For non-DT/ACPI systems, assume unique level 1 caches, system-wide in cache_leaves_are_shared()
207 return !(this_leaf->level == 1); in cache_leaves_are_shared()
213 return -ENOTSUPP; in cache_setup_acpi()
225 if (this_cpu_ci->cpu_map_populated) in cache_shared_cpu_map_setup()
239 this_leaf = this_cpu_ci->info_list + index; in cache_shared_cpu_map_setup()
241 if (!cpumask_empty(&this_leaf->shared_cpu_map)) in cache_shared_cpu_map_setup()
244 cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map); in cache_shared_cpu_map_setup()
248 if (i == cpu || !sib_cpu_ci->info_list) in cache_shared_cpu_map_setup()
250 sib_leaf = sib_cpu_ci->info_list + index; in cache_shared_cpu_map_setup()
252 cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map); in cache_shared_cpu_map_setup()
253 cpumask_set_cpu(i, &this_leaf->shared_cpu_map); in cache_shared_cpu_map_setup()
256 /* record the maximum cache line size */ in cache_shared_cpu_map_setup()
257 if (this_leaf->coherency_line_size > coherency_max_size) in cache_shared_cpu_map_setup()
258 coherency_max_size = this_leaf->coherency_line_size; in cache_shared_cpu_map_setup()
271 this_leaf = this_cpu_ci->info_list + index; in cache_shared_cpu_map_remove()
272 for_each_cpu(sibling, &this_leaf->shared_cpu_map) { in cache_shared_cpu_map_remove()
279 if (!sib_cpu_ci->info_list) in cache_shared_cpu_map_remove()
282 sib_leaf = sib_cpu_ci->info_list + index; in cache_shared_cpu_map_remove()
283 cpumask_clear_cpu(cpu, &sib_leaf->shared_cpu_map); in cache_shared_cpu_map_remove()
284 cpumask_clear_cpu(sibling, &this_leaf->shared_cpu_map); in cache_shared_cpu_map_remove()
287 of_node_put(this_leaf->fw_token); in cache_shared_cpu_map_remove()
305 return -ENOENT; in init_cache_level()
310 return -ENOENT; in populate_cache_leaves()
318 return -ENOENT; in detect_cache_attributes()
323 return -ENOMEM; in detect_cache_attributes()
326 * populate_cache_leaves() may completely setup the cache leaves and in detect_cache_attributes()
333 * For systems using DT for cache hierarchy, fw_token in detect_cache_attributes()
339 pr_warn("Unable to detect cache hierarchy for CPU %d\n", cpu); in detect_cache_attributes()
350 /* pointer to cpuX/cache device */
356 /* pointer to array of devices for cpuX/cache/indexY */
366 return sysfs_emit(buf, "%u\n", this_leaf->object); \
381 return sysfs_emit(buf, "%uK\n", this_leaf->size >> 10); in size_show()
388 const struct cpumask *mask = &this_leaf->shared_cpu_map; in shared_cpu_map_show()
397 const struct cpumask *mask = &this_leaf->shared_cpu_map; in shared_cpu_list_show()
408 switch (this_leaf->type) { in type_show()
416 output = "Unified"; in type_show()
419 return -EINVAL; in type_show()
429 unsigned int ci_attr = this_leaf->attributes; in allocation_policy_show()
448 unsigned int ci_attr = this_leaf->attributes; in write_policy_show()
493 const struct cpumask *mask = &this_leaf->shared_cpu_map; in cache_default_attrs_is_visible()
494 umode_t mode = attr->mode; in cache_default_attrs_is_visible()
496 if ((attr == &dev_attr_id.attr) && (this_leaf->attributes & CACHE_ID)) in cache_default_attrs_is_visible()
498 if ((attr == &dev_attr_type.attr) && this_leaf->type) in cache_default_attrs_is_visible()
500 if ((attr == &dev_attr_level.attr) && this_leaf->level) in cache_default_attrs_is_visible()
507 this_leaf->coherency_line_size) in cache_default_attrs_is_visible()
510 this_leaf->size) /* allow 0 = full associativity */ in cache_default_attrs_is_visible()
513 this_leaf->number_of_sets) in cache_default_attrs_is_visible()
515 if ((attr == &dev_attr_size.attr) && this_leaf->size) in cache_default_attrs_is_visible()
518 (this_leaf->attributes & CACHE_WRITE_POLICY_MASK)) in cache_default_attrs_is_visible()
521 (this_leaf->attributes & CACHE_ALLOCATE_POLICY_MASK)) in cache_default_attrs_is_visible()
524 this_leaf->physical_line_partition) in cache_default_attrs_is_visible()
567 /* Add/Remove cache interface for CPU device */
592 return -ENOENT; in cpu_cache_sysfs_init()
594 per_cpu_cache_dev(cpu) = cpu_device_create(dev, NULL, NULL, "cache"); in cpu_cache_sysfs_init()
608 return -ENOMEM; in cpu_cache_sysfs_init()
626 this_leaf = this_cpu_ci->info_list + i; in cache_add_dev()
627 if (this_leaf->disable_sysfs) in cache_add_dev()
629 if (this_leaf->type == CACHE_TYPE_NOCACHE) in cache_add_dev()