forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/arch/arm64/kernel/cacheinfo.c
....@@ -1,20 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ARM64 cacheinfo support
34 *
45 * Copyright (C) 2015 ARM Ltd.
56 * All Rights Reserved
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12
- * kind, whether express or implied; without even the implied warranty
13
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
187 */
198
209 #include <linux/acpi.h>
....@@ -27,6 +16,15 @@
2716 #define CLIDR_CTYPE_MASK(level) (7 << CLIDR_CTYPE_SHIFT(level))
2817 #define CLIDR_CTYPE(clidr, level) \
2918 (((clidr) & CLIDR_CTYPE_MASK(level)) >> CLIDR_CTYPE_SHIFT(level))
19
+
20
+int cache_line_size(void)
21
+{
22
+ if (coherency_max_size != 0)
23
+ return coherency_max_size;
24
+
25
+ return cache_line_size_of_cpu();
26
+}
27
+EXPORT_SYMBOL_GPL(cache_line_size);
3028
3129 static inline enum cache_type get_cache_type(int level)
3230 {
....@@ -47,7 +45,8 @@
4745
4846 int init_cache_level(unsigned int cpu)
4947 {
50
- unsigned int ctype, level, leaves, fw_level;
48
+ unsigned int ctype, level, leaves;
49
+ int fw_level;
5150 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
5251
5352 for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) {
....@@ -65,6 +64,9 @@
6564 else
6665 fw_level = acpi_find_last_cache_level(cpu);
6766
67
+ if (fw_level < 0)
68
+ return fw_level;
69
+
6870 if (level < fw_level) {
6971 /*
7072 * some external caches not specified in CLIDR_EL1