forked from Minki/linux
cb84d11e16
Support for kernel-mode NEON to be nested and/or used in hardirq context adds significant complexity, and the benefits may be marginal. In practice, kernel-mode NEON is not used in hardirq context, and is rarely used in softirq context (by certain mac80211 drivers). This patch implements an arm64 may_use_simd() function to allow clients to check whether kernel-mode NEON is usable in the current context, and simplifies kernel_neon_{begin,end}() to handle only saving of the task FPSIMD state (if any). Without nesting, there is no other state to save. The partial fpsimd save/restore functions become redundant as a result of these changes, so they are removed too. The save/restore model is changed to operate directly on task_struct without additional percpu storage. This simplifies the code and saves a bit of memory, but means that softirqs must now be disabled when manipulating the task fpsimd state from task context: correspondingly, preempt_{en,dis}sable() calls are upgraded to local_bh_{en,dis}able() as appropriate. fpsimd_thread_switch() already runs with hardirqs disabled and so is already protected from softirqs. These changes should make it easier to support kernel-mode NEON in the presence of the Scalable Vector extension in the future. Signed-off-by: Dave Martin <Dave.Martin@arm.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
77 lines
2.0 KiB
C
77 lines
2.0 KiB
C
/*
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef __ASM_FP_H
|
|
#define __ASM_FP_H
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
/*
|
|
* FP/SIMD storage area has:
|
|
* - FPSR and FPCR
|
|
* - 32 128-bit data registers
|
|
*
|
|
* Note that user_fpsimd forms a prefix of this structure, which is
|
|
* relied upon in the ptrace FP/SIMD accessors.
|
|
*/
|
|
struct fpsimd_state {
|
|
union {
|
|
struct user_fpsimd_state user_fpsimd;
|
|
struct {
|
|
__uint128_t vregs[32];
|
|
u32 fpsr;
|
|
u32 fpcr;
|
|
};
|
|
};
|
|
/* the id of the last cpu to have restored this state */
|
|
unsigned int cpu;
|
|
};
|
|
|
|
|
|
#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
|
|
/* Masks for extracting the FPSR and FPCR from the FPSCR */
|
|
#define VFP_FPSCR_STAT_MASK 0xf800009f
|
|
#define VFP_FPSCR_CTRL_MASK 0x07f79f00
|
|
/*
|
|
* The VFP state has 32x64-bit registers and a single 32-bit
|
|
* control/status register.
|
|
*/
|
|
#define VFP_STATE_SIZE ((32 * 8) + 4)
|
|
#endif
|
|
|
|
struct task_struct;
|
|
|
|
extern void fpsimd_save_state(struct fpsimd_state *state);
|
|
extern void fpsimd_load_state(struct fpsimd_state *state);
|
|
|
|
extern void fpsimd_thread_switch(struct task_struct *next);
|
|
extern void fpsimd_flush_thread(void);
|
|
|
|
extern void fpsimd_preserve_current_state(void);
|
|
extern void fpsimd_restore_current_state(void);
|
|
extern void fpsimd_update_current_state(struct fpsimd_state *state);
|
|
|
|
extern void fpsimd_flush_task_state(struct task_struct *target);
|
|
|
|
/* For use by EFI runtime services calls only */
|
|
extern void __efi_fpsimd_begin(void);
|
|
extern void __efi_fpsimd_end(void);
|
|
|
|
#endif
|
|
|
|
#endif
|