提交 8884b7bd 编写于 作者: D Dave Martin 提交者: Will Deacon

arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu.

There is currently some duplicate logic to associate current's
FPSIMD context with the cpu when loading FPSIMD state into the cpu
regs.

Subsequent patches will update that logic, so in order to ensure it
only needs to be done in one place, this patch factors the relevant
code out into a new function fpsimd_bind_to_cpu().
Signed-off-by: NDave Martin <Dave.Martin@arm.com>
Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: NWill Deacon <will.deacon@arm.com>
上级 071b6d4a
...@@ -991,6 +991,18 @@ void fpsimd_signal_preserve_current_state(void) ...@@ -991,6 +991,18 @@ void fpsimd_signal_preserve_current_state(void)
sve_to_fpsimd(current); sve_to_fpsimd(current);
} }
/*
* Associate current's FPSIMD context with this cpu
* Preemption must be disabled when calling this function.
*/
static void fpsimd_bind_to_cpu(void)
{
struct fpsimd_state *st = &current->thread.fpsimd_state;
__this_cpu_write(fpsimd_last_state, st);
st->cpu = smp_processor_id();
}
/* /*
* Load the userland FPSIMD state of 'current' from memory, but only if the * Load the userland FPSIMD state of 'current' from memory, but only if the
* FPSIMD state already held in the registers is /not/ the most recent FPSIMD * FPSIMD state already held in the registers is /not/ the most recent FPSIMD
...@@ -1004,11 +1016,8 @@ void fpsimd_restore_current_state(void) ...@@ -1004,11 +1016,8 @@ void fpsimd_restore_current_state(void)
local_bh_disable(); local_bh_disable();
if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) { if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
struct fpsimd_state *st = &current->thread.fpsimd_state;
task_fpsimd_load(); task_fpsimd_load();
__this_cpu_write(fpsimd_last_state, st); fpsimd_bind_to_cpu();
st->cpu = smp_processor_id();
} }
local_bh_enable(); local_bh_enable();
...@@ -1032,12 +1041,8 @@ void fpsimd_update_current_state(struct fpsimd_state *state) ...@@ -1032,12 +1041,8 @@ void fpsimd_update_current_state(struct fpsimd_state *state)
task_fpsimd_load(); task_fpsimd_load();
if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) { if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE))
struct fpsimd_state *st = &current->thread.fpsimd_state; fpsimd_bind_to_cpu();
__this_cpu_write(fpsimd_last_state, st);
st->cpu = smp_processor_id();
}
local_bh_enable(); local_bh_enable();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册