mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
drm/amd/display: Add control mechanism for FPU utilization
DC invokes DC_FPU_START/END in multiple parts of the code; this can create a situation where we invoke this FPU operation in a nested way or exit too early. For avoiding this situation, this commit adds a mechanism where dc_fpu_begin/end manages the access to kernel_fpu_begin/end. Change since V3: - Rebase Change since V2: - Christian: Do not use this_cpu_* between get/put_cpu_ptr(). Change since V1: - Use a better variable names - Use get_cpu_ptr and put_cpu_ptr to better balance preemption enable and disable Cc: Harry Wentland <harry.wentland@amd.com> Cc: Anson Jacob <Anson.Jacob@amd.com> Cc: Christian König <christian.koenig@amd.com> Cc: Hersen Wu <hersenxs.wu@amd.com> Cc: Aric Cyr <aric.cyr@amd.com> Cc: Jun Lei <jun.lei@amd.com> Cc: Dmytro Laktyushkin <dmytro.laktyushkin@amd.com> Cc: Qingqing Zhuo <qingqing.zhuo@amd.com> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
96ee63730f
commit
2d8471dc37
@@ -33,6 +33,19 @@
|
||||
#include <asm/cputable.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* DOC: DC FPU manipulation overview
|
||||
*
|
||||
* DC core uses FPU operations in multiple parts of the code, which requires a
|
||||
* more specialized way to manage these areas' entrance. To fulfill this
|
||||
* requirement, we created some wrapper functions that encapsulate
|
||||
* kernel_fpu_begin/end to better fit our need in the display component. In
|
||||
* summary, in this file, you can find functions related to FPU operation
|
||||
* management.
|
||||
*/
|
||||
|
||||
static DEFINE_PER_CPU(int, fpu_recursion_depth);
|
||||
|
||||
/**
|
||||
* dc_fpu_begin - Enables FPU protection
|
||||
* @function_name: A string containing the function name for debug purposes
|
||||
@@ -48,22 +61,30 @@
|
||||
*/
|
||||
void dc_fpu_begin(const char *function_name, const int line)
|
||||
{
|
||||
TRACE_DCN_FPU(true, function_name, line);
|
||||
int *pcpu;
|
||||
|
||||
pcpu = get_cpu_ptr(&fpu_recursion_depth);
|
||||
*pcpu += 1;
|
||||
|
||||
if (*pcpu == 1) {
|
||||
#if defined(CONFIG_X86)
|
||||
kernel_fpu_begin();
|
||||
kernel_fpu_begin();
|
||||
#elif defined(CONFIG_PPC64)
|
||||
if (cpu_has_feature(CPU_FTR_VSX_COMP)) {
|
||||
preempt_disable();
|
||||
enable_kernel_vsx();
|
||||
} else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) {
|
||||
preempt_disable();
|
||||
enable_kernel_altivec();
|
||||
} else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) {
|
||||
preempt_disable();
|
||||
enable_kernel_fp();
|
||||
}
|
||||
if (cpu_has_feature(CPU_FTR_VSX_COMP)) {
|
||||
preempt_disable();
|
||||
enable_kernel_vsx();
|
||||
} else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) {
|
||||
preempt_disable();
|
||||
enable_kernel_altivec();
|
||||
} else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) {
|
||||
preempt_disable();
|
||||
enable_kernel_fp();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TRACE_DCN_FPU(true, function_name, line, *pcpu);
|
||||
put_cpu_ptr(&fpu_recursion_depth);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,19 +99,27 @@ void dc_fpu_begin(const char *function_name, const int line)
|
||||
*/
|
||||
void dc_fpu_end(const char *function_name, const int line)
|
||||
{
|
||||
TRACE_DCN_FPU(false, function_name, line);
|
||||
int *pcpu;
|
||||
|
||||
pcpu = get_cpu_ptr(&fpu_recursion_depth);
|
||||
*pcpu -= 1;
|
||||
if (*pcpu <= 0) {
|
||||
#if defined(CONFIG_X86)
|
||||
kernel_fpu_end();
|
||||
kernel_fpu_end();
|
||||
#elif defined(CONFIG_PPC64)
|
||||
if (cpu_has_feature(CPU_FTR_VSX_COMP)) {
|
||||
disable_kernel_vsx();
|
||||
preempt_enable();
|
||||
} else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) {
|
||||
disable_kernel_altivec();
|
||||
preempt_enable();
|
||||
} else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) {
|
||||
disable_kernel_fp();
|
||||
preempt_enable();
|
||||
}
|
||||
if (cpu_has_feature(CPU_FTR_VSX_COMP)) {
|
||||
disable_kernel_vsx();
|
||||
preempt_enable();
|
||||
} else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) {
|
||||
disable_kernel_altivec();
|
||||
preempt_enable();
|
||||
} else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) {
|
||||
disable_kernel_fp();
|
||||
preempt_enable();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TRACE_DCN_FPU(false, function_name, line, *pcpu);
|
||||
put_cpu_ptr(&fpu_recursion_depth);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user