| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ARM64 cacheinfo support |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2015 ARM Ltd. |
|---|
| 5 | 6 | * 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/>. |
|---|
| 18 | 7 | */ |
|---|
| 19 | 8 | |
|---|
| 20 | 9 | #include <linux/acpi.h> |
|---|
| .. | .. |
|---|
| 27 | 16 | #define CLIDR_CTYPE_MASK(level) (7 << CLIDR_CTYPE_SHIFT(level)) |
|---|
| 28 | 17 | #define CLIDR_CTYPE(clidr, level) \ |
|---|
| 29 | 18 | (((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); |
|---|
| 30 | 28 | |
|---|
| 31 | 29 | static inline enum cache_type get_cache_type(int level) |
|---|
| 32 | 30 | { |
|---|
| .. | .. |
|---|
| 47 | 45 | |
|---|
| 48 | 46 | int init_cache_level(unsigned int cpu) |
|---|
| 49 | 47 | { |
|---|
| 50 | | - unsigned int ctype, level, leaves, fw_level; |
|---|
| 48 | + unsigned int ctype, level, leaves; |
|---|
| 49 | + int fw_level; |
|---|
| 51 | 50 | struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); |
|---|
| 52 | 51 | |
|---|
| 53 | 52 | for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) { |
|---|
| .. | .. |
|---|
| 65 | 64 | else |
|---|
| 66 | 65 | fw_level = acpi_find_last_cache_level(cpu); |
|---|
| 67 | 66 | |
|---|
| 67 | + if (fw_level < 0) |
|---|
| 68 | + return fw_level; |
|---|
| 69 | + |
|---|
| 68 | 70 | if (level < fw_level) { |
|---|
| 69 | 71 | /* |
|---|
| 70 | 72 | * some external caches not specified in CLIDR_EL1 |
|---|