|
4 | 4 | *
|
5 | 5 | * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
|
6 | 6 | */
|
7 |
| -#include <asm/cpu-info.h> |
8 | 7 | #include <linux/cacheinfo.h>
|
| 8 | +#include <asm/bootinfo.h> |
| 9 | +#include <asm/cpu-info.h> |
9 | 10 |
|
10 | 11 | /* Populates leaf and increments to next leaf */
|
11 | 12 | #define populate_cache(cache, leaf, c_level, c_type) \
|
|
17 | 18 | leaf->ways_of_associativity = c->cache.ways; \
|
18 | 19 | leaf->size = c->cache.linesz * c->cache.sets * \
|
19 | 20 | c->cache.ways; \
|
| 21 | + if (leaf->level > 2) \ |
| 22 | + leaf->size *= nodes_per_package; \ |
20 | 23 | leaf++; \
|
21 | 24 | } while (0)
|
22 | 25 |
|
@@ -95,11 +98,15 @@ static void cache_cpumap_setup(unsigned int cpu)
|
95 | 98 |
|
96 | 99 | int populate_cache_leaves(unsigned int cpu)
|
97 | 100 | {
|
98 |
| - int level = 1; |
| 101 | + int level = 1, nodes_per_package = 1; |
99 | 102 | struct cpuinfo_loongarch *c = ¤t_cpu_data;
|
100 | 103 | struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
|
101 | 104 | struct cacheinfo *this_leaf = this_cpu_ci->info_list;
|
102 | 105 |
|
| 106 | + if (loongson_sysconf.nr_nodes > 1) |
| 107 | + nodes_per_package = loongson_sysconf.cores_per_package |
| 108 | + / loongson_sysconf.cores_per_node; |
| 109 | + |
103 | 110 | if (c->icache.waysize) {
|
104 | 111 | populate_cache(dcache, this_leaf, level, CACHE_TYPE_DATA);
|
105 | 112 | populate_cache(icache, this_leaf, level++, CACHE_TYPE_INST);
|
|
0 commit comments