drm/amd/display: Base changes for isolating FPU operation in a single place
Subsystems (3)
cover drm/amd/display: Base changes for isolating FPU operation in a single place
Hi,
In the display core, we utilize floats and doubles units for calculating modesetting parameters. One side effect of our approach to use double-precision is the fact that we spread multiple FPU access across our driver, which means that we can accidentally clobber user space FPU state.
# Challenges
1. Keep in mind that this FPU code is ingrained in our display driver and performs several crucial tasks. Additionally, we already have multiple architectures available in the kernel and a large set of users; in other words, we prefer to avoid a radical approach that might break our user's system.
2. We share our display code with Windows; thus, we need to maintain the interoperability between these two systems.
3. We need a mechanism for identifying which function uses FPU registers; fortunately, Peter Zijlstra wrote a series a couple of months ago where he introduced an FPU check for objtool. I used the following command for identifying the potential FPU usage:
./tools/objtool/objtool check -Ffa "drivers/gpu/drm/amd/display/dc/ANY_FILE.o"
4. Since our code heavily relies on FPU and the fact that we spread kernel_fpu_begin/end across multiple functions, we can have some complex scenarios that will require code refactoring. However, we want to avoid complicated changes since this is a formula to introduce regressions; we want something that allows us to fix it in small, safe, and reliable steps.
# Our approach
For trying to solve this problem, we came up with the following strategy:
1. Keep in mind that we are using kernel_fpu_begin/end spread in various areas and sometimes across multiple functions. If we try to move some of the functions to an isolated place, we can generate a situation where we can call the FPU protection more than once, causing multiple warnings. We can deal with this problem by adding a thin management layer around the kernel_fpu_begin/end used inside the display.
2. We will need a trace mechanism for this FPU management inside our display code.
3. After we get the thin layer that manages FPU, we can start to move each function that uses FPU to the centralized place. Our DQE runs multiple tests in different ASICs every week; we can take advantage of this to ensure that our FPU patches work does not introduce any regression. The idea is to work on a specific part of the code every week (e.g., week 1: DCN2, week 1: DCN2.1, etc.).
4. Finally, after we can isolate the FPU operations in a single place, we can altogether remove the FPU flags from other files and eliminate an unnecessary code introduced to deal with this problem.
# This series
To maintain the interoperability between multiple OSes, we already have a define named DC_FP_START/END, which is a straightforward wrapper to kernel_fpu_begin/end in the Linux side. In this series, I decided to expand the scope of this DC_FP_* wrapper to trace FPU entrance and exit in the display code, but I also add a mechanism for managing the entrance and exit of kernel_fpu_begin/end. You can see the details on how I did that in the last two patches.
I also isolate a simple function that requires FPU access to demonstrate my strategy for isolating this FPU access in a single place. If this series gets accepted, the following steps consist of moving all FPU functions weekly until we isolate everything in the fpu_operation folder.
Best Regards
Rodrigo Siqueira
Rodrigo Siqueira (4):
drm/amd/display: Introduce FPU directory inside DC drm/amd/display: Add FPU event trace drm/amd/display: Add ref count control for FPU utilization drm/amd/display: Add DC_FP helper to check FPU state
.../gpu/drm/amd/display/amdgpu_dm/Makefile | 3 +- .../amd/display/amdgpu_dm/amdgpu_dm_trace.h | 24 ++++ .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 111 ++++++++++++++++++ .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.h | 34 ++++++ drivers/gpu/drm/amd/display/dc/Makefile | 1 + drivers/gpu/drm/amd/display/dc/dc_trace.h | 3 + .../drm/amd/display/dc/dcn20/dcn20_resource.c | 41 +------ .../drm/amd/display/dc/dcn20/dcn20_resource.h | 2 - .../drm/amd/display/dc/dcn21/dcn21_resource.c | 2 + .../amd/display/dc/fpu_operations/Makefile | 58 +++++++++ .../drm/amd/display/dc/fpu_operations/dcn2x.c | 106 +++++++++++++++++ .../drm/amd/display/dc/fpu_operations/dcn2x.h | 33 ++++++ drivers/gpu/drm/amd/display/dc/os_types.h | 6 +- 13 files changed, 381 insertions(+), 43 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h create mode 100644 drivers/gpu/drm/amd/display/dc/fpu_operations/Makefile create mode 100644 drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.c create mode 100644 drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.h
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/4 drm/amd/display: Introduce FPU directory inside DC
The display core files rely on FPU operation, which requires to be compiled with special flags. Ideally, we don't want these FPU operations to get spread around the DC code; nevertheless, it happens in the current source. This commit introduces a new directory named fpu_operations that intends to centralize all files that require the FPU compilation flag. As part of this new component, this patch also moves one of the functions that require FPU access to a single shared file. Notice that this is the first part of the work, and it does not fix the FPU issue yet; we still need other patches for achieving the complete isolation of this file.
--- drivers/gpu/drm/amd/display/dc/Makefile | 1 + .../drm/amd/display/dc/dcn20/dcn20_resource.c | 39 +------- .../drm/amd/display/dc/dcn20/dcn20_resource.h | 2 - .../drm/amd/display/dc/dcn21/dcn21_resource.c | 2 + .../amd/display/dc/fpu_operations/Makefile | 58 ++++++++++++ .../drm/amd/display/dc/fpu_operations/dcn2x.c | 89 +++++++++++++++++++ .../drm/amd/display/dc/fpu_operations/dcn2x.h | 33 +++++++ 7 files changed, 185 insertions(+), 39 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/fpu_operations/Makefile create mode 100644 drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.c create mode 100644 drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.h
drivers/gpu/drm/amd/display/dc/Makefile +1 -0
@@ -35,6 +35,7 @@ DC_LIBS += dcn301 DC_LIBS += dcn302 endif +DC_LIBS += fpu_operations DC_LIBS += dce120 DC_LIBS += dce112
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +2 -37
@@ -35,6 +35,8 @@#include "include/irq_service_interface.h" #include "dcn20/dcn20_resource.h" +#include "fpu_operations/dcn2x.h" +#include "dcn10/dcn10_hubp.h" #include "dcn10/dcn10_ipp.h" #include "dcn20_hubbub.h"
@@ -1974,43 +1976,6 @@ void dcn20_split_stream_for_mpc(ASSERT (primary_pipe->plane_state); } -void dcn20_populate_dml_writeback_from_context ( -struct dc *dc,struct resource_context *res_ctx,display_e2e_pipe_params_st *pipes) -{ -int pipe_cnt, i; - -for (i =0 , pipe_cnt =0 ; i < dc->res_pool->pipe_count; i++) { -struct dc_writeback_info *wb_info = &res_ctx->pipe_ctx[i].stream->writeback_info[0 ]; - -if (!res_ctx->pipe_ctx[i].stream) -continue ; - -/* Set writeback information */ - pipes[pipe_cnt].dout.wb_enable = (wb_info->wb_enabled == true) ?1 :0 ; - pipes[pipe_cnt].dout.num_active_wb++; - pipes[pipe_cnt].dout.wb.wb_src_height = wb_info->dwb_params.cnv_params.crop_height; - pipes[pipe_cnt].dout.wb.wb_src_width = wb_info->dwb_params.cnv_params.crop_width; - pipes[pipe_cnt].dout.wb.wb_dst_width = wb_info->dwb_params.dest_width; - pipes[pipe_cnt].dout.wb.wb_dst_height = wb_info->dwb_params.dest_height; - pipes[pipe_cnt].dout.wb.wb_htaps_luma =1 ; - pipes[pipe_cnt].dout.wb.wb_vtaps_luma =1 ; - pipes[pipe_cnt].dout.wb.wb_htaps_chroma = wb_info->dwb_params.scaler_taps.h_taps_c; - pipes[pipe_cnt].dout.wb.wb_vtaps_chroma = wb_info->dwb_params.scaler_taps.v_taps_c; - pipes[pipe_cnt].dout.wb.wb_hratio =1.0 ; - pipes[pipe_cnt].dout.wb.wb_vratio =1.0 ; -if (wb_info->dwb_params.out_format == dwb_scaler_mode_yuv420) { -if (wb_info->dwb_params.output_depth ==DWB_OUTPUT_PIXEL_DEPTH_8BPC ) - pipes[pipe_cnt].dout.wb.wb_pixel_format = dm_420_8; -else - pipes[pipe_cnt].dout.wb.wb_pixel_format = dm_420_10; - }else - pipes[pipe_cnt].dout.wb.wb_pixel_format = dm_444_32; - - pipe_cnt++; - } - -} - int dcn20_populate_dml_pipes_from_context( struct dc *dc, struct dc_state *context,
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.h +0 -2
@@ -58,8 +58,6 @@ struct pipe_ctx *dcn20_acquire_idle_pipe_for_layer(struct dc_state *state, const struct resource_pool *pool, struct dc_stream_state *stream); -void dcn20_populate_dml_writeback_from_context ( -struct dc *dc,struct resource_context *res_ctx,display_e2e_pipe_params_st *pipes); struct stream_encoder *dcn20_stream_encoder_create( enum engine_id eng_id,
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +2 -0
@@ -35,6 +35,8 @@#include "include/irq_service_interface.h" #include "dcn20/dcn20_resource.h" +#include "fpu_operations/dcn2x.h" +#include "clk_mgr.h" #include "dcn10/dcn10_hubp.h" #include "dcn10/dcn10_ipp.h"
drivers/gpu/drm/amd/display/dc/fpu_operations/Makefile new file +58 -0
58 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.c new file +89 -0
89 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __DCN2X_H__ +#define __DCN2X_H__ + +void dcn20_populate_dml_writeback_from_context (struct dc *dc, +struct resource_context *res_ctx,display_e2e_pipe_params_st *pipes); + +#endif /* __DCN2X_H__ */
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
kernel test robot
build botRe: [PATCH 1/4] drm/amd/display: Introduce FPU directory inside DC
I love your patch! Perhaps something to improve:
Hi Rodrigo,
I love your patch! Perhaps something to improve:
[auto build test WARNING on next-20210331]
[also build test WARNING on v5.12-rc5]
[cannot apply to linus/master v5.12-rc5 v5.12-rc4 v5.12-rc3] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Rodrigo-Siqueira/drm-amd-display-Base-changes-for-isolating-FPU-operation-in-a-single-place/20210331-202750 base: 7a43c78d0573e0bbbb0456b033e2b9a895b89464 config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c4d5d1d0a04f13014a22e6932ddf8487bb130d34
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Rodrigo-Siqueira/drm-amd-display-Base-changes-for-isolating-FPU-operation-in-a-single-place/20210331-202750 git checkout c4d5d1d0a04f13014a22e6932ddf8487bb130d34
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/amd/amdgpu/../display/dc/fpu_operations/dcn2x.c:84:6: warning: no previous prototype for 'dcn20_populate_dml_writeback_from_context' [-Wmissing-prototypes]
84 | void dcn20_populate_dml_writeback_from_context(struct dc *dc,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/dcn20_populate_dml_writeback_from_context +84 drivers/gpu/drm/amd/amdgpu/../display/dc/fpu_operations/dcn2x.c
83
> 84 void dcn20_populate_dml_writeback_from_context(struct dc *dc,
85 struct resource_context *res_ctx, display_e2e_pipe_params_st *pipes)
86 {
87 _dcn20_populate_dml_writeback_from_context(dc, res_ctx, pipes);
88 }
89 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 2/4 drm/amd/display: Add FPU event trace
In reply to Rodrigo SiqueiraWe don't have any mechanism for tracing FPU operations inside the display core, making the debug work a little bit tricky. For trying to alleviate this problem, this commit introduces a trace mechanism inside our DC_FP_START/END macros.
--- .../gpu/drm/amd/display/amdgpu_dm/Makefile | 3 +- .../amd/display/amdgpu_dm/amdgpu_dm_trace.h | 21 +++++++ .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 61 +++++++++++++++++++ .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.h | 33 ++++++++++ drivers/gpu/drm/amd/display/dc/dc_trace.h | 3 + drivers/gpu/drm/amd/display/dc/os_types.h | 6 +- 6 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h
drivers/gpu/drm/amd/display/amdgpu_dm/Makefile +2 -1
@@ -25,7 +25,8 @@ -AMDGPUDM = amdgpu_dm.o amdgpu_dm_irq.o amdgpu_dm_mst_types.o amdgpu_dm_color.o +AMDGPUDM = amdgpu_dm.o amdgpu_dm_irq.o amdgpu_dm_mst_types.o amdgpu_dm_color.o \ + dc_fpu.o ifneq ($(CONFIG_DRM_AMD_DC),) AMDGPUDM += amdgpu_dm_services.o amdgpu_dm_helpers.o amdgpu_dm_pp_smu.o
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h +21 -0
@@ -637,6 +637,27 @@ TRACE_EVENT(amdgpu_refresh_rate_track, __entry->refresh_rate_ns) ); +TRACE_EVENT (dcn_fpu, + TP_PROTO(bool begin, const char *function, const int line), +TP_ARGS (begin, function, line), + +TP_STRUCT__entry ( + __field(bool, begin) + __field(const char *, function) +__field (int, line) + ), +TP_fast_assign ( + __entry->begin = begin; + __entry->function = function; + __entry->line = line; + ), +TP_printk ("%s()+%d: %s" , + __entry->function, + __entry->line, + __entry->begin ?"begin" :"end" + ) +); +#endif /* _AMDGPU_DM_TRACE_H_ */ #undef TRACE_INCLUDE_PATH
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c new file +61 -0
61 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2021 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __DC_FPU_H__ +#define __DC_FPU_H__ + +void dc_fpu_begin (const char *function_name,const int line); +void dc_fpu_end (const char *function_name,const int line); + +#endif /* __DC_FPU_H__ */
drivers/gpu/drm/amd/display/dc/dc_trace.h +3 -0
@@ -37,3 +37,6 @@#define TRACE_DCN_CLOCK_STATE (dcn_clocks) \ trace_amdgpu_dm_dc_clocks_state(dcn_clocks) + +#define TRACE_DCN_FPU (begin, function, line) \ + trace_dcn_fpu(begin, function, line)
drivers/gpu/drm/amd/display/dc/os_types.h +3 -3
@@ -52,9 +52,9 @@#if defined(CONFIG_DRM_AMD_DC_DCN )#if defined(CONFIG_X86 ) -#include <asm/fpu/api.h> -#define DC_FP_START () kernel_fpu_begin() -#define DC_FP_END () kernel_fpu_end() +#include "amdgpu_dm/dc_fpu.h" +#define DC_FP_START () dc_fpu_begin(__func__, __LINE__) +#define DC_FP_END () dc_fpu_end(__func__, __LINE__)#elif defined(CONFIG_PPC64 )#include <asm/switch_to.h> #include <asm/cputable.h>
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
kernel test robot
build botRe: [PATCH 2/4] drm/amd/display: Add FPU event trace
I love your patch! Perhaps something to improve:
Hi Rodrigo,
I love your patch! Perhaps something to improve:
[auto build test WARNING on next-20210331]
[cannot apply to linus/master v5.12-rc5 v5.12-rc4 v5.12-rc3 v5.12-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Rodrigo-Siqueira/drm-amd-display-Base-changes-for-isolating-FPU-operation-in-a-single-place/20210331-202750 base: 7a43c78d0573e0bbbb0456b033e2b9a895b89464 config: x86_64-allyesconfig (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/5859110d0579f7ee57ca1b1840c3960492a9c0c0 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Rodrigo-Siqueira/drm-amd-display-Base-changes-for-isolating-FPU-operation-in-a-single-place/20210331-202750 git checkout 5859110d0579f7ee57ca1b1840c3960492a9c0c0 # save the attached .config to linux build tree make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/dc_fpu.c:41:6: warning: no previous prototype for 'dc_fpu_begin' [-Wmissing-prototypes]
41 | void dc_fpu_begin(const char *function_name, const int line)
| ^~~~~~~~~~~~
>> drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/dc_fpu.c:57:6: warning: no previous prototype for 'dc_fpu_end' [-Wmissing-prototypes] 57 | void dc_fpu_end(const char *function_name, const int line)
| ^~~~~~~~~~
vim +/dc_fpu_begin +41 drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/dc_fpu.c
30
31 /**
32 * dc_fpu_begin - Enables FPU protection
33 * @function_name: A string containing the function name for debug purposes
34 * @line: A-line number where DC_FP_START was invoked for debug purpose
35 *
36 * This function is responsible for managing the use of kernel_fpu_begin() with
37 * the advantage of providing an event trace for debugging.
38 *
39 * Note: Do not call this function directly; always use DC_FP_START().
40 */
> 41 void dc_fpu_begin(const char *function_name, const int line)
42 {
43 TRACE_DCN_FPU(true, function_name, line);
44 kernel_fpu_begin();
45 }
46
47 /**
48 * dc_fpu_end - Disable FPU protection
49 * @function_name: A string containing the function name for debug purposes
50 * @line: A-line number where DC_FP_END was invoked for debug purpose
51 *
52 * This function is responsible for managing the use of kernel_fpu_end() with
53 * the advantage of providing an event trace for debugging.
54 *
55 * Note: Do not call this function directly; always use DC_FP_END().
56 */
> 57 void dc_fpu_end(const char *function_name, const int line)---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH 2/4] drm/amd/display: Add FPU event trace
In reply to Rodrigo SiqueiraI love your patch! Yet something to improve:
Hi Rodrigo,
I love your patch! Yet something to improve:
[auto build test ERROR on next-20210331]
[cannot apply to linus/master v5.12-rc5 v5.12-rc4 v5.12-rc3 v5.12-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Rodrigo-Siqueira/drm-amd-display-Base-changes-for-isolating-FPU-operation-in-a-single-place/20210331-202750 base: 7a43c78d0573e0bbbb0456b033e2b9a895b89464 config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5859110d0579f7ee57ca1b1840c3960492a9c0c0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Rodrigo-Siqueira/drm-amd-display-Base-changes-for-isolating-FPU-operation-in-a-single-place/20210331-202750 git checkout 5859110d0579f7ee57ca1b1840c3960492a9c0c0
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/dc_fpu.c:29:10: fatal error: asm/fpu/api.h: No such file or directory
29 | #include <asm/fpu/api.h>
| ^~~~~~~~~~~~~~~compilation terminated.
vim +29 drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/dc_fpu.c
28
> 29 #include <asm/fpu/api.h>
30 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 3/4 drm/amd/display: Add ref count control for FPU utilization
In reply to Rodrigo SiqueiraDC 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. For avoiding this situation, this commit adds a mechanism where dc_fpu_begin/end manages the access to kernel_fpu_begin/end.
--- .../amd/display/amdgpu_dm/amdgpu_dm_trace.h | 13 ++++--- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 34 ++++++++++++++++--- drivers/gpu/drm/amd/display/dc/dc_trace.h | 4 +-- 3 files changed, 40 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h +8 -5
@@ -638,23 +638,26 @@ TRACE_EVENT(amdgpu_refresh_rate_track, );TRACE_EVENT (dcn_fpu, - TP_PROTO(bool begin, const char *function, const int line), -TP_ARGS (begin, function, line), + TP_PROTO(bool begin, const char *function, const int line, const int ref_count), +TP_ARGS (begin, function, line, ref_count),TP_STRUCT__entry ( __field(bool, begin) __field(const char *, function) __field(int, line) +__field (int, ref_count) ),TP_fast_assign ( __entry->begin = begin; __entry->function = function; __entry->line = line; + __entry->ref_count = ref_count; ), -TP_printk ("%s()+%d: %s" , +TP_printk ("%s: ref_count: %d: %s()+%d:" , + __entry->begin ?"begin" :"end" , + __entry->ref_count, __entry->function, - __entry->line, - __entry->begin ?"begin" :"end" + __entry->line ) );
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +30 -4
@@ -28,6 +28,19 @@#include <asm/fpu/api.h> +/** +* DOC: 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(atomic_t, fpu_ref); +/** * dc_fpu_begin - Enables FPU protection * @function_name: A string containing the function name for debug purposes
@@ -40,8 +53,14 @@*/ void dc_fpu_begin (const char *function_name,const int line) { -TRACE_DCN_FPU (true, function_name, line); -kernel_fpu_begin (); +int ret; +atomic_t *local_fpu_ref =this_cpu_ptr (&fpu_ref); + + ret =atomic_inc_return (local_fpu_ref); +TRACE_DCN_FPU (true, function_name, line, ret); + +if (ret ==1 ) +kernel_fpu_begin (); }/**
@@ -56,6 +75,13 @@ 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); -kernel_fpu_end (); + +int ret; +atomic_t *local_fpu_ref =this_cpu_ptr (&fpu_ref); + + ret =atomic_dec_return (local_fpu_ref); +TRACE_DCN_FPU (false, function_name, line, ret); + +if (!ret) +kernel_fpu_end (); }
drivers/gpu/drm/amd/display/dc/dc_trace.h +2 -2
@@ -38,5 +38,5 @@#define TRACE_DCN_CLOCK_STATE (dcn_clocks) \ trace_amdgpu_dm_dc_clocks_state(dcn_clocks) -#define TRACE_DCN_FPU (begin, function, line) \ - trace_dcn_fpu(begin, function, line) +#define TRACE_DCN_FPU (begin, function, line, ref_count) \ + trace_dcn_fpu(begin, function, line, ref_count)
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerRe: [PATCH 3/4] drm/amd/display: Add ref count control for FPU utilization
Am 31.03.21 um 14:25 schrieb Rodrigo Siqueira:
Quoted 4 lines
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. For avoiding this situation, this commit adds a mechanism where dc_fpu_begin/end manages the access to kernel_fpu_begin/end.
In general please name this "recursion" control instead of "ref count". Let's call the child by it's name :)
Quoted 70 lines
Signed-off-by Rodrigo Siqueira <[email protected]>Acked-by Rodrigo Siqueira <[email protected]>--- .../amd/display/amdgpu_dm/amdgpu_dm_trace.h | 13 ++++--- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 34 ++++++++++++++++--- drivers/gpu/drm/amd/display/dc/dc_trace.h | 4 +-- 3 files changed, 40 insertions(+), 11 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h +8
-5@@ -638,23 +638,26 @@ TRACE_EVENT(amdgpu_refresh_rate_track, );TRACE_EVENT (dcn_fpu, - TP_PROTO(bool begin, const char *function, const int line), -TP_ARGS (begin, function, line), + TP_PROTO(bool begin, const char *function, const int line, const int ref_count), +TP_ARGS (begin, function, line, ref_count),TP_STRUCT__entry ( __field(bool, begin) __field(const char *, function) __field(int, line) +__field (int, ref_count) ),TP_fast_assign ( __entry->begin = begin; __entry->function = function; __entry->line = line; + __entry->ref_count = ref_count; ), -TP_printk ("%s()+%d: %s" , +TP_printk ("%s: ref_count: %d: %s()+%d:" , + __entry->begin ?"begin" :"end" , + __entry->ref_count, __entry->function, - __entry->line, - __entry->begin ?"begin" :"end" + __entry->line ) );drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +13
-0@@ -28,6 +28,19 @@#include <asm/fpu/api.h> +/** +* DOC: 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(atomic_t, fpu_ref); +/** * dc_fpu_begin - Enables FPU protection * @function_name: A string containing the function name for debug purposes
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c line 59
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +4
-2@@ -40,8 +53,14 @@*/ void dc_fpu_begin (const char *function_name,const int line) { -TRACE_DCN_FPU (true, function_name, line); -kernel_fpu_begin (); +int ret; +atomic_t *local_fpu_ref =this_cpu_ptr (&fpu_ref); + + ret =atomic_inc_return (local_fpu_ref);
You need to disable preemption for this or otherwise it can be that you schedule to another process.
Regards,
Christian.
Quoted 28 lines
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +13
-2+TRACE_DCN_FPU (true, function_name, line, ret); + +if (ret ==1 ) +kernel_fpu_begin (); }/** @@ -56,6 +75,13 @@ 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); -kernel_fpu_end (); + +int ret; +atomic_t *local_fpu_ref =this_cpu_ptr (&fpu_ref); + + ret =atomic_dec_return (local_fpu_ref); +TRACE_DCN_FPU (false, function_name, line, ret); + +if (!ret) +kernel_fpu_end (); }drivers/gpu/drm/amd/display/dc/dc_trace.h +0
-0
drivers/gpu/drm/amd/display/dc/dc_trace.h line 42
Quoted 7 lines
drivers/gpu/drm/amd/display/dc/dc_trace.h +2
-2@@ -38,5 +38,5 @@#define TRACE_DCN_CLOCK_STATE (dcn_clocks) \ trace_amdgpu_dm_dc_clocks_state(dcn_clocks) -#define TRACE_DCN_FPU (begin, function, line) \ - trace_dcn_fpu(begin, function, line) +#define TRACE_DCN_FPU (begin, function, line, ref_count) \ + trace_dcn_fpu(begin, function, line, ref_count)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/4 drm/amd/display: Add DC_FP helper to check FPU state
In reply to Rodrigo SiqueiraTo fully isolate FPU operations in a single place, we must avoid situations where compilers spill FP values to registers due to FP enable in a specific C file. Note that even if we isolate all FPU functions in a single file and call its interface from other files, the compiler might enable the use of FPU before we call DC_FP_START. Nevertheless, it is the programmer's responsibility to invoke DC_FP_START/END in the correct place. To highlight situations where developers forgot to use the FP protection before calling the DC FPU interface functions, we introduce a helper that checks if the function is invoked under FP protection. If not, it will trigger a kernel warning.
--- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 34 ++++++++++++++++--- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.h | 1 + .../drm/amd/display/dc/dcn20/dcn20_resource.c | 2 ++ .../drm/amd/display/dc/fpu_operations/dcn2x.c | 17 ++++++++++ 4 files changed, 49 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +29 -5
@@ -40,6 +40,25 @@*/ static DEFINE_PER_CPU(atomic_t, fpu_ref); +static DEFINE_PER_CPU(atomic_t, fp_dc_enabled); + +/** +* is_fp_dc_enabled - Check if FPU protection is enabled +* +* This function tells if the code is already under FPU protection or not. A +* function that works as an API for a set of FPU operations can use this +* function for checking if the caller invoked it after DC_FP_START(). For +* example, take a look at dcn2x.c file. +* +* Return: +* Return true if we already enabled FPU protection, otherwise return false. +*/ +inline bool is_fp_dc_enabled (void ) +{ +atomic_t *fp_enabled =this_cpu_ptr (&fp_dc_enabled); + +return atomic_read (fp_enabled); +}/** * dc_fpu_begin - Enables FPU protection
@@ -55,12 +74,15 @@ void dc_fpu_begin(const char *function_name, const int line) {int ret;atomic_t *local_fpu_ref =this_cpu_ptr (&fpu_ref); +atomic_t *fp_enabled =this_cpu_ptr (&fp_dc_enabled); ret =atomic_inc_return (local_fpu_ref);TRACE_DCN_FPU (true, function_name, line, ret); -if (ret ==1 ) +if (ret ==1 ) {kernel_fpu_begin (); +atomic_set (fp_enabled,1 ); + } }/**
@@ -75,13 +97,15 @@ void dc_fpu_begin(const char *function_name, const int line)*/ void dc_fpu_end (const char *function_name,const int line) { - -int ret; +bool ret;atomic_t *local_fpu_ref =this_cpu_ptr (&fpu_ref); +atomic_t *fp_enabled =this_cpu_ptr (&fp_dc_enabled); - ret =atomic_dec_return (local_fpu_ref); + ret =atomic_dec_and_test (local_fpu_ref);TRACE_DCN_FPU (false, function_name, line, ret); -if (!ret) +if (ret) { +atomic_set (fp_enabled,0 );kernel_fpu_end (); + } }
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h +1 -0
@@ -27,6 +27,7 @@#ifndef __DC_FPU_H__#define __DC_FPU_H__ +bool is_fp_dc_enabled (void );void dc_fpu_begin (const char *function_name,const int line);void dc_fpu_end (const char *function_name,const int line);
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +2 -0
@@ -2351,7 +2351,9 @@ int dcn20_populate_dml_pipes_from_context( }/* populate writeback information */ +DC_FP_START (); dc->res_pool->funcs->populate_dml_writeback_from_context (dc, res_ctx, pipes); +DC_FP_END ();return pipe_cnt; }
drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.c +17 -0
@@ -42,6 +42,22 @@* that deals with FP register is contained within this call. * 3. All function that needs to be accessed outside this file requires a * public interface that not uses any FPU reference. +* 4. Developers should not use DC_FP_START/END in this file, but they need to +* ensure that the caller invokes it before access any function available in +* this file. For this reason, public API in this file must invoke +* ASSERT(is_fp_dc_enabled()); +* +* Let's expand a little bit more the idea in the code pattern number for. To +* fully isolate FPU operations in a single place, we must avoid situations +* where compilers spill FP values to registers due to FP enable in a specific +* C file. Note that even if we isolate all FPU functions in a single file and +* call its interface from other files, the compiler might enable the use of +* FPU before we call DC_FP_START. Nevertheless, it is the programmer's +* responsibility to invoke DC_FP_START/END in the correct place. To highlight +* situations where developers forgot to use the FP protection before calling +* the DC FPU interface functions, we introduce a helper that checks if the +* function is invoked under FP protection. If not, it will trigger a kernel +* warning. */ static noinline void _dcn20_populate_dml_writeback_from_context(struct dc *dc,
@@ -84,6 +100,7 @@ static noinline void _dcn20_populate_dml_writeback_from_context(struct dc *dc,void dcn20_populate_dml_writeback_from_context (struct dc *dc,struct resource_context *res_ctx,display_e2e_pipe_params_st *pipes) { +ASSERT (is_fp_dc_enabled ());_dcn20_populate_dml_writeback_from_context (dc, res_ctx, pipes); }
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerRe: [PATCH 4/4] drm/amd/display: Add DC_FP helper to check FPU state
Am 31.03.21 um 14:25 schrieb Rodrigo Siqueira:
Quoted 32 lines
To fully isolate FPU operations in a single place, we must avoid situations where compilers spill FP values to registers due to FP enable in a specific C file. Note that even if we isolate all FPU functions in a single file and call its interface from other files, the compiler might enable the use of FPU before we call
DC_FP_START. Nevertheless, it is the programmer's responsibility to invoke DC_FP_START/END in the correct place. To highlight situations where developers forgot to use the FP protection before calling the DC FPU interface functions, we introduce a helper that checks if the function is invoked under FP protection. If not, it will trigger a kernel warning.Signed-off-by Rodrigo Siqueira <[email protected]>Acked-by Rodrigo Siqueira <[email protected]>--- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 34 ++++++++++++++++--- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.h | 1 + .../drm/amd/display/dc/dcn20/dcn20_resource.c | 2 ++ .../drm/amd/display/dc/fpu_operations/dcn2x.c | 17 ++++++++++ 4 files changed, 49 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +4
-0@@ -40,6 +40,25 @@*/ static DEFINE_PER_CPU(atomic_t, fpu_ref); +static DEFINE_PER_CPU(atomic_t, fp_dc_enabled); + +/** +* is_fp_dc_enabled - Check if FPU protection is enabled
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c line 56
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +10
-0+* +* This function tells if the code is already under FPU protection or not. A +* function that works as an API for a set of FPU operations can use this +* function for checking if the caller invoked it after DC_FP_START(). For +* example, take a look at dcn2x.c file. +* +* Return: +* Return true if we already enabled FPU protection, otherwise return false. +*/ +inline bool is_fp_dc_enabled (void )
I would rather name this dc_is_fp_enabled() or even better directly make this dc_assert_fp_enabled().
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c line 60
Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +4
-0+{ +atomic_t *fp_enabled =this_cpu_ptr (&fp_dc_enabled); + +return atomic_read (fp_enabled);
The handling with fp_enaled is overkill. Instead you can also check fpu_ref for > 1.
Regards,
Christian.
Quoted 95 lines
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +11
-5+}/** * dc_fpu_begin - Enables FPU protection @@ -55,12 +74,15 @@ void dc_fpu_begin(const char *function_name, const int line) {int ret;atomic_t *local_fpu_ref =this_cpu_ptr (&fpu_ref); +atomic_t *fp_enabled =this_cpu_ptr (&fp_dc_enabled); ret =atomic_inc_return (local_fpu_ref);TRACE_DCN_FPU (true, function_name, line, ret); -if (ret ==1 ) +if (ret ==1 ) {kernel_fpu_begin (); +atomic_set (fp_enabled,1 ); + } }/** @@ -75,13 +97,15 @@ void dc_fpu_begin(const char *function_name, const int line)*/ void dc_fpu_end (const char *function_name,const int line) { - -int ret; +bool ret;atomic_t *local_fpu_ref =this_cpu_ptr (&fpu_ref); +atomic_t *fp_enabled =this_cpu_ptr (&fp_dc_enabled); - ret =atomic_dec_return (local_fpu_ref); + ret =atomic_dec_and_test (local_fpu_ref);TRACE_DCN_FPU (false, function_name, line, ret); -if (!ret) +if (ret) { +atomic_set (fp_enabled,0 );kernel_fpu_end (); + } }drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h +1
-0@@ -27,6 +27,7 @@#ifndef __DC_FPU_H__#define __DC_FPU_H__ +bool is_fp_dc_enabled (void );void dc_fpu_begin (const char *function_name,const int line);void dc_fpu_end (const char *function_name,const int line);drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +2
-0@@ -2351,7 +2351,9 @@ int dcn20_populate_dml_pipes_from_context( }/* populate writeback information */ +DC_FP_START (); dc->res_pool->funcs->populate_dml_writeback_from_context (dc, res_ctx, pipes); +DC_FP_END ();return pipe_cnt; }drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.c +16
-0@@ -42,6 +42,22 @@* that deals with FP register is contained within this call. * 3. All function that needs to be accessed outside this file requires a * public interface that not uses any FPU reference. +* 4. Developers should not use DC_FP_START/END in this file, but they need to +* ensure that the caller invokes it before access any function available in +* this file. For this reason, public API in this file must invoke +* ASSERT(is_fp_dc_enabled()); +* +* Let's expand a little bit more the idea in the code pattern number for. To +* fully isolate FPU operations in a single place, we must avoid situations +* where compilers spill FP values to registers due to FP enable in a specific +* C file. Note that even if we isolate all FPU functions in a single file and +* call its interface from other files, the compiler might enable the use of +* FPU before we call DC_FP_START. Nevertheless, it is the programmer's +* responsibility to invoke DC_FP_START/END in the correct place. To highlight +* situations where developers forgot to use the FP protection before calling +* the DC FPU interface functions, we introduce a helper that checks if the +* function is invoked under FP protection. If not, it will trigger a kernel +* warning. */ static noinline void _dcn20_populate_dml_writeback_from_context(struct dc *dc,
drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.c static noinline void _dcn20_populate_dml_writeback_from_context(struct dc *dc, · line 106
Quoted 7 lines
drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.c +1
-0@@ -84,6 +100,7 @@ static noinline void _dcn20_populate_dml_writeback_from_context(struct dc *dc,void dcn20_populate_dml_writeback_from_context (struct dc *dc,struct resource_context *res_ctx,display_e2e_pipe_params_st *pipes) { +ASSERT (is_fp_dc_enabled ());_dcn20_populate_dml_writeback_from_context (dc, res_ctx, pipes); }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerHi Rodrigo,
I'm not so happy about the whole recursion thing, but I think that is something which can be worked on later on.
Apart from that the approach sounds solid to me.
Regards,
Christian.
Am 31.03.21 um 14:24 schrieb Rodrigo Siqueira:
Quoted 94 lines
Hi,
In the display core, we utilize floats and doubles units for calculating modesetting parameters. One side effect of our approach to use double-precision is the fact that we spread multiple FPU access across our driver, which means that we can accidentally clobber user space FPU state.
# Challenges
1. Keep in mind that this FPU code is ingrained in our display driver and performs several crucial tasks. Additionally, we already have multiple architectures available in the kernel and a large set of users; in other words, we prefer to avoid a radical approach that might break our user's system.
2. We share our display code with Windows; thus, we need to maintain the interoperability between these two systems.
3. We need a mechanism for identifying which function uses FPU registers; fortunately, Peter Zijlstra wrote a series a couple of months ago where he introduced an FPU check for objtool. I used the following command for identifying the potential FPU usage:
./tools/objtool/objtoolcheck -Ffa "drivers/gpu/drm/amd/display/dc/ANY_FILE.o"4. Since our code heavily relies on FPU and the fact that we spread kernel_fpu_begin/end across multiple functions, we can have some complex scenarios that will require code refactoring. However, we want to avoid complicated changes since this is a formula to introduce regressions; we want something that allows us to fix it in small, safe, and reliable steps.
# Our approach
For trying to solve this problem, we came up with the following strategy:
1. Keep in mind that we are using kernel_fpu_begin/end spread in various areas and sometimes across multiple functions. If we try to move some of the functions to an isolated place, we can generate a situation where we can call the FPU protection more than once, causing multiple warnings. We can deal with this problem by adding a thin management layer around the kernel_fpu_begin/end used inside the display.
2. We will need a trace mechanism for this FPU management inside our display code.
3. After we get the thin layer that manages FPU, we can start to move each function that uses FPU to the centralized place. Our DQE runs multiple tests in different ASICs every week; we can take advantage of this to ensure that our FPU patches work does not introduce any regression. The idea is to work on a specific part of the code every week (e.g., week 1: DCN2, week 1: DCN2.1, etc.).
4. Finally, after we can isolate the FPU operations in a single place, we can altogether remove the FPU flags from other files and eliminate an unnecessary code introduced to deal with this problem.
# This series
To maintain the interoperability between multiple OSes, we already have a define named DC_FP_START/END, which is a straightforward wrapper to kernel_fpu_begin/end in the Linux side. In this series, I decided to expand the scope of this DC_FP_* wrapper to trace FPU entrance and exit in the display code, but I also add a mechanism for managing the entrance and exit of kernel_fpu_begin/end. You can see the details on how I did that in the last two patches.
I also isolate a simple function that requires FPU access to demonstrate my strategy for isolating this FPU access in a single place. If this series gets accepted, the following steps consist of moving all FPU functions weekly until we isolate everything in the
fpu_operationfolder.Best Regards
Rodrigo SiqueiraRodrigo Siqueira (4):
drm/amd/display: Introduce FPU directory inside DC drm/amd/display: Add FPU event trace drm/amd/display: Add ref count control for FPU utilization drm/amd/display: AddDC_FPhelper to check FPU state.../gpu/drm/amd/display/amdgpu_dm/Makefile | 3 +- .../amd/display/amdgpu_dm/amdgpu_dm_trace.h | 24 ++++ .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 111 ++++++++++++++++++ .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.h | 34 ++++++ drivers/gpu/drm/amd/display/dc/Makefile | 1 + drivers/gpu/drm/amd/display/dc/dc_trace.h | 3 + .../drm/amd/display/dc/dcn20/dcn20_resource.c | 41 +------ .../drm/amd/display/dc/dcn20/dcn20_resource.h | 2 - .../drm/amd/display/dc/dcn21/dcn21_resource.c | 2 + .../amd/display/dc/fpu_operations/Makefile | 58 +++++++++ .../drm/amd/display/dc/fpu_operations/dcn2x.c | 106 +++++++++++++++++ .../drm/amd/display/dc/fpu_operations/dcn2x.h | 33 ++++++ drivers/gpu/drm/amd/display/dc/os_types.h | 6 +- 13 files changed, 381 insertions(+), 43 deletions(-)
Quoted 6 lines
create mode 100644
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.ccreate mode 100644drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.hcreate mode 100644drivers/gpu/drm/amd/display/dc/fpu_operations/Makefilecreate mode 100644drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.ccreate mode 100644drivers/gpu/drm/amd/display/dc/fpu_operations/dcn2x.h
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx