.. | .. |
---|
180 | 180 | */ |
---|
181 | 181 | static void get_cpu_fpsimd_context(void) |
---|
182 | 182 | { |
---|
183 | | - if (!IS_ENABLED(CONFIG_PREEMPT_RT)) |
---|
184 | | - local_bh_disable(); |
---|
185 | | - else |
---|
186 | | - preempt_disable(); |
---|
| 183 | + local_bh_disable(); |
---|
187 | 184 | __get_cpu_fpsimd_context(); |
---|
188 | 185 | } |
---|
189 | 186 | |
---|
.. | .. |
---|
204 | 201 | static void put_cpu_fpsimd_context(void) |
---|
205 | 202 | { |
---|
206 | 203 | __put_cpu_fpsimd_context(); |
---|
207 | | - if (!IS_ENABLED(CONFIG_PREEMPT_RT)) |
---|
208 | | - local_bh_enable(); |
---|
209 | | - else |
---|
210 | | - preempt_enable(); |
---|
| 204 | + local_bh_enable(); |
---|
211 | 205 | } |
---|
212 | 206 | |
---|
213 | 207 | static bool have_cpu_fpsimd_context(void) |
---|
.. | .. |
---|
215 | 209 | return !preemptible() && __this_cpu_read(fpsimd_context_busy); |
---|
216 | 210 | } |
---|
217 | 211 | |
---|
218 | | -static void *sve_free_atomic(struct task_struct *task) |
---|
| 212 | +/* |
---|
| 213 | + * Call __sve_free() directly only if you know task can't be scheduled |
---|
| 214 | + * or preempted. |
---|
| 215 | + */ |
---|
| 216 | +static void __sve_free(struct task_struct *task) |
---|
219 | 217 | { |
---|
220 | | - void *sve_state = task->thread.sve_state; |
---|
| 218 | + kfree(task->thread.sve_state); |
---|
| 219 | + task->thread.sve_state = NULL; |
---|
| 220 | +} |
---|
221 | 221 | |
---|
| 222 | +static void sve_free(struct task_struct *task) |
---|
| 223 | +{ |
---|
222 | 224 | WARN_ON(test_tsk_thread_flag(task, TIF_SVE)); |
---|
223 | 225 | |
---|
224 | | - task->thread.sve_state = NULL; |
---|
225 | | - return sve_state; |
---|
| 226 | + __sve_free(task); |
---|
226 | 227 | } |
---|
227 | 228 | |
---|
228 | 229 | /* |
---|
.. | .. |
---|
583 | 584 | int sve_set_vector_length(struct task_struct *task, |
---|
584 | 585 | unsigned long vl, unsigned long flags) |
---|
585 | 586 | { |
---|
586 | | - void *mem = NULL; |
---|
587 | 587 | if (flags & ~(unsigned long)(PR_SVE_VL_INHERIT | |
---|
588 | 588 | PR_SVE_SET_VL_ONEXEC)) |
---|
589 | 589 | return -EINVAL; |
---|
.. | .. |
---|
637 | 637 | * Force reallocation of task SVE state to the correct size |
---|
638 | 638 | * on next use: |
---|
639 | 639 | */ |
---|
640 | | - mem = sve_free_atomic(task); |
---|
| 640 | + sve_free(task); |
---|
641 | 641 | |
---|
642 | 642 | task->thread.sve_vl = vl; |
---|
643 | | - kfree(mem); |
---|
644 | 643 | |
---|
645 | 644 | out: |
---|
646 | 645 | update_tsk_thread_flag(task, TIF_SVE_VL_INHERIT, |
---|
.. | .. |
---|
918 | 917 | */ |
---|
919 | 918 | void fpsimd_release_task(struct task_struct *dead_task) |
---|
920 | 919 | { |
---|
921 | | - void *mem = NULL; |
---|
922 | | - mem = sve_free_atomic(dead_task); |
---|
923 | | - kfree(mem); |
---|
| 920 | + __sve_free(dead_task); |
---|
924 | 921 | } |
---|
925 | 922 | |
---|
926 | 923 | #endif /* CONFIG_ARM64_SVE */ |
---|
.. | .. |
---|
1025 | 1022 | void fpsimd_flush_thread(void) |
---|
1026 | 1023 | { |
---|
1027 | 1024 | int vl, supported_vl; |
---|
1028 | | - void *mem = NULL; |
---|
1029 | 1025 | |
---|
1030 | 1026 | if (!system_supports_fpsimd()) |
---|
1031 | 1027 | return; |
---|
.. | .. |
---|
1038 | 1034 | |
---|
1039 | 1035 | if (system_supports_sve()) { |
---|
1040 | 1036 | clear_thread_flag(TIF_SVE); |
---|
1041 | | - mem = sve_free_atomic(current); |
---|
| 1037 | + sve_free(current); |
---|
1042 | 1038 | |
---|
1043 | 1039 | /* |
---|
1044 | 1040 | * Reset the task vector length as required. |
---|
.. | .. |
---|
1072 | 1068 | } |
---|
1073 | 1069 | |
---|
1074 | 1070 | put_cpu_fpsimd_context(); |
---|
1075 | | - kfree(mem); |
---|
1076 | 1071 | } |
---|
1077 | 1072 | |
---|
1078 | 1073 | /* |
---|