.. | .. |
---|
3 | 3 | #define _LINUX_CACHEINFO_H |
---|
4 | 4 | |
---|
5 | 5 | #include <linux/bitops.h> |
---|
| 6 | +#include <linux/cpu.h> |
---|
6 | 7 | #include <linux/cpumask.h> |
---|
7 | 8 | #include <linux/smp.h> |
---|
8 | 9 | |
---|
.. | .. |
---|
16 | 17 | CACHE_TYPE_SEPARATE = CACHE_TYPE_INST | CACHE_TYPE_DATA, |
---|
17 | 18 | CACHE_TYPE_UNIFIED = BIT(2), |
---|
18 | 19 | }; |
---|
| 20 | + |
---|
| 21 | +extern unsigned int coherency_max_size; |
---|
19 | 22 | |
---|
20 | 23 | /** |
---|
21 | 24 | * struct cacheinfo - represent a cache leaf node |
---|
.. | .. |
---|
99 | 102 | |
---|
100 | 103 | const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf); |
---|
101 | 104 | |
---|
| 105 | +/* |
---|
| 106 | + * Get the id of the cache associated with @cpu at level @level. |
---|
| 107 | + * cpuhp lock must be held. |
---|
| 108 | + */ |
---|
| 109 | +static inline int get_cpu_cacheinfo_id(int cpu, int level) |
---|
| 110 | +{ |
---|
| 111 | + struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu); |
---|
| 112 | + int i; |
---|
| 113 | + |
---|
| 114 | + for (i = 0; i < ci->num_leaves; i++) { |
---|
| 115 | + if (ci->info_list[i].level == level) { |
---|
| 116 | + if (ci->info_list[i].attributes & CACHE_ID) |
---|
| 117 | + return ci->info_list[i].id; |
---|
| 118 | + return -1; |
---|
| 119 | + } |
---|
| 120 | + } |
---|
| 121 | + |
---|
| 122 | + return -1; |
---|
| 123 | +} |
---|
| 124 | + |
---|
102 | 125 | #endif /* _LINUX_CACHEINFO_H */ |
---|