drm/amd/display: Initialize missing TD-LUT programming inputs
PATCH 1/1 drm/amd/display: Initialize missing TD-LUT programming inputs
dml_core_mode_programming() memsets (clears) its scratch structure before calculating TD-LUT settings, but does not initialize tdlut_mpc_width_flag or is_gfx11.
Both inputs therefore remain false regardless of the plane configuration which can result in incorrect calculations.
Initialize both fields using the same sources as the mode support path (now both paths are aligned).
--- .../dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn4_calcs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn4_calcs.c +2 -0
@@ -11074,6 +11074,8 @@ static bool dml_core_mode_programming(struct dml2_core_calcs_mode_programming_ex calculate_tdlut_setting_params->cursor_buffer_size = mode_lib->ip.cursor_buffer_size; calculate_tdlut_setting_params->gpuvm_enable = display_cfg->gpuvm_enable; calculate_tdlut_setting_params->gpuvm_page_size_kbytes = display_cfg->plane_descriptors[k].overrides.gpuvm_min_page_size_kbytes; + calculate_tdlut_setting_params->tdlut_mpc_width_flag = display_cfg->plane_descriptors[k].tdlut.tdlut_mpc_width_flag; + calculate_tdlut_setting_params->is_gfx11 =dml_get_gfx_version (display_cfg->plane_descriptors[k].surface.tiling);// output calculate_tdlut_setting_params->tdlut_pte_bytes_per_frame = &s->tdlut_pte_bytes_per_frame[k];
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] amd/display: Implicit cast of unsigned int to bool in is_gfx11 breaks GFX12 --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] amd/display: Implicit cast of unsigned int to bool in is_gfx11 breaks GFX12 --
commit 6cadd8de043129ed240d5c445ed5c65b848832cc
Author: Avi Weiss <[email protected]>
drm/amd/display: Initialize missing TD-LUT programming inputs
This commit aligns the mode programming path with the mode support path by explicitly initializing tdlut_mpc_width_flag and is_gfx11 inputs in dml_core_mode_programming() for DCN401 sources.
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn4_calcs.c static bool dml_core_mode_programming(struct dml2_core_calcs_mode_programming_ex · line 11056
Quoted 9 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn4_calcs.c +2
-0@@ -11052,6 +11052,8 @@ static bool dml_core_mode_programming(struct dml2_core_calcs_mode_programming_ex calculate_tdlut_setting_params->cursor_buffer_size = mode_lib->ip.cursor_buffer_size; calculate_tdlut_setting_params->gpuvm_enable = display_cfg->gpuvm_enable; calculate_tdlut_setting_params->gpuvm_page_size_kbytes = display_cfg->plane_descriptors[k].overrides.gpuvm_min_page_size_kbytes; + calculate_tdlut_setting_params->tdlut_mpc_width_flag = display_cfg->plane_descriptors[k].tdlut.tdlut_mpc_width_flag; + calculate_tdlut_setting_params->is_gfx11 =dml_get_gfx_version (display_cfg->plane_descriptors[k].surface.tiling);
[Severity: High]
This problem wasn't introduced by this patch, but it appears this copies an existing bug from dml_core_mode_support() into dml_core_mode_programming().
Looking at dml_get_gfx_version(), it returns an unsigned int 12 for GFX12 swizzle modes. When this result is assigned directly to the boolean field is_gfx11, it will evaluate to true because any non-zero integer is true in C.
Could this cause GFX12 hardware to incorrectly use GFX11 TD-LUT pitch alignment (like 256B instead of 128B), leading to display corruption?
Would it be better to use an explicit equality check here and in the mode support path, such as:is_gfx11 = (dml_get_gfx_version(...) == 11);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 4 lines · Avi Weiss
dml_core_mode_programming()memsets (clears) its scratch structure before calculating TD-LUT settings, but does not initializetdlut_mpc_width_flagoris_gfx11.
Quoted 8 lines
Both inputs therefore remain false regardless of the plane configuration which can result in incorrect calculations.
Initialize both fields using the same sources as the mode support path (now both paths are aligned).
Fixes 70839da63605 ("drm/amd/display: Add new DCN401 sources")Signed-off-by Avi Weiss <[email protected]>
The issue sashiko found is also a real problem but somewhat unrelated.
Harry
Quoted 17 lines
--- .../dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn4_calcs.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn4_calcs.c +2
-0@@ -11074,6 +11074,8 @@ static bool dml_core_mode_programming(struct dml2_core_calcs_mode_programming_ex calculate_tdlut_setting_params->cursor_buffer_size = mode_lib->ip.cursor_buffer_size; calculate_tdlut_setting_params->gpuvm_enable = display_cfg->gpuvm_enable; calculate_tdlut_setting_params->gpuvm_page_size_kbytes = display_cfg->plane_descriptors[k].overrides.gpuvm_min_page_size_kbytes; + calculate_tdlut_setting_params->tdlut_mpc_width_flag = display_cfg->plane_descriptors[k].tdlut.tdlut_mpc_width_flag; + calculate_tdlut_setting_params->is_gfx11 =dml_get_gfx_version (display_cfg->plane_descriptors[k].surface.tiling);// output calculate_tdlut_setting_params->tdlut_pte_bytes_per_frame = &s->tdlut_pte_bytes_per_frame[k];