Skip to content

Commit

Permalink
amdgpu/pm: Fix incorrect variable for size of clocks array
Browse files Browse the repository at this point in the history
 [v2]
No Changes, added RB
 [v1]
Size of pp_clock_levels_with_latency is PP_MAX_CLOCK_LEVELS, not MAX_NUM_CLOCKS.
Both are currently defined as 16, modifying in case one value is modified in future
Changed code in both arcturus and aldabaran.

Also removed unneeded var count, and used min_t function

Signed-off-by: Darren Powell <darren.powell@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Darren Powell authored and Alex Deucher committed Jun 22, 2022
1 parent ab8529b commit 543faf5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,13 @@ static int arcturus_get_clk_table(struct smu_context *smu,
struct pp_clock_levels_with_latency *clocks,
struct smu_11_0_dpm_table *dpm_table)
{
int i, count;
uint32_t i;

count = (dpm_table->count > MAX_NUM_CLOCKS) ? MAX_NUM_CLOCKS : dpm_table->count;
clocks->num_levels = count;
clocks->num_levels = min_t(uint32_t,
dpm_table->count,
(uint32_t)PP_MAX_CLOCK_LEVELS);

for (i = 0; i < count; i++) {
for (i = 0; i < clocks->num_levels; i++) {
clocks->data[i].clocks_in_khz =
dpm_table->dpm_levels[i].value * 1000;
clocks->data[i].latency_in_us = 0;
Expand Down
9 changes: 5 additions & 4 deletions drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,13 @@ static int aldebaran_get_clk_table(struct smu_context *smu,
struct pp_clock_levels_with_latency *clocks,
struct smu_13_0_dpm_table *dpm_table)
{
int i, count;
uint32_t i;

count = (dpm_table->count > MAX_NUM_CLOCKS) ? MAX_NUM_CLOCKS : dpm_table->count;
clocks->num_levels = count;
clocks->num_levels = min_t(uint32_t,
dpm_table->count,
(uint32_t)PP_MAX_CLOCK_LEVELS);

for (i = 0; i < count; i++) {
for (i = 0; i < clocks->num_levels; i++) {
clocks->data[i].clocks_in_khz =
dpm_table->dpm_levels[i].value * 1000;
clocks->data[i].latency_in_us = 0;
Expand Down

0 comments on commit 543faf5

Please sign in to comment.