drm/amd/display: fix array lenth error.
Subsystems (3)
PATCH 1/2 drm/amd/display: fix array lenth error.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +2 -2
@@ -358,7 +358,7 @@ bool dm_pp_get_clock_levels_by_type(* non-boosted one. */ DRM_INFO ("DM_PPLIB: reducing engine clock level from %d to %d\n" , dc_clks->num_levels, i +1 ); - dc_clks->num_levels = i; + dc_clks->num_levels = i +1 ;break ; } }
@@ -367,7 +367,7 @@ bool dm_pp_get_clock_levels_by_type(if (dc_clks->clocks_in_khz[i] > validation_clks.memory_max_clock) {DRM_INFO ("DM_PPLIB: reducing memory clock level from %d to %d\n" , dc_clks->num_levels, i +1 ); - dc_clks->num_levels = i; + dc_clks->num_levels = i +1 ;break ; } }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amd/powerplay: refine code to avoid potential bug that the memory not cleared.
In reply to a message not in the archive--- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +7 -10
@@ -4397,16 +4397,14 @@ static int smu7_get_sclks(struct pp_hwmgr *hwmgr, struct amd_pp_clocks *clocks)if (table_info ==NULL || table_info->vdd_dep_on_sclk ==NULL )return -EINVAL ; dep_sclk_table = table_info->vdd_dep_on_sclk; -for (i =0 ; i < dep_sclk_table->count; i++) { +for (i =0 ; i < dep_sclk_table->count; i++) clocks->clock[i] = dep_sclk_table->entries[i].clk; - clocks->count++; - } + clocks->count = dep_sclk_table->count; }else if (hwmgr->pp_table_version ==PP_TABLE_V0 ) { sclk_table = hwmgr->dyn_state.vddc_dependency_on_sclk; -for (i =0 ; i < sclk_table->count; i++) { +for (i =0 ; i < sclk_table->count; i++) clocks->clock[i] = sclk_table->entries[i].clk; - clocks->count++; - } + clocks->count = sclk_table->count; }return 0 ;
@@ -4440,14 +4438,13 @@ static int smu7_get_mclks(struct pp_hwmgr *hwmgr, struct amd_pp_clocks *clocks) clocks->clock[i] = dep_mclk_table->entries[i].clk; clocks->latency[i] =smu7_get_mem_latency (hwmgr, dep_mclk_table->entries[i].clk); - clocks->count++; } + clocks->count = dep_mclk_table->count; }else if (hwmgr->pp_table_version ==PP_TABLE_V0 ) { mclk_table = hwmgr->dyn_state.vddc_dependency_on_mclk; -for (i =0 ; i < mclk_table->count; i++) { +for (i =0 ; i < mclk_table->count; i++) clocks->clock[i] = mclk_table->entries[i].clk; - clocks->count++; - } + clocks->count = mclk_table->count }return 0 ; }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 2/2] drm/amd/powerplay: refine code to avoid potential bug that the memory not cleared.
In reply to a message not in the archive+ clocks->count = mclk_table->count
Missing semicolon. Will fix in V2.
Best Regards
Rex
-----Original Message-----
From: Rex Zhu [mailto:[email protected]]
Sent: Monday, February 06, 2017 1:09 PM
To: [email protected]
Cc: Zhu, Rex
Subject: [PATCH 2/2] drm/amd/powerplay: refine code to avoid potential bug that the memory not cleared.
--- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +7 -10
@@ -4397,16 +4397,14 @@ static int smu7_get_sclks(struct pp_hwmgr *hwmgr, struct amd_pp_clocks *clocks)if (table_info ==NULL || table_info->vdd_dep_on_sclk ==NULL )return -EINVAL ; dep_sclk_table = table_info->vdd_dep_on_sclk; -for (i =0 ; i < dep_sclk_table->count; i++) { +for (i =0 ; i < dep_sclk_table->count; i++) clocks->clock[i] = dep_sclk_table->entries[i].clk; - clocks->count++; - } + clocks->count = dep_sclk_table->count; }else if (hwmgr->pp_table_version ==PP_TABLE_V0 ) { sclk_table = hwmgr->dyn_state.vddc_dependency_on_sclk; -for (i =0 ; i < sclk_table->count; i++) { +for (i =0 ; i < sclk_table->count; i++) clocks->clock[i] = sclk_table->entries[i].clk; - clocks->count++; - } + clocks->count = sclk_table->count; }return 0 ;
@@ -4440,14 +4438,13 @@ static int smu7_get_mclks(struct pp_hwmgr *hwmgr, struct amd_pp_clocks *clocks) clocks->clock[i] = dep_mclk_table->entries[i].clk; clocks->latency[i] =smu7_get_mem_latency (hwmgr, dep_mclk_table->entries[i].clk); - clocks->count++; } + clocks->count = dep_mclk_table->count; }else if (hwmgr->pp_table_version ==PP_TABLE_V0 ) { mclk_table = hwmgr->dyn_state.vddc_dependency_on_mclk; -for (i =0 ; i < mclk_table->count; i++) { +for (i =0 ; i < mclk_table->count; i++) clocks->clock[i] = mclk_table->entries[i].clk; - clocks->count++; - } + clocks->count = mclk_table->count }return 0 ; }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 11 lines · Rex Zhu
Change-Id I09011c5e6d5493db7e3d9a7ff7ab8c871a8db862Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +0
-0
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c bool dm_pp_get_clock_levels_by_type( · line 361
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +1
-1@@ -358,7 +358,7 @@ bool dm_pp_get_clock_levels_by_type(* non-boosted one. */ DRM_INFO ("DM_PPLIB: reducing engine clock level from %d to %d\n" , dc_clks->num_levels, i +1 ); - dc_clks->num_levels = i; + dc_clks->num_levels = i +1 ;
It seems to me the DRM_INFO print is wrong here, not the actual assignment. We're setting num_levels to the current index if the clocks for that index are higher than the max validation clocks, hence this index now should become num_levels.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c bool dm_pp_get_clock_levels_by_type( · line 373
Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +1
-1break ; } }@@ -367,7 +367,7 @@ bool dm_pp_get_clock_levels_by_type(if (dc_clks->clocks_in_khz[i] > validation_clks.memory_max_clock) {DRM_INFO ("DM_PPLIB: reducing memory clock level from %d to %d\n" , dc_clks->num_levels, i +1 ); - dc_clks->num_levels = i; + dc_clks->num_levels = i +1 ;break ; } }
Same comment as above.
Harry
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
seems reasonable.
but i think need to check num_levels can't be 0. in some case, there is only one level of mclk, and higher than the max validation clocks.. and will lead kernel panic.
Best Regards
Rex
________________________________
From: Wentland, Harry
Sent: Monday, February 6, 2017 10:54:24 PM
To: Zhu, Rex; [email protected]
Subject: Re: [PATCH 1/2] drm/amd/display: fix array lenth error.
Quoted 11 lines · Rex Zhu
Change-Id I09011c5e6d5493db7e3d9a7ff7ab8c871a8db862Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +0
-0
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c bool dm_pp_get_clock_levels_by_type( · line 361
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +1
-1@@ -358,7 +358,7 @@ bool dm_pp_get_clock_levels_by_type(* non-boosted one. */ DRM_INFO ("DM_PPLIB: reducing engine clock level from %d to %d\n" , dc_clks->num_levels, i +1 ); - dc_clks->num_levels = i; + dc_clks->num_levels = i +1 ;
It seems to me the DRM_INFO print is wrong here, not the actual assignment. We're setting num_levels to the current index if the clocks for that index are higher than the max validation clocks, hence this index now should become num_levels.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c bool dm_pp_get_clock_levels_by_type( · line 373
Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +1
-1break ; } }@@ -367,7 +367,7 @@ bool dm_pp_get_clock_levels_by_type(if (dc_clks->clocks_in_khz[i] > validation_clks.memory_max_clock) {DRM_INFO ("DM_PPLIB: reducing memory clock level from %d to %d\n" , dc_clks->num_levels, i +1 ); - dc_clks->num_levels = i; + dc_clks->num_levels = i +1 ;break ; } }
Same comment as above.
Harry
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
True, we should probably always keep one level even if it's larger than max_clock, but output a big fat warning message when that happens.
Harry
Quoted 57 lines · Rex
seems reasonable.
but i think need to check
num_levelscan't be 0. in some case, there is only one level of mclk, and higher than the max validation clocks.. and will lead kernel panic.Best Regards
Rex
------------------------------------------------------------------------
*From:* Wentland, Harry
*Sent:* Monday, February 6, 2017 10:54:24 PM
*To:* Zhu, Rex; [email protected] *Subject:* Re: [PATCH 1/2] drm/amd/display: fix array lenth error.Quoted 11 lines · Rex Zhu
Change-Id I09011c5e6d5493db7e3d9a7ff7ab8c871a8db862Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +0
-0drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c bool dm_pp_get_clock_levels_by_type( · line 361
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +1
-1@@ -358,7 +358,7 @@ bool dm_pp_get_clock_levels_by_type(* non-boosted one. */ DRM_INFO ("DM_PPLIB: reducing engine clock level from %d to %d\n" , dc_clks->num_levels, i +1 ); - dc_clks->num_levels = i; + dc_clks->num_levels = i +1 ;It seems to me the
DRM_INFOprint is wrong here, not the actual assignment. We're settingnum_levelsto the current index if the clocks for that index are higher than the max validation clocks, hence this index now should becomenum_levels.drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c bool dm_pp_get_clock_levels_by_type( · line 373
Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c +1
-1break ; } }@@ -367,7 +367,7 @@ bool dm_pp_get_clock_levels_by_type(if (dc_clks->clocks_in_khz[i] > validation_clks.memory_max_clock) {DRM_INFO ("DM_PPLIB: reducing memory clock level from %d to %d\n" , dc_clks->num_levels, i +1 ); - dc_clks->num_levels = i; + dc_clks->num_levels = i +1 ;break ; } }Same comment as above.
Quoted 1 line
Harry
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx