.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2017 Linaro Ltd. <ard.biesheuvel@linaro.org> |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify it |
---|
5 | | - * under the terms of the GNU General Public License version 2 as published |
---|
6 | | - * by the Free Software Foundation. |
---|
7 | 4 | */ |
---|
8 | 5 | |
---|
9 | 6 | #ifndef __ASM_SIMD_H |
---|
.. | .. |
---|
15 | 12 | #include <linux/preempt.h> |
---|
16 | 13 | #include <linux/types.h> |
---|
17 | 14 | |
---|
18 | | -#ifdef CONFIG_KERNEL_MODE_NEON |
---|
| 15 | +DECLARE_PER_CPU(bool, fpsimd_context_busy); |
---|
19 | 16 | |
---|
20 | | -DECLARE_PER_CPU(bool, kernel_neon_busy); |
---|
| 17 | +#ifdef CONFIG_KERNEL_MODE_NEON |
---|
21 | 18 | |
---|
22 | 19 | /* |
---|
23 | 20 | * may_use_simd - whether it is allowable at this time to issue SIMD |
---|
.. | .. |
---|
29 | 26 | static __must_check inline bool may_use_simd(void) |
---|
30 | 27 | { |
---|
31 | 28 | /* |
---|
32 | | - * kernel_neon_busy is only set while preemption is disabled, |
---|
| 29 | + * We must make sure that the SVE has been initialized properly |
---|
| 30 | + * before using the SIMD in kernel. |
---|
| 31 | + * fpsimd_context_busy is only set while preemption is disabled, |
---|
33 | 32 | * and is clear whenever preemption is enabled. Since |
---|
34 | | - * this_cpu_read() is atomic w.r.t. preemption, kernel_neon_busy |
---|
| 33 | + * this_cpu_read() is atomic w.r.t. preemption, fpsimd_context_busy |
---|
35 | 34 | * cannot change under our feet -- if it's set we cannot be |
---|
36 | 35 | * migrated, and if it's clear we cannot be migrated to a CPU |
---|
37 | 36 | * where it is set. |
---|
38 | 37 | */ |
---|
39 | 38 | return !in_irq() && !irqs_disabled() && !in_nmi() && |
---|
40 | | - !this_cpu_read(kernel_neon_busy); |
---|
| 39 | + !this_cpu_read(fpsimd_context_busy); |
---|
41 | 40 | } |
---|
42 | 41 | |
---|
43 | 42 | #else /* ! CONFIG_KERNEL_MODE_NEON */ |
---|