Lines Matching refs:cpu

33 #define ci_cacheinfo(cpu)	(&per_cpu(ci_cpu_cacheinfo, cpu))  argument
34 #define cache_leaves(cpu) (ci_cacheinfo(cpu)->num_leaves) argument
35 #define per_cpu_cacheinfo(cpu) (ci_cacheinfo(cpu)->info_list) argument
37 struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu) in get_cpu_cacheinfo() argument
39 return ci_cacheinfo(cpu); in get_cpu_cacheinfo()
43 static int cache_setup_of_node(unsigned int cpu) in cache_setup_of_node() argument
47 struct device *cpu_dev = get_cpu_device(cpu); in cache_setup_of_node()
48 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); in cache_setup_of_node()
56 pr_err("No cpu device for CPU %d\n", cpu); in cache_setup_of_node()
61 pr_err("Failed to find cpu%d device node\n", cpu); in cache_setup_of_node()
65 while (index < cache_leaves(cpu)) { in cache_setup_of_node()
77 if (index != cache_leaves(cpu)) /* not all OF nodes populated */ in cache_setup_of_node()
89 static inline int cache_setup_of_node(unsigned int cpu) { return 0; } in cache_setup_of_node() argument
102 static int cache_shared_cpu_map_setup(unsigned int cpu) in cache_shared_cpu_map_setup() argument
104 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); in cache_shared_cpu_map_setup()
109 ret = cache_setup_of_node(cpu); in cache_shared_cpu_map_setup()
113 for (index = 0; index < cache_leaves(cpu); index++) { in cache_shared_cpu_map_setup()
121 cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map); in cache_shared_cpu_map_setup()
125 if (i == cpu || !sib_cpu_ci->info_list) in cache_shared_cpu_map_setup()
129 cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map); in cache_shared_cpu_map_setup()
138 static void cache_shared_cpu_map_remove(unsigned int cpu) in cache_shared_cpu_map_remove() argument
140 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); in cache_shared_cpu_map_remove()
144 for (index = 0; index < cache_leaves(cpu); index++) { in cache_shared_cpu_map_remove()
149 if (sibling == cpu) /* skip itself */ in cache_shared_cpu_map_remove()
157 cpumask_clear_cpu(cpu, &sib_leaf->shared_cpu_map); in cache_shared_cpu_map_remove()
164 static void free_cache_attributes(unsigned int cpu) in free_cache_attributes() argument
166 if (!per_cpu_cacheinfo(cpu)) in free_cache_attributes()
169 cache_shared_cpu_map_remove(cpu); in free_cache_attributes()
171 kfree(per_cpu_cacheinfo(cpu)); in free_cache_attributes()
172 per_cpu_cacheinfo(cpu) = NULL; in free_cache_attributes()
175 int __weak init_cache_level(unsigned int cpu) in init_cache_level() argument
180 int __weak populate_cache_leaves(unsigned int cpu) in populate_cache_leaves() argument
185 static int detect_cache_attributes(unsigned int cpu) in detect_cache_attributes() argument
189 if (init_cache_level(cpu) || !cache_leaves(cpu)) in detect_cache_attributes()
192 per_cpu_cacheinfo(cpu) = kcalloc(cache_leaves(cpu), in detect_cache_attributes()
194 if (per_cpu_cacheinfo(cpu) == NULL) in detect_cache_attributes()
197 ret = populate_cache_leaves(cpu); in detect_cache_attributes()
204 ret = cache_shared_cpu_map_setup(cpu); in detect_cache_attributes()
207 cpu); in detect_cache_attributes()
213 free_cache_attributes(cpu); in detect_cache_attributes()
219 #define per_cpu_cache_dev(cpu) (per_cpu(ci_cache_dev, cpu)) argument
225 #define per_cpu_index_dev(cpu) (per_cpu(ci_index_dev, cpu)) argument
226 #define per_cache_index_dev(cpu, idx) ((per_cpu_index_dev(cpu))[idx]) argument
423 static void cpu_cache_sysfs_exit(unsigned int cpu) in cpu_cache_sysfs_exit() argument
428 if (per_cpu_index_dev(cpu)) { in cpu_cache_sysfs_exit()
429 for (i = 0; i < cache_leaves(cpu); i++) { in cpu_cache_sysfs_exit()
430 ci_dev = per_cache_index_dev(cpu, i); in cpu_cache_sysfs_exit()
435 kfree(per_cpu_index_dev(cpu)); in cpu_cache_sysfs_exit()
436 per_cpu_index_dev(cpu) = NULL; in cpu_cache_sysfs_exit()
438 device_unregister(per_cpu_cache_dev(cpu)); in cpu_cache_sysfs_exit()
439 per_cpu_cache_dev(cpu) = NULL; in cpu_cache_sysfs_exit()
442 static int cpu_cache_sysfs_init(unsigned int cpu) in cpu_cache_sysfs_init() argument
444 struct device *dev = get_cpu_device(cpu); in cpu_cache_sysfs_init()
446 if (per_cpu_cacheinfo(cpu) == NULL) in cpu_cache_sysfs_init()
449 per_cpu_cache_dev(cpu) = cpu_device_create(dev, NULL, NULL, "cache"); in cpu_cache_sysfs_init()
450 if (IS_ERR(per_cpu_cache_dev(cpu))) in cpu_cache_sysfs_init()
451 return PTR_ERR(per_cpu_cache_dev(cpu)); in cpu_cache_sysfs_init()
454 per_cpu_index_dev(cpu) = kcalloc(cache_leaves(cpu), in cpu_cache_sysfs_init()
456 if (unlikely(per_cpu_index_dev(cpu) == NULL)) in cpu_cache_sysfs_init()
462 cpu_cache_sysfs_exit(cpu); in cpu_cache_sysfs_init()
466 static int cache_add_dev(unsigned int cpu) in cache_add_dev() argument
472 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); in cache_add_dev()
475 rc = cpu_cache_sysfs_init(cpu); in cache_add_dev()
479 parent = per_cpu_cache_dev(cpu); in cache_add_dev()
480 for (i = 0; i < cache_leaves(cpu); i++) { in cache_add_dev()
491 per_cache_index_dev(cpu, i) = ci_dev; in cache_add_dev()
493 cpumask_set_cpu(cpu, &cache_dev_map); in cache_add_dev()
497 cpu_cache_sysfs_exit(cpu); in cache_add_dev()
501 static void cache_remove_dev(unsigned int cpu) in cache_remove_dev() argument
503 if (!cpumask_test_cpu(cpu, &cache_dev_map)) in cache_remove_dev()
505 cpumask_clear_cpu(cpu, &cache_dev_map); in cache_remove_dev()
507 cpu_cache_sysfs_exit(cpu); in cache_remove_dev()
513 unsigned int cpu = (unsigned long)hcpu; in cacheinfo_cpu_callback() local
518 rc = detect_cache_attributes(cpu); in cacheinfo_cpu_callback()
520 rc = cache_add_dev(cpu); in cacheinfo_cpu_callback()
523 cache_remove_dev(cpu); in cacheinfo_cpu_callback()
524 free_cache_attributes(cpu); in cacheinfo_cpu_callback()
532 int cpu, rc = 0; in cacheinfo_sysfs_init() local
536 for_each_online_cpu(cpu) { in cacheinfo_sysfs_init()
537 rc = detect_cache_attributes(cpu); in cacheinfo_sysfs_init()
540 rc = cache_add_dev(cpu); in cacheinfo_sysfs_init()
542 free_cache_attributes(cpu); in cacheinfo_sysfs_init()
543 pr_err("error populating cacheinfo..cpu%d\n", cpu); in cacheinfo_sysfs_init()