#ifndef _ASM_X86_FPU_API_H
#define _ASM_X86_FPU_API_H
+#include <linux/preempt.h>
/*
* Use kernel_fpu_begin/end() if you intend to use FPU in kernel context. It
extern void kernel_fpu_end(void);
extern bool irq_fpu_usable(void);
+static inline void fpregs_lock(void)
+{
+ preempt_disable();
+}
+
+static inline void fpregs_unlock(void)
+{
+ preempt_enable();
+}
+
/*
* Query the presence of one or more xfeatures. Works on any legacy CPU as well.
*
}
/*
+ * Internal helper, do not use directly. Use switch_fpu_return() instead.
+ */
+static inline void __fpregs_load_activate(struct fpu *fpu, int cpu)
+{
+ if (!fpregs_state_valid(fpu, cpu)) {
+ if (current->mm)
+ copy_kernel_to_fpregs(&fpu->state);
+ fpregs_activate(fpu);
+ }
+}
+
+/*
* FPU state switching for scheduling.
*
* This is a two-stage process:
*/
static inline void switch_fpu_finish(struct fpu *new_fpu, int cpu)
{
- if (static_cpu_has(X86_FEATURE_FPU)) {
- if (!fpregs_state_valid(new_fpu, cpu)) {
- if (current->mm)
- copy_kernel_to_fpregs(&new_fpu->state);
- }
-
- fpregs_activate(new_fpu);
- }
+ if (static_cpu_has(X86_FEATURE_FPU))
+ __fpregs_load_activate(new_fpu, cpu);
}
/*