drm/amd/display: Remove FPU operations from dcn201 resources
authorRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Thu, 14 Jul 2022 19:11:31 +0000 (15:11 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 25 Jul 2022 21:16:08 +0000 (17:16 -0400)
We have some FPU operations on the resource part of the DCN201. This
commit drops FPU flags and moves any required FPU code to the DML
folder.

Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Acked-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dcn201/Makefile
drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c
drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.h

index 96cbd4c..5c9ce2c 100644 (file)
@@ -6,30 +6,6 @@ DCN201 = dcn201_init.o dcn201_resource.o dcn201_hwseq.o \
        dcn201_mpc.o dcn201_hubp.o dcn201_opp.o dcn201_optc.o dcn201_dpp.o \
        dcn201_dccg.o dcn201_link_encoder.o
 
-ifdef CONFIG_X86
-CFLAGS_$(AMDDALPATH)/dc/dcn201/dcn201_resource.o := -mhard-float -msse
-endif
-
-ifdef CONFIG_PPC64
-CFLAGS_$(AMDDALPATH)/dc/dcn201/dcn201_resource.o := -mhard-float -maltivec
-endif
-
-ifdef CONFIG_CC_IS_GCC
-ifeq ($(call cc-ifversion, -lt, 0701, y), y)
-IS_OLD_GCC = 1
-endif
-endif
-
-ifdef CONFIG_X86
-ifdef IS_OLD_GCC
-# Stack alignment mismatch, proceed with caution.
-# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
-# (8B stack alignment).
-CFLAGS_$(AMDDALPATH)/dc/dcn201/dcn201_resource.o += -mpreferred-stack-boundary=4
-else
-CFLAGS_$(AMDDALPATH)/dc/dcn201/dcn201_resource.o += -msse2
-endif
-endif
 AMD_DAL_DCN201 = $(addprefix $(AMDDALPATH)/dc/dcn201/,$(DCN201))
 
 AMD_DISPLAY_FILES += $(AMD_DAL_DCN201)
index 0bb7d3d..e549a79 100644 (file)
@@ -1036,6 +1036,14 @@ static bool dcn201_get_dcc_compression_cap(const struct dc *dc,
                        output);
 }
 
+static void dcn201_populate_dml_writeback_from_context(struct dc *dc,
+                                                      struct resource_context *res_ctx,
+                                                      display_e2e_pipe_params_st *pipes)
+{
+       DC_FP_START();
+       dcn201_populate_dml_writeback_from_context_fpu(dc, res_ctx, pipes);
+       DC_FP_END();
+}
 
 static void dcn201_destroy_resource_pool(struct resource_pool **pool)
 {
@@ -1067,8 +1075,8 @@ static struct resource_funcs dcn201_res_pool_funcs = {
        .add_dsc_to_stream_resource = NULL,
        .remove_stream_from_ctx = dcn20_remove_stream_from_ctx,
        .acquire_idle_pipe_for_layer = dcn201_acquire_idle_pipe_for_layer,
+       .populate_dml_writeback_from_context = dcn201_populate_dml_writeback_from_context,
        .patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
-       .populate_dml_writeback_from_context = dcn20_populate_dml_writeback_from_context,
        .set_mcif_arb_params = dcn20_set_mcif_arb_params,
        .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link
 };
index eeeae52..3942848 100644 (file)
@@ -2303,3 +2303,90 @@ void dcn21_clk_mgr_set_bw_params_wm_table(struct clk_bw_params *bw_params)
        bw_params->wm_table.entries[WM_D].wm_type = WM_TYPE_RETRAINING;
        bw_params->wm_table.entries[WM_D].valid = true;
 }
