diff options
-rw-r--r-- | arch/arm64/Kconfig | 3 | ||||
-rw-r--r-- | arch/arm64/include/asm/neon.h | 14 | ||||
-rw-r--r-- | arch/arm64/kernel/fpsimd.c | 28 |
3 files changed, 45 insertions, 0 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 9737e97f9f38..ae323a45c28c 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig | |||
@@ -96,6 +96,9 @@ config SWIOTLB | |||
96 | config IOMMU_HELPER | 96 | config IOMMU_HELPER |
97 | def_bool SWIOTLB | 97 | def_bool SWIOTLB |
98 | 98 | ||
99 | config KERNEL_MODE_NEON | ||
100 | def_bool y | ||
101 | |||
99 | source "init/Kconfig" | 102 | source "init/Kconfig" |
100 | 103 | ||
101 | source "kernel/Kconfig.freezer" | 104 | source "kernel/Kconfig.freezer" |
diff --git a/arch/arm64/include/asm/neon.h b/arch/arm64/include/asm/neon.h new file mode 100644 index 000000000000..b0cc58a97780 --- /dev/null +++ b/arch/arm64/include/asm/neon.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * linux/arch/arm64/include/asm/neon.h | ||
3 | * | ||
4 | * Copyright (C) 2013 Linaro Ltd <ard.biesheuvel@linaro.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #define cpu_has_neon() (1) | ||
12 | |||
13 | void kernel_neon_begin(void); | ||
14 | void kernel_neon_end(void); | ||
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index e8b8357aedb4..1f2e4d5a5c0f 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
23 | #include <linux/signal.h> | 23 | #include <linux/signal.h> |
24 | #include <linux/hardirq.h> | ||
24 | 25 | ||
25 | #include <asm/fpsimd.h> | 26 | #include <asm/fpsimd.h> |
26 | #include <asm/cputype.h> | 27 | #include <asm/cputype.h> |
@@ -83,6 +84,33 @@ void fpsimd_flush_thread(void) | |||
83 | fpsimd_load_state(¤t->thread.fpsimd_state); | 84 | fpsimd_load_state(¤t->thread.fpsimd_state); |
84 | } | 85 | } |
85 | 86 | ||
87 | #ifdef CONFIG_KERNEL_MODE_NEON | ||
88 | |||
89 | /* | ||
90 | * Kernel-side NEON support functions | ||
91 | */ | ||
92 | void kernel_neon_begin(void) | ||
93 | { | ||
94 | /* Avoid using the NEON in interrupt context */ | ||
95 | BUG_ON(in_interrupt()); | ||
96 | preempt_disable(); | ||
97 | |||
98 | if (current->mm) | ||
99 | fpsimd_save_state(¤t->thread.fpsimd_state); | ||
100 | } | ||
101 | EXPORT_SYMBOL(kernel_neon_begin); | ||
102 | |||
103 | void kernel_neon_end(void) | ||
104 | { | ||
105 | if (current->mm) | ||
106 | fpsimd_load_state(¤t->thread.fpsimd_state); | ||
107 | |||
108 | preempt_enable(); | ||
109 | } | ||
110 | EXPORT_SYMBOL(kernel_neon_end); | ||
111 | |||
112 | #endif /* CONFIG_KERNEL_MODE_NEON */ | ||
113 | |||
86 | /* | 114 | /* |
87 | * FP/SIMD support code initialisation. | 115 | * FP/SIMD support code initialisation. |
88 | */ | 116 | */ |