hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/arm64/include/asm/simd.h
....@@ -1,9 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * 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.
74 */
85
96 #ifndef __ASM_SIMD_H
....@@ -15,9 +12,9 @@
1512 #include <linux/preempt.h>
1613 #include <linux/types.h>
1714
18
-#ifdef CONFIG_KERNEL_MODE_NEON
15
+DECLARE_PER_CPU(bool, fpsimd_context_busy);
1916
20
-DECLARE_PER_CPU(bool, kernel_neon_busy);
17
+#ifdef CONFIG_KERNEL_MODE_NEON
2118
2219 /*
2320 * may_use_simd - whether it is allowable at this time to issue SIMD
....@@ -29,15 +26,17 @@
2926 static __must_check inline bool may_use_simd(void)
3027 {
3128 /*
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,
3332 * 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
3534 * cannot change under our feet -- if it's set we cannot be
3635 * migrated, and if it's clear we cannot be migrated to a CPU
3736 * where it is set.
3837 */
3938 return !in_irq() && !irqs_disabled() && !in_nmi() &&
40
- !this_cpu_read(kernel_neon_busy);
39
+ !this_cpu_read(fpsimd_context_busy);
4140 }
4241
4342 #else /* ! CONFIG_KERNEL_MODE_NEON */