DC Patches August 12, 2022
cover DC Patches August 12, 2022
This DC patchset brings improvements in multiple areas. In summary, we have:
* Fix ARGB16161616 pixel format;
* Fix pixel clock in 10/12-bpc;
* Add reserved dc_log_type;
* Fix some variables widths in dc;
* Add chip version GC_11_0_3_A0 to DCN32 family;
* Fix light up bug with dcn314 with 8K@30;
* Fix monitor hang while playback MPO video;
* Include scaling factor for SubVP command;
* Improve header inclusion pattern;
* Update clock table policy for DCN314;
* Modify DSC bit for phantom pipes;
* Use pitch when calculating size to cache in MALL;
* Avoid doing vm_init multiple time;
Alvin Lee (3):
drm/amd/display: Include scaling factor for SubVP command drm/amd/display: Don't set DSC for phantom pipes drm/amd/display: Use pitch when calculating size to cache in MALL
Aric Cyr (1):
drm/amd/display: 3.2.198
Chaitanya Dhere (1):
drm/amd/display: Modify header inclusion pattern
Charlene Liu (1):
drm/amd/display: avoid doing vm_init multiple time
Daniel Miess (1):
drm/amd/display: Add debug parameter to retain default clock table
Ethan Wellenreiter (1):
drm/amd/display: reverted limiting vscsdp_for_colorimetry and
ARGB16161616 pixel format addition
Ian Chen (1):
Add reserved dc_log_type.
Ilya Bakoulin (1):
drm/amd/display: Fix pixel clock programming
Josip Pavic (1):
drm/amd/display: do not compare integers of different widths
Nicholas Kazlauskas (1):
drm/amd/display: Update clock table policy for DCN314
Samson Tam (1):
drm/amd/display: add chip revision to DCN32
Tom Chung (1):
drm/amd/display: Fix plug/unplug external monitor will hang while
playback MPO video
.../drm/amd/display/dc/basics/conversion.c | 21 ++ .../drm/amd/display/dc/basics/conversion.h | 3 + .../dc/clk_mgr/dcn314/dcn314_clk_mgr.c | 188 ++++++++++++------ .../display/dc/clk_mgr/dcn314/dcn314_smu.h | 33 ++- drivers/gpu/drm/amd/display/dc/core/dc.c | 11 +- drivers/gpu/drm/amd/display/dc/dc.h | 3 +- drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 11 + .../drm/amd/display/dc/dce/dce_clock_source.c | 2 + .../gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c | 2 - .../gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | 3 - .../gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c | 2 - .../gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c | 3 - .../drm/amd/display/dc/dcn21/dcn21_hubbub.c | 8 +- .../gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c | 2 - .../drm/amd/display/dc/dcn32/dcn32_hwseq.c | 3 +- .../display/dc/dcn32/dcn32_resource_helpers.c | 2 +- .../amd/display/dc/dcn321/dcn321_resource.c | 3 +- .../dc/dml/dcn31/display_mode_vba_31.c | 2 +- .../dc/dml/dcn31/display_rq_dlg_calc_31.c | 2 +- .../amd/display/dc/dml/dcn314/dcn314_fpu.c | 2 +- .../drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 1 + .../gpu/drm/amd/display/include/dal_asic_id.h | 4 +- .../drm/amd/display/include/logger_types.h | 4 +- 23 files changed, 225 insertions(+), 90 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/14 drm/amd/display: reverted limiting vscsdp_for_colorimetry and ARGB16161616 pixel format addition
From: Ethan Wellenreiter <[email protected]>
[WHY]
Limiting vscsdp_for_colorimetry for YCbCr420/BT2020 resulted in red/green point failures in HDR10 DTN tests. The re-implementation of ARGB16161616 was to fix this however it did not actually fix this issue but a side effect of the issue.
[HOW]
Change ARGB16161616 pixel format to 26.
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c | 2 -- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | 3 --- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c | 2 -- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c | 3 --- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c | 2 -- 5 files changed, 12 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c +0 -2
@@ -361,8 +361,6 @@ void dpp1_cnv_setup ( select =INPUT_CSC_SELECT_ICSC ;break ;case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 : - pixel_format =22 ; -break ;case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 : pixel_format =26 ;/* ARGB16161616_UNORM */ break ;
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +0 -3
@@ -278,9 +278,6 @@ void hubp1_program_pixel_format( SURFACE_PIXEL_FORMAT, 10);break ;case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 : -REG_UPDATE (DCSURF_SURFACE_CONFIG , -SURFACE_PIXEL_FORMAT ,22 ); -break ;case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 :/*we use crossbar already*/ REG_UPDATE (DCSURF_SURFACE_CONFIG ,SURFACE_PIXEL_FORMAT ,26 );/* ARGB16161616_UNORM */
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c +0 -2
@@ -166,8 +166,6 @@ static void dpp2_cnv_setup ( select =DCN2_ICSC_SELECT_ICSC_A ;break ;case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 : - pixel_format =22 ; -break ;case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 : pixel_format =26 ;/* ARGB16161616_UNORM */ break ;
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hubp.c +0 -3
@@ -463,9 +463,6 @@ void hubp2_program_pixel_format( SURFACE_PIXEL_FORMAT, 10);break ;case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 : -REG_UPDATE (DCSURF_SURFACE_CONFIG , -SURFACE_PIXEL_FORMAT ,22 ); -break ;case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 :/*we use crossbar already*/ REG_UPDATE (DCSURF_SURFACE_CONFIG ,SURFACE_PIXEL_FORMAT ,26 );/* ARGB16161616_UNORM */
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c +0 -2
@@ -244,8 +244,6 @@ void dpp3_cnv_setup ( select =INPUT_CSC_SELECT_ICSC ;break ;case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 : - pixel_format =22 ; -break ;case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 : pixel_format =26 ;/* ARGB16161616_UNORM */ break ;
Signature · 1 line
2.25.1
PATCH 2/14 drm/amd/display: 3.2.198
In reply to brichangFrom: Aric Cyr <[email protected]>
This version brings along following fixes:
-Fix edp panel missing event
-Set ARGB16161616 pixel format to 26
-Fix dcn32 interger issue
-Clear optc underflow bit after ODM clock off
-Fix issue with stereo3D
-Fix DML2 lightup issue
-Correct DTBCLK for dcn314
-Revert for a regression
-Fix clocks and bugs in DML2
-Enable SubVP by defalut on DCN32 & DCN321
-Corret boundary condition for engin ID on DCN303
-Fix FRL encoder override registry key
-Fix VPG for dcn314 HPO
-Fix Linux compile-time warning
-Add new prefetch modes in DML for DCN32
--- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -1
@@ -47,7 +47,7 @@ struct aux_payload;struct set_config_cmd_payload ;struct dmub_notification ; -#define DC_VER "3.2.197" +#define DC_VER "3.2.198"#define MAX_SURFACES 3#define MAX_PLANES 6
Signature · 1 line
2.25.1
PATCH 3/14 drm/amd/display: Fix pixel clock programming
In reply to brichangFrom: Ilya Bakoulin <[email protected]>
[Why]
Some pixel clock values could cause HDMI TMDS SSCPs to be misaligned between different HDMI lanes when using YCbCr420 10-bit pixel format.
BIOS functions for transmitter/encoder control take pixel clock in kHz increments, whereas the function for setting the pixel clock is in 100Hz increments. Setting pixel clock to a value that is not on a kHz boundary will cause the issue.
[How]
Round pixel clock down to nearest kHz in 10/12-bpc cases.
--- drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +2 -0
@@ -543,9 +543,11 @@ static void dce112_get_pix_clk_dividers_helper (switch (pix_clk_params->color_depth) {case COLOR_DEPTH_101010 : actual_pixel_clock_100hz = (actual_pixel_clock_100hz *5 ) >>2 ; + actual_pixel_clock_100hz -= actual_pixel_clock_100hz %10 ;break ;case COLOR_DEPTH_121212 : actual_pixel_clock_100hz = (actual_pixel_clock_100hz *6 ) >>2 ; + actual_pixel_clock_100hz -= actual_pixel_clock_100hz %10 ;break ;case COLOR_DEPTH_161616 : actual_pixel_clock_100hz = actual_pixel_clock_100hz *2 ;
Signature · 1 line
2.25.1
PATCH 4/14 Add reserved dc_log_type.
In reply to brichangFrom: Ian Chen <[email protected]>
--- drivers/gpu/drm/amd/display/include/logger_types.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/include/logger_types.h +3 -1
@@ -119,13 +119,15 @@ enum dc_log_type {LOG_HDMI_RETIMER_REDRIVER ,LOG_DSC ,LOG_SMU_MSG , +LOG_DC2RESERVED4 , +LOG_DC2RESERVED5 ,LOG_DWB ,LOG_GAMMA_DEBUG ,LOG_MAX_HW_POINTS ,LOG_ALL_TF_CHANNELS ,LOG_SAMPLE_1DLUT ,LOG_DP2 , -LOG_SECTION_TOTAL_COUNT + LOG_DC2RESERVED12, };#define DC_MIN_LOG_MASK ((1 << LOG_ERROR) | \
Signature · 1 line
2.25.1
PATCH 5/14 drm/amd/display: do not compare integers of different widths
In reply to brichangFrom: Josip Pavic <[email protected]>
[Why & How]
Increase width of some variables to avoid comparing integers of different widths.
--- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c +2 -1
@@ -331,7 +331,8 @@ static uint32_t dcn32_calculate_cab_allocation(struct dc *dc, struct dc_state *cbool dcn32_apply_idle_power_optimizations (struct dc *dc,bool enable) {union dmub_rb_cmd cmd; -uint8_t ways, i, j; +uint8_t ways, i; +int j;bool stereo_in_use = false;struct dc_plane_state *plane =NULL ;
Signature · 1 line
2.25.1
PATCH 6/14 drm/amd/display: add chip revision to DCN32
In reply to brichangFrom: Samson Tam <[email protected]>
[Why & How]
Add GC_11_0_3_A0 as a chip revision to the DCN32 family
--- drivers/gpu/drm/amd/display/include/dal_asic_id.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/include/dal_asic_id.h +3 -1
@@ -247,10 +247,12 @@ enum {#define AMDGPU_FAMILY_GC_11_0_1 148#define GC_11_0_0_A0 0x1#define GC_11_0_2_A0 0x10 +#define GC_11_0_3_A0 0x20#define GC_11_UNKNOWN 0xFF#define ASICREV_IS_GC_11_0_0 (eChipRev) (eChipRev < GC_11_0_2_A0) -#define ASICREV_IS_GC_11_0_2 (eChipRev) (eChipRev >= GC_11_0_2_A0 && eChipRev < GC_11_UNKNOWN) +#define ASICREV_IS_GC_11_0_2 (eChipRev) (eChipRev >= GC_11_0_2_A0 && eChipRev < GC_11_0_3_A0) +#define ASICREV_IS_GC_11_0_3 (eChipRev) (eChipRev >= GC_11_0_3_A0 && eChipRev < GC_11_UNKNOWN)/* * ASIC chip ID
Signature · 1 line
2.25.1
PATCH 7/14 drm/amd/display: Add debug parameter to retain default clock table
In reply to brichangFrom: Daniel Miess <[email protected]>
[Why]
Need a way to retain default clock table to aid
the investigation into why 8k@30 display not
lighting up on dcn314
[How]
Use flag to prevent execution of bw_params helper function and function for updating bw_bounding_box
--- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_clk_mgr.c | 2 +- drivers/gpu/drm/amd/display/dc/dc.h | 1 + drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_clk_mgr.c +1 -1
@@ -719,7 +719,7 @@ void dcn314_clk_mgr_construct(if (clk_mgr->base.base.ctx->dc->debug.pstate_enabled) {dcn314_get_dpm_table_from_smu (&clk_mgr->base, &smu_dpm_clks); -if (ctx->dc_bios && ctx->dc_bios->integrated_info) { +if (ctx->dc_bios && ctx->dc_bios->integrated_info && ctx->dc->config.use_default_clock_table == false) { dcn314_clk_mgr_helper_populate_bw_params( &clk_mgr->base, ctx->dc_bios->integrated_info,
drivers/gpu/drm/amd/display/dc/dc.h +1 -0
@@ -404,6 +404,7 @@ struct dc_config {bool use_pipe_ctx_sync_logic;bool ignore_dpref_ss;bool enable_mipi_converter_optimization; +bool use_default_clock_table; };enum visual_confirm {
drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c +1 -1
@@ -189,7 +189,7 @@ void dcn314_update_bw_bounding_box_fpu(struct dc *dc, struct clk_bw_params *bw_pdc_assert_fp_enabled ();// Default clock levels are used for diags, which may lead to overclocking. -if (!IS_DIAG_DC (dc->ctx->dce_environment)) { +if (!IS_DIAG_DC (dc->ctx->dce_environment) && dc->config.use_default_clock_table == false) { dcn3_14_ip.max_num_otg = dc->res_pool->res_cap->num_timing_generator; dcn3_14_ip.max_num_dpp = dc->res_pool->pipe_count;
Signature · 1 line
2.25.1
PATCH 8/14 drm/amd/display: Fix plug/unplug external monitor will hang while playback MPO video
In reply to brichangFrom: Tom Chung <[email protected]>
[Why]
Pipes for MPO primary and overlay will be power down and power up during plug/unplug external monitor while MPO video playback.
But the pipes were the same after plug/unplug and should not need to be power down and power up or it will make page flip interrupt disabled and cause hang issue.
[How]
Add pipe split change condition that not only check the top pipe pointer but also check the index of top pipe if both top pipes are available.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +9 -2
@@ -1077,8 +1077,15 @@ static void disable_dangling_plane(struct dc *dc, struct dc_state *context)struct dc_stream_state *old_stream = dc->current_state->res_ctx.pipe_ctx[i].stream;bool should_disable = true; -bool pipe_split_change = - context->res_ctx.pipe_ctx[i].top_pipe != dc->current_state->res_ctx.pipe_ctx[i].top_pipe; +bool pipe_split_change = false; + +if ((context->res_ctx.pipe_ctx[i].top_pipe) && + (dc->current_state->res_ctx.pipe_ctx[i].top_pipe)) + pipe_split_change = context->res_ctx.pipe_ctx[i].top_pipe->pipe_idx != + dc->current_state->res_ctx.pipe_ctx[i].top_pipe->pipe_idx; +else + pipe_split_change = context->res_ctx.pipe_ctx[i].top_pipe != + dc->current_state->res_ctx.pipe_ctx[i].top_pipe;for (j =0 ; j < context->stream_count; j++) {if (old_stream == context->streams[j]) {
Signature · 1 line
2.25.1
PATCH 9/14 drm/amd/display: Include scaling factor for SubVP command
In reply to brichangFrom: Alvin Lee <[email protected]>
[Description]
For SubVP scaling cases, we must include the scaling info as part of the cmd. This is required when converting OTG line to HUBP line for the MALL_START_LINE programming.
--- .../drm/amd/display/dc/basics/conversion.c | 21 +++++++++++++++++++ .../drm/amd/display/dc/basics/conversion.h | 3 +++ drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 11 ++++++++++ .../amd/display/dc/dcn321/dcn321_resource.c | 3 ++- 4 files changed, 37 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/basics/conversion.c +21 -0
@@ -100,3 +100,24 @@ void convert_float_matrix( matrix[i] = (uint16_t )reg_value; } } + +static uint32_t find_gcd (uint32_t a,uint32_t b) +{ +uint32_t remainder =0 ; +while (b !=0 ) { + remainder = a % b; + a = b; + b = remainder; + } +return a; +} + +void reduce_fraction (uint32_t num,uint32_t den, +uint32_t *out_num,uint32_t *out_den) +{ +uint32_t gcd =0 ; + + gcd =find_gcd (num, den); + *out_num = num / gcd; + *out_den = den / gcd; +}
drivers/gpu/drm/amd/display/dc/basics/conversion.h +3 -0
@@ -38,6 +38,9 @@ void convert_float_matrix(struct fixed31_32 *flt, uint32_t buffer_size); +void reduce_fraction (uint32_t num,uint32_t den, +uint32_t *out_num,uint32_t *out_den); +static inline unsigned int log_2 (unsigned int num) {return ilog2 (num);
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c +11 -0
@@ -29,6 +29,7 @@#include "dm_helpers.h" #include "dc_hw_types.h" #include "core_types.h" +#include "../basics/conversion.h" #define CTX dc_dmub_srv->ctx#define DC_LOGGER CTX->logger
@@ -600,6 +601,7 @@ static void populate_subvp_cmd_pipe_info(struct dc *dc, &cmd->fw_assisted_mclk_switch_v2.config_data.pipe_data[cmd_pipe_index];struct dc_crtc_timing *main_timing = &subvp_pipe->stream->timing;struct dc_crtc_timing *phantom_timing = &subvp_pipe->stream->mall_stream_config.paired_stream->timing; +uint32_t out_num, out_den; pipe_data->mode =SUBVP ; pipe_data->pipe_config.subvp_data.pix_clk_100hz = subvp_pipe->stream->timing.pix_clk_100hz;
@@ -613,6 +615,15 @@ static void populate_subvp_cmd_pipe_info(struct dc *dc, pipe_data->pipe_config.subvp_data.main_pipe_index = subvp_pipe->pipe_idx; pipe_data->pipe_config.subvp_data.is_drr = subvp_pipe->stream->ignore_msa_timing_param; +/* Calculate the scaling factor from the src and dst height. +* e.g. If 3840x2160 being downscaled to 1920x1080, the scaling factor is 1/2. +* Reduce the fraction 1080/2160 = 1/2 for the "scaling factor" +*/ +reduce_fraction (subvp_pipe->stream->src.height, subvp_pipe->stream->dst.height, &out_num, &out_den); +// TODO: Uncomment below lines once DMCUB include headers are promoted +//pipe_data->pipe_config.subvp_data.scale_factor_numerator = out_num; +//pipe_data->pipe_config.subvp_data.scale_factor_denominator = out_den; +// Prefetch lines is equal to VACTIVE + BP + VSYNC pipe_data->pipe_config.subvp_data.prefetch_lines = phantom_timing->v_total - phantom_timing->v_front_porch;
drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c +2 -1
@@ -1664,7 +1664,8 @@ static bool dcn321_resource_construct( dc->caps.subvp_prefetch_end_to_mall_start_us =15 ; dc->caps.subvp_swath_height_margin_lines =16 ; dc->caps.subvp_pstate_allow_width_us =20 ; - + dc->caps.subvp_vertical_int_margin_us =30 ; + dc->caps.max_slave_planes =1 ; dc->caps.max_slave_yuv_planes =1 ; dc->caps.max_slave_rgb_planes =1 ;
Signature · 1 line
2.25.1
PATCH 10/14 drm/amd/display: Modify header inclusion pattern
In reply to brichangFrom: Chaitanya Dhere <[email protected]>
[Why]
Recent backport from opensource broke the Nightly tool build that tests DC and DML for bugs and regressions. This was because the backport had a header inclusion that was not consistent with the AMD style of including headers was allowed to be merged back in DML code that caused tool compilation failures.
[How]
Modify the way in which the header file in included so that it is consistent with AMD style of including headers. This then automatically fixes the tool compilation process and also helps maintain the code quality and consistency.
--- drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c | 2 +- .../gpu/drm/amd/display/dc/dml/dcn31/display_rq_dlg_calc_31.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c +1 -1
@@ -26,7 +26,7 @@#include "dc.h" #include "dc_link.h" #include "../display_mode_lib.h" -#include "dml/dcn30/display_mode_vba_30.h" +#include "../dcn30/display_mode_vba_30.h" #include "display_mode_vba_31.h" #include "../dml_inline_defs.h"
drivers/gpu/drm/amd/display/dc/dml/dcn31/display_rq_dlg_calc_31.c +1 -1
@@ -27,7 +27,7 @@#include "../display_mode_vba.h" #include "../dml_inline_defs.h" #include "display_rq_dlg_calc_31.h" -#include "dml/dcn30/display_mode_vba_30.h" +#include "../dcn30/display_mode_vba_30.h" static bool is_dual_plane (enum source_format_class source_format) {
Signature · 1 line
2.25.1
PATCH 11/14 drm/amd/display: Update clock table policy for DCN314
In reply to brichangFrom: Nicholas Kazlauskas <[email protected]>
[Why & How]
Depending on how the clock table is constructed from PMFW we can run into issues where we don't think we have enough bandwidth available due to FCLK too low - eg. when the FCLK table contains invalid entries or a single entry.
We should always pick up the maximum clocks for each state as a final state in this case to prevent validation from failing if the table is malformed.
We should also contain sensible defaults in the case where values are invalid.
Redfine the clock table structures by adding a 314 prefix to make debugging these issues easier by avoiding symbol name clashes.
Overall this policy more closely aligns to how we did things for 315, but because of how the voltage rail is setup we should favor keeping DCFCLK low rather than DISPCLK or DPPCLK - so use the max for those in every entry.
--- .../dc/clk_mgr/dcn314/dcn314_clk_mgr.c | 186 ++++++++++++------ .../display/dc/clk_mgr/dcn314/dcn314_smu.h | 33 +++- 2 files changed, 154 insertions(+), 65 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_clk_mgr.c +122 -64
@@ -415,7 +415,7 @@ static struct wm_table lpddr5_wm_table = { } }; -static DpmClocks_t dummy_clocks; +static DpmClocks314_t dummy_clocks;static struct dcn314_watermarks dummy_wms = {0 };
@@ -500,7 +500,7 @@ static void dcn314_notify_wm_ranges(struct clk_mgr *clk_mgr_base)static void dcn314_get_dpm_table_from_smu (struct clk_mgr_internal *clk_mgr,struct dcn314_smu_dpm_clks *smu_dpm_clks) { -DpmClocks_t *table = smu_dpm_clks->dpm_clks; +DpmClocks314_t *table = smu_dpm_clks->dpm_clks;if (!clk_mgr->smu_ver)return ;
@@ -517,6 +517,26 @@ static void dcn314_get_dpm_table_from_smu(struct clk_mgr_internal *clk_mgr,dcn314_smu_transfer_dpm_table_smu_2_dram (clk_mgr); } +static inline bool is_valid_clock_value (uint32_t clock_value) +{ +return clock_value >1 && clock_value <100000 ; +} + +static unsigned int convert_wck_ratio (uint8_t wck_ratio) +{ +switch (wck_ratio) { +case WCK_RATIO_1_2 : +return 2 ; + +case WCK_RATIO_1_4 : +return 4 ; + +default : +break ; + } +return 1 ; +} +static uint32_t find_max_clk_value (const uint32_t clocks[],uint32_t num_clocks) {uint32_t max =0 ;
@@ -530,89 +550,127 @@ static uint32_t find_max_clk_value(const uint32_t clocks[], uint32_t num_clocks)return max; } -static unsigned int find_clk_for_voltage ( -const DpmClocks_t *clock_table, -const uint32_t clocks[], -unsigned int voltage) -{ -int i; -int max_voltage =0 ; -int clock =0 ; - -for (i =0 ; i <NUM_SOC_VOLTAGE_LEVELS ; i++) { -if (clock_table->SocVoltage[i] == voltage) { -return clocks[i]; - }else if (clock_table->SocVoltage[i] >= max_voltage && - clock_table->SocVoltage[i] < voltage) { - max_voltage = clock_table->SocVoltage[i]; - clock = clocks[i]; - } - } - -ASSERT (clock); -return clock; -} -static void dcn314_clk_mgr_helper_populate_bw_params (struct clk_mgr_internal *clk_mgr,struct integrated_info *bios_info, -const DpmClocks_t *clock_table) +const DpmClocks314_t *clock_table) { -int i, j;struct clk_bw_params *bw_params = clk_mgr->base.bw_params; -uint32_t max_dispclk =0 , max_dppclk =0 ; - - j =-1 ; - -ASSERT (NUM_DF_PSTATE_LEVELS <=MAX_NUM_DPM_LVL ); - -/* Find lowest DPM, FCLK is filled in reverse order*/ +struct clk_limit_table_entry def_max = bw_params->clk_table.entries[bw_params->clk_table.num_entries -1 ]; +uint32_t max_pstate =0 , max_fclk =0 , min_pstate =0 , max_dispclk =0 , max_dppclk =0 ; +int i; -for (i =NUM_DF_PSTATE_LEVELS -1 ; i >=0 ; i--) { -if (clock_table->DfPstateTable[i].FClk !=0 ) { - j = i; -break ; +/* Find highest valid fclk pstate */ +for (i =0 ; i < clock_table->NumDfPstatesEnabled; i++) { +if (is_valid_clock_value (clock_table->DfPstateTable[i].FClk) && + clock_table->DfPstateTable[i].FClk > max_fclk) { + max_fclk = clock_table->DfPstateTable[i].FClk; + max_pstate = i; } } -if (j ==-1 ) { -/* clock table is all 0s, just use our own hardcode */ -ASSERT (0 ); -return ; - } - - bw_params->clk_table.num_entries = j +1 ; +/* We expect the table to contain at least one valid fclk entry. */ +ASSERT (is_valid_clock_value (max_fclk)); -/* dispclk and dppclk can be max at any voltage, same number of levels for both */ +/* Dispclk and dppclk can be max at any voltage, same number of levels for both */ if (clock_table->NumDispClkLevelsEnabled <=NUM_DISPCLK_DPM_LEVELS && clock_table->NumDispClkLevelsEnabled <=NUM_DPPCLK_DPM_LEVELS ) { max_dispclk =find_max_clk_value (clock_table->DispClocks, clock_table->NumDispClkLevelsEnabled); max_dppclk =find_max_clk_value (clock_table->DppClocks, clock_table->NumDispClkLevelsEnabled); }else { +/* Invalid number of entries in the table from PMFW. */ ASSERT (0 ); } -for (i =0 ; i < bw_params->clk_table.num_entries; i++, j--) { - bw_params->clk_table.entries[i].fclk_mhz = clock_table->DfPstateTable[j].FClk; - bw_params->clk_table.entries[i].memclk_mhz = clock_table->DfPstateTable[j].MemClk; - bw_params->clk_table.entries[i].voltage = clock_table->DfPstateTable[j].Voltage; -switch (clock_table->DfPstateTable[j].WckRatio) { -case WCK_RATIO_1_2 : - bw_params->clk_table.entries[i].wck_ratio =2 ; -break ; -case WCK_RATIO_1_4 : - bw_params->clk_table.entries[i].wck_ratio =4 ; -break ; -default : - bw_params->clk_table.entries[i].wck_ratio =1 ; +/* Base the clock table on dcfclk, need at least one entry regardless of pmfw table */ +for (i =0 ; i < clock_table->NumDcfClkLevelsEnabled; i++) { +uint32_t min_fclk = clock_table->DfPstateTable[0 ].FClk; +int j; + +for (j =1 ; j < clock_table->NumDfPstatesEnabled; j++) { +if (is_valid_clock_value (clock_table->DfPstateTable[j].FClk) && + clock_table->DfPstateTable[j].FClk < min_fclk && + clock_table->DfPstateTable[j].Voltage <= clock_table->SocVoltage[i]) { + min_fclk = clock_table->DfPstateTable[j].FClk; + min_pstate = j; + } } - bw_params->clk_table.entries[i].dcfclk_mhz =find_clk_for_voltage (clock_table, clock_table->DcfClocks, clock_table->DfPstateTable[j].Voltage); - bw_params->clk_table.entries[i].socclk_mhz =find_clk_for_voltage (clock_table, clock_table->SocClocks, clock_table->DfPstateTable[j].Voltage); + +/* First search defaults for the clocks we don't read using closest lower or equal default dcfclk */ +for (j = bw_params->clk_table.num_entries -1 ; j >0 ; j--) +if (bw_params->clk_table.entries[j].dcfclk_mhz <= clock_table->DcfClocks[i]) +break ; + + bw_params->clk_table.entries[i].phyclk_mhz = bw_params->clk_table.entries[j].phyclk_mhz; + bw_params->clk_table.entries[i].phyclk_d18_mhz = bw_params->clk_table.entries[j].phyclk_d18_mhz; + bw_params->clk_table.entries[i].dtbclk_mhz = bw_params->clk_table.entries[j].dtbclk_mhz; + +/* Now update clocks we do read */ + bw_params->clk_table.entries[i].fclk_mhz = min_fclk; + bw_params->clk_table.entries[i].memclk_mhz = clock_table->DfPstateTable[min_pstate].MemClk; + bw_params->clk_table.entries[i].voltage = clock_table->DfPstateTable[min_pstate].Voltage; + bw_params->clk_table.entries[i].dcfclk_mhz = clock_table->DcfClocks[i]; + bw_params->clk_table.entries[i].socclk_mhz = clock_table->SocClocks[i]; + bw_params->clk_table.entries[i].dispclk_mhz = max_dispclk; + bw_params->clk_table.entries[i].dppclk_mhz = max_dppclk; + bw_params->clk_table.entries[i].wck_ratio =convert_wck_ratio ( + clock_table->DfPstateTable[min_pstate].WckRatio); + }; + +/* Make sure to include at least one entry at highest pstate */ +if (max_pstate != min_pstate || i ==0 ) { +if (i >MAX_NUM_DPM_LVL -1 ) + i =MAX_NUM_DPM_LVL -1 ; + + bw_params->clk_table.entries[i].fclk_mhz = max_fclk; + bw_params->clk_table.entries[i].memclk_mhz = clock_table->DfPstateTable[max_pstate].MemClk; + bw_params->clk_table.entries[i].voltage = clock_table->DfPstateTable[max_pstate].Voltage; + bw_params->clk_table.entries[i].dcfclk_mhz =find_max_clk_value (clock_table->DcfClocks,NUM_DCFCLK_DPM_LEVELS ); + bw_params->clk_table.entries[i].socclk_mhz =find_max_clk_value (clock_table->SocClocks,NUM_SOCCLK_DPM_LEVELS ); bw_params->clk_table.entries[i].dispclk_mhz = max_dispclk; bw_params->clk_table.entries[i].dppclk_mhz = max_dppclk; + bw_params->clk_table.entries[i].wck_ratio =convert_wck_ratio ( + clock_table->DfPstateTable[max_pstate].WckRatio); + i++; } + bw_params->clk_table.num_entries = i--; + +/* Make sure all highest clocks are included*/ + bw_params->clk_table.entries[i].socclk_mhz =find_max_clk_value (clock_table->SocClocks,NUM_SOCCLK_DPM_LEVELS ); + bw_params->clk_table.entries[i].dispclk_mhz =find_max_clk_value (clock_table->DispClocks,NUM_DISPCLK_DPM_LEVELS ); + bw_params->clk_table.entries[i].dppclk_mhz =find_max_clk_value (clock_table->DppClocks,NUM_DPPCLK_DPM_LEVELS ); +ASSERT (clock_table->DcfClocks[i] ==find_max_clk_value (clock_table->DcfClocks,NUM_DCFCLK_DPM_LEVELS )); + bw_params->clk_table.entries[i].phyclk_mhz = def_max.phyclk_mhz; + bw_params->clk_table.entries[i].phyclk_d18_mhz = def_max.phyclk_d18_mhz; + bw_params->clk_table.entries[i].dtbclk_mhz = def_max.dtbclk_mhz; +/* +* Set any 0 clocks to max default setting. Not an issue for +* power since we aren't doing switching in such case anyway +*/ +for (i =0 ; i < bw_params->clk_table.num_entries; i++) { +if (!bw_params->clk_table.entries[i].fclk_mhz) { + bw_params->clk_table.entries[i].fclk_mhz = def_max.fclk_mhz; + bw_params->clk_table.entries[i].memclk_mhz = def_max.memclk_mhz; + bw_params->clk_table.entries[i].voltage = def_max.voltage; + } +if (!bw_params->clk_table.entries[i].dcfclk_mhz) + bw_params->clk_table.entries[i].dcfclk_mhz = def_max.dcfclk_mhz; +if (!bw_params->clk_table.entries[i].socclk_mhz) + bw_params->clk_table.entries[i].socclk_mhz = def_max.socclk_mhz; +if (!bw_params->clk_table.entries[i].dispclk_mhz) + bw_params->clk_table.entries[i].dispclk_mhz = def_max.dispclk_mhz; +if (!bw_params->clk_table.entries[i].dppclk_mhz) + bw_params->clk_table.entries[i].dppclk_mhz = def_max.dppclk_mhz; +if (!bw_params->clk_table.entries[i].phyclk_mhz) + bw_params->clk_table.entries[i].phyclk_mhz = def_max.phyclk_mhz; +if (!bw_params->clk_table.entries[i].phyclk_d18_mhz) + bw_params->clk_table.entries[i].phyclk_d18_mhz = def_max.phyclk_d18_mhz; +if (!bw_params->clk_table.entries[i].dtbclk_mhz) + bw_params->clk_table.entries[i].dtbclk_mhz = def_max.dtbclk_mhz; + } +ASSERT (bw_params->clk_table.entries[i-1 ].dcfclk_mhz); bw_params->vram_type = bios_info->memory_type; - bw_params->num_channels = bios_info->ma_channel_number; + bw_params->num_channels = bios_info->ma_channel_number ? bios_info->ma_channel_number :4 ;for (i =0 ; i <WM_SET_COUNT ; i++) { bw_params->wm_table.entries[i].wm_inst = i;
@@ -671,10 +729,10 @@ void dcn314_clk_mgr_construct( }ASSERT (clk_mgr->smu_wm_set.wm_set); - smu_dpm_clks.dpm_clks = (DpmClocks_t *)dm_helpers_allocate_gpu_mem ( + smu_dpm_clks.dpm_clks = (DpmClocks314_t *)dm_helpers_allocate_gpu_mem ( clk_mgr->base.base.ctx,DC_MEM_ALLOC_TYPE_FRAME_BUFFER , -sizeof (DpmClocks_t), +sizeof (DpmClocks314_t), &smu_dpm_clks.mc_address.quad_part);if (smu_dpm_clks.dpm_clks ==NULL ) {
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_smu.h +32 -1
@@ -36,6 +36,37 @@ typedef enum {WCK_RATIO_MAX } WCK_RATIO_e; +typedef struct { +uint32_t FClk; +uint32_t MemClk; +uint32_t Voltage; +uint8_t WckRatio; +uint8_t Spare[3 ]; +}DfPstateTable314_t ; + +//Freq in MHz +//Voltage in milli volts with 2 fractional bits +typedef struct { +uint32_t DcfClocks[NUM_DCFCLK_DPM_LEVELS ]; +uint32_t DispClocks[NUM_DISPCLK_DPM_LEVELS ]; +uint32_t DppClocks[NUM_DPPCLK_DPM_LEVELS ]; +uint32_t SocClocks[NUM_SOCCLK_DPM_LEVELS ]; +uint32_t VClocks[NUM_VCN_DPM_LEVELS ]; +uint32_t DClocks[NUM_VCN_DPM_LEVELS ]; +uint32_t SocVoltage[NUM_SOC_VOLTAGE_LEVELS ]; +DfPstateTable314_t DfPstateTable[NUM_DF_PSTATE_LEVELS ]; + +uint8_t NumDcfClkLevelsEnabled; +uint8_t NumDispClkLevelsEnabled;//Applies to both Dispclk and Dppclk +uint8_t NumSocClkLevelsEnabled; +uint8_t VcnClkLevelsEnabled;//Applies to both Vclk and Dclk +uint8_t NumDfPstatesEnabled; +uint8_t spare[3 ]; + +uint32_t MinGfxClk; +uint32_t MaxGfxClk; +}DpmClocks314_t ; +struct dcn314_watermarks {// Watermarks WatermarkRowGeneric_t WatermarkRow[WM_COUNT ][NUM_WM_RANGES ];
@@ -43,7 +74,7 @@ struct dcn314_watermarks { };struct dcn314_smu_dpm_clks { -DpmClocks_t *dpm_clks; +DpmClocks314_t *dpm_clks;union large_integer mc_address; };
Signature · 1 line
2.25.1
PATCH 12/14 drm/amd/display: Don't set DSC for phantom pipes
In reply to brichangFrom: Alvin Lee <[email protected]>
[Description]
Don't set DSC bit for phantom pipes, not required since phantom pipe don't have any actual output
--- drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +1 -0
@@ -493,6 +493,7 @@ void dcn32_set_phantom_stream_timing(struct dc *dc, phantom_stream->timing.v_front_porch + phantom_stream->timing.v_sync_width + phantom_bp; + phantom_stream->timing.flags.DSC =0 ;// Don't need DSC for phantom timing }/**
Signature · 1 line
2.25.1
PATCH 13/14 drm/amd/display: Use pitch when calculating size to cache in MALL
In reply to brichangFrom: Alvin Lee <[email protected]>
[Description]
Use pitch when calculating size to cache in MALL
--- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c +1 -1
@@ -63,7 +63,7 @@ uint32_t dcn32_helper_calculate_num_ways_for_subvp(struct dc *dc, struct dc_statif (pipe->stream && pipe->plane_state && !pipe->top_pipe && pipe->stream->mall_stream_config.type ==SUBVP_PHANTOM ) { bytes_per_pixel = pipe->plane_state->format >=SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 ?8 :4 ; - mall_region_pixels = pipe->stream->timing.h_addressable * pipe->stream->timing.v_addressable; + mall_region_pixels = pipe->plane_state->plane_size.surface_pitch * pipe->stream->timing.v_addressable;// For bytes required in MALL, calculate based on number of MBlks required num_mblks = (mall_region_pixels * bytes_per_pixel +
Signature · 1 line
2.25.1
PATCH 14/14 drm/amd/display: avoid doing vm_init multiple time
In reply to brichangFrom: Charlene Liu <[email protected]>
[why]
this is to ensure that driver will not reprogram hvm_prefetch_req again if it is done.
--- drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c +7 -1
@@ -67,9 +67,15 @@ static uint32_t convert_and_clamp(void dcn21_dchvm_init (struct hubbub *hubbub) {struct dcn20_hubbub *hubbub1 =TO_DCN20_HUBBUB (hubbub); -uint32_t riommu_active; +uint32_t riommu_active, prefetch_done;int i; +REG_GET (DCHVM_RIOMMU_STAT0 ,HOSTVM_PREFETCH_DONE , &prefetch_done); + +if (prefetch_done) { + hubbub->riommu_active = true; +return ; + }//Init DCHVM block REG_UPDATE (DCHVM_CTRL0 ,HOSTVM_INIT_REQ ,1 );
Signature · 1 line
2.25.1