Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

amdgpu/pm: Fix incorrect variable for size of clocks array

[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>

authored by

Darren Powell and committed by
Alex Deucher
543faf57 ab8529b0

+10 -8
+5 -4
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
··· 573 573 struct pp_clock_levels_with_latency *clocks, 574 574 struct smu_11_0_dpm_table *dpm_table) 575 575 { 576 - int i, count; 576 + uint32_t i; 577 577 578 - count = (dpm_table->count > MAX_NUM_CLOCKS) ? MAX_NUM_CLOCKS : dpm_table->count; 579 - clocks->num_levels = count; 578 + clocks->num_levels = min_t(uint32_t, 579 + dpm_table->count, 580 + (uint32_t)PP_MAX_CLOCK_LEVELS); 580 581 581 - for (i = 0; i < count; i++) { 582 + for (i = 0; i < clocks->num_levels; i++) { 582 583 clocks->data[i].clocks_in_khz = 583 584 dpm_table->dpm_levels[i].value * 1000; 584 585 clocks->data[i].latency_in_us = 0;
+5 -4
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
··· 555 555 struct pp_clock_levels_with_latency *clocks, 556 556 struct smu_13_0_dpm_table *dpm_table) 557 557 { 558 - int i, count; 558 + uint32_t i; 559 559 560 - count = (dpm_table->count > MAX_NUM_CLOCKS) ? MAX_NUM_CLOCKS : dpm_table->count; 561 - clocks->num_levels = count; 560 + clocks->num_levels = min_t(uint32_t, 561 + dpm_table->count, 562 + (uint32_t)PP_MAX_CLOCK_LEVELS); 562 563 563 - for (i = 0; i < count; i++) { 564 + for (i = 0; i < clocks->num_levels; i++) { 564 565 clocks->data[i].clocks_in_khz = 565 566 dpm_table->dpm_levels[i].value * 1000; 566 567 clocks->data[i].latency_in_us = 0;