+
+void dcn201_populate_dml_writeback_from_context_fpu(struct dc *dc,
+                                                   struct resource_context *res_ctx,
+                                                   display_e2e_pipe_params_st *pipes)
+{
+       int pipe_cnt, i, j;
+       double max_calc_writeback_dispclk;
+       double writeback_dispclk;
+       struct writeback_st dout_wb;
+
+       dc_assert_fp_enabled();
+
+       for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
+               struct dc_stream_state *stream = res_ctx->pipe_ctx[i].stream;
+
+               if (!stream)
+                       continue;
+               max_calc_writeback_dispclk = 0;
+
+               /* Set writeback information */
+               pipes[pipe_cnt].dout.wb_enable = 0;
+               pipes[pipe_cnt].dout.num_active_wb = 0;
+               for (j = 0; j < stream->num_wb_info; j++) {
+                       struct dc_writeback_info *wb_info = &stream->writeback_info[j];
+
+                       if (wb_info->wb_enabled && wb_info->writeback_source_plane &&
+                                       (wb_info->writeback_source_plane == res_ctx->pipe_ctx[i].plane_state)) {
+                               pipes[pipe_cnt].dout.wb_enable = 1;
+                               pipes[pipe_cnt].dout.num_active_wb++;
+                               dout_wb.wb_src_height = wb_info->dwb_params.cnv_params.crop_en ?
+                                       wb_info->dwb_params.cnv_params.crop_height :
+                                       wb_info->dwb_params.cnv_params.src_height;
+                               dout_wb.wb_src_width = wb_info->dwb_params.cnv_params.crop_en ?
+                                       wb_info->dwb_params.cnv_params.crop_width :
+                                       wb_info->dwb_params.cnv_params.src_width;
+                               dout_wb.wb_dst_width = wb_info->dwb_params.dest_width;
+                               dout_wb.wb_dst_height = wb_info->dwb_params.dest_height;
+                               dout_wb.wb_htaps_luma = wb_info->dwb_params.scaler_taps.h_taps;
+                               dout_wb.wb_vtaps_luma = wb_info->dwb_params.scaler_taps.v_taps;;
+                               dout_wb.wb_htaps_chroma = wb_info->dwb_params.scaler_taps.h_taps_c;
+                               dout_wb.wb_vtaps_chroma = wb_info->dwb_params.scaler_taps.v_taps_c;
+                               dout_wb.wb_hratio = wb_info->dwb_params.cnv_params.crop_en ?
+                                       (double)wb_info->dwb_params.cnv_params.crop_width /
+                                               (double)wb_info->dwb_params.dest_width :
+                                       (double)wb_info->dwb_params.cnv_params.src_width /
+                                               (double)wb_info->dwb_params.dest_width;
+                               dout_wb.wb_vratio = wb_info->dwb_params.cnv_params.crop_en ?
+                                       (double)wb_info->dwb_params.cnv_params.crop_height /
+                                               (double)wb_info->dwb_params.dest_height :
+                                       (double)wb_info->dwb_params.cnv_params.src_height /
+                                               (double)wb_info->dwb_params.dest_height;
+                               if (wb_info->dwb_params.out_format == dwb_scaler_mode_yuv420) {
+                                       if (wb_info->dwb_params.output_depth == DWB_OUTPUT_PIXEL_DEPTH_8BPC)
+                                               dout_wb.wb_pixel_format = dm_420_8;
+                                       else
+                                               dout_wb.wb_pixel_format = dm_420_10;
+                               } else
+                                       dout_wb.wb_pixel_format = dm_444_32;
+
+                               /* Workaround for cases where multiple writebacks are connected to same plane
+                                * In which case, need to compute worst case and set the associated writeback parameters
+                                * This workaround is necessary due to DML computation assuming only 1 set of writeback
+                                * parameters per pipe */
+                               writeback_dispclk = CalculateWriteBackDISPCLK(
+                                               dout_wb.wb_pixel_format,
+                                               pipes[pipe_cnt].pipe.dest.pixel_rate_mhz,
+                                               dout_wb.wb_hratio,
+                                               dout_wb.wb_vratio,
+                                               dout_wb.wb_htaps_luma,
+                                               dout_wb.wb_vtaps_luma,
+                                               dout_wb.wb_htaps_chroma,
+                                               dout_wb.wb_vtaps_chroma,
+                                               dout_wb.wb_dst_width,
+                                               pipes[pipe_cnt].pipe.dest.htotal,
+                                               2);
+
+                               if (writeback_dispclk > max_calc_writeback_dispclk) {
+                                       max_calc_writeback_dispclk = writeback_dispclk;
+                                       pipes[pipe_cnt].dout.wb = dout_wb;
+                               }
+                       }
+               }
+
+               pipe_cnt++;
+       }
+
+}
index a6e1ad0..c51badf 100644 (file)
@@ -84,4 +84,8 @@ void dcn21_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params
 
 void dcn21_clk_mgr_set_bw_params_wm_table(struct clk_bw_params *bw_params);
 
+void dcn201_populate_dml_writeback_from_context_fpu(struct dc *dc,
+                                               struct resource_context *res_ctx,
+                                               display_e2e_pipe_params_st *pipes);
+
 #endif /* __DCN20_FPU_H__ */