Commit 853dc075 authored by Rex Zhu's avatar Rex Zhu Committed by Greg Kroah-Hartman

drm/amd/pp: Fix truncated clock value when set watermark

[ Upstream commit 4d454e9f ]

the clk value should be tranferred to MHz first and
then transfer to uint16. otherwise, the clock value
will be truncated.
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reported-by: default avatarHersen Wu <hersenxs.wu@amd.com>
Signed-off-by: default avatarRex Zhu <Rex.Zhu@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5faabd22
...@@ -669,20 +669,20 @@ int smu_set_watermarks_for_clocks_ranges(void *wt_table, ...@@ -669,20 +669,20 @@ int smu_set_watermarks_for_clocks_ranges(void *wt_table,
for (i = 0; i < wm_with_clock_ranges->num_wm_dmif_sets; i++) { for (i = 0; i < wm_with_clock_ranges->num_wm_dmif_sets; i++) {
table->WatermarkRow[1][i].MinClock = table->WatermarkRow[1][i].MinClock =
cpu_to_le16((uint16_t) cpu_to_le16((uint16_t)
(wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_min_dcfclk_clk_in_khz) / (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_min_dcfclk_clk_in_khz /
1000); 1000));
table->WatermarkRow[1][i].MaxClock = table->WatermarkRow[1][i].MaxClock =
cpu_to_le16((uint16_t) cpu_to_le16((uint16_t)
(wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_max_dcfclk_clk_in_khz) / (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_max_dcfclk_clk_in_khz /
1000); 1000));
table->WatermarkRow[1][i].MinUclk = table->WatermarkRow[1][i].MinUclk =
cpu_to_le16((uint16_t) cpu_to_le16((uint16_t)
(wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_min_mem_clk_in_khz) / (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_min_mem_clk_in_khz /
1000); 1000));
table->WatermarkRow[1][i].MaxUclk = table->WatermarkRow[1][i].MaxUclk =
cpu_to_le16((uint16_t) cpu_to_le16((uint16_t)
(wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_max_mem_clk_in_khz) / (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_max_mem_clk_in_khz /
1000); 1000));
table->WatermarkRow[1][i].WmSetting = (uint8_t) table->WatermarkRow[1][i].WmSetting = (uint8_t)
wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_set_id; wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_set_id;
} }
...@@ -690,20 +690,20 @@ int smu_set_watermarks_for_clocks_ranges(void *wt_table, ...@@ -690,20 +690,20 @@ int smu_set_watermarks_for_clocks_ranges(void *wt_table,
for (i = 0; i < wm_with_clock_ranges->num_wm_mcif_sets; i++) { for (i = 0; i < wm_with_clock_ranges->num_wm_mcif_sets; i++) {
table->WatermarkRow[0][i].MinClock = table->WatermarkRow[0][i].MinClock =
cpu_to_le16((uint16_t) cpu_to_le16((uint16_t)
(wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_min_socclk_clk_in_khz) / (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_min_socclk_clk_in_khz /
1000); 1000));
table->WatermarkRow[0][i].MaxClock = table->WatermarkRow[0][i].MaxClock =
cpu_to_le16((uint16_t) cpu_to_le16((uint16_t)
(wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_max_socclk_clk_in_khz) / (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_max_socclk_clk_in_khz /
1000); 1000));
table->WatermarkRow[0][i].MinUclk = table->WatermarkRow[0][i].MinUclk =
cpu_to_le16((uint16_t) cpu_to_le16((uint16_t)
(wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_min_mem_clk_in_khz) / (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_min_mem_clk_in_khz /
1000); 1000));
table->WatermarkRow[0][i].MaxUclk = table->WatermarkRow[0][i].MaxUclk =
cpu_to_le16((uint16_t) cpu_to_le16((uint16_t)
(wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_max_mem_clk_in_khz) / (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_max_mem_clk_in_khz /
1000); 1000));
table->WatermarkRow[0][i].WmSetting = (uint8_t) table->WatermarkRow[0][i].WmSetting = (uint8_t)
wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_set_id; wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_set_id;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment