Commit ae88357c authored by Ilya Bakoulin's avatar Ilya Bakoulin Committed by Alex Deucher

drm/amd/display: Revert "Fix clock table filling logic"

[Why]
This change was found to break some high-refresh modes. Reverting
to unblock mainline.
Signed-off-by: default avatarIlya Bakoulin <Ilya.Bakoulin@amd.com>
Reviewed-by: default avatarSung Lee <Sung.Lee@amd.com>
Acked-by: default avatarStylon Wang <stylon.wang@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 24cc4f8d
...@@ -835,66 +835,47 @@ static struct wm_table lpddr4_wm_table_rn = { ...@@ -835,66 +835,47 @@ static struct wm_table lpddr4_wm_table_rn = {
} }
}; };
static unsigned int find_max_fclk_for_voltage(struct dpm_clocks *clock_table, static unsigned int find_socclk_for_voltage(struct dpm_clocks *clock_table, unsigned int voltage)
unsigned int voltage)
{ {
int i; int i;
uint32_t max_clk = 0;
for (i = 0; i < PP_SMU_NUM_FCLK_DPM_LEVELS; i++) { for (i = 0; i < PP_SMU_NUM_SOCCLK_DPM_LEVELS; i++) {
if (clock_table->FClocks[i].Vol <= voltage) { if (clock_table->SocClocks[i].Vol == voltage)
max_clk = clock_table->FClocks[i].Freq > max_clk ? return clock_table->SocClocks[i].Freq;
clock_table->FClocks[i].Freq : max_clk;
}
}
return max_clk;
}
static unsigned int find_max_memclk_for_voltage(struct dpm_clocks *clock_table,
unsigned int voltage)
{
int i;
uint32_t max_clk = 0;
for (i = 0; i < PP_SMU_NUM_MEMCLK_DPM_LEVELS; i++) {
if (clock_table->MemClocks[i].Vol <= voltage) {
max_clk = clock_table->MemClocks[i].Freq > max_clk ?
clock_table->MemClocks[i].Freq : max_clk;
}
} }
return max_clk; ASSERT(0);
return 0;
} }
static unsigned int find_max_socclk_for_voltage(struct dpm_clocks *clock_table, static unsigned int find_dcfclk_for_voltage(struct dpm_clocks *clock_table, unsigned int voltage)
unsigned int voltage)
{ {
int i; int i;
uint32_t max_clk = 0;
for (i = 0; i < PP_SMU_NUM_SOCCLK_DPM_LEVELS; i++) { for (i = 0; i < PP_SMU_NUM_DCFCLK_DPM_LEVELS; i++) {
if (clock_table->SocClocks[i].Vol <= voltage) { if (clock_table->DcfClocks[i].Vol == voltage)
max_clk = clock_table->SocClocks[i].Freq > max_clk ? return clock_table->DcfClocks[i].Freq;
clock_table->SocClocks[i].Freq : max_clk;
}
} }
return max_clk; ASSERT(0);
return 0;
} }
static void rn_clk_mgr_helper_populate_bw_params(struct clk_bw_params *bw_params, struct dpm_clocks *clock_table, struct integrated_info *bios_info) static void rn_clk_mgr_helper_populate_bw_params(struct clk_bw_params *bw_params, struct dpm_clocks *clock_table, struct integrated_info *bios_info)
{ {
int i, j = 0; int i, j = 0;
unsigned int volt;
j = -1; j = -1;
/* Find max DPM */ ASSERT(PP_SMU_NUM_FCLK_DPM_LEVELS <= MAX_NUM_DPM_LVL);
for (i = 0; i < PP_SMU_NUM_DCFCLK_DPM_LEVELS; ++i) {
if (clock_table->DcfClocks[i].Freq != 0 && /* Find lowest DPM, FCLK is filled in reverse order*/
clock_table->DcfClocks[i].Vol != 0)
for (i = PP_SMU_NUM_FCLK_DPM_LEVELS - 1; i >= 0; i--) {
if (clock_table->FClocks[i].Freq != 0 && clock_table->FClocks[i].Vol != 0) {
j = i; j = i;
break;
}
} }
if (j == -1) { if (j == -1) {
...@@ -905,18 +886,13 @@ static void rn_clk_mgr_helper_populate_bw_params(struct clk_bw_params *bw_params ...@@ -905,18 +886,13 @@ static void rn_clk_mgr_helper_populate_bw_params(struct clk_bw_params *bw_params
bw_params->clk_table.num_entries = j + 1; bw_params->clk_table.num_entries = j + 1;
for (i = 0; i < bw_params->clk_table.num_entries; i++) { for (i = 0; i < bw_params->clk_table.num_entries; i++, j--) {
volt = clock_table->DcfClocks[i].Vol; bw_params->clk_table.entries[i].fclk_mhz = clock_table->FClocks[j].Freq;
bw_params->clk_table.entries[i].memclk_mhz = clock_table->MemClocks[j].Freq;
bw_params->clk_table.entries[i].voltage = volt; bw_params->clk_table.entries[i].voltage = clock_table->FClocks[j].Vol;
bw_params->clk_table.entries[i].dcfclk_mhz = bw_params->clk_table.entries[i].dcfclk_mhz = find_dcfclk_for_voltage(clock_table, clock_table->FClocks[j].Vol);
clock_table->DcfClocks[i].Freq; bw_params->clk_table.entries[i].socclk_mhz = find_socclk_for_voltage(clock_table,
bw_params->clk_table.entries[i].fclk_mhz = bw_params->clk_table.entries[i].voltage);
find_max_fclk_for_voltage(clock_table, volt);
bw_params->clk_table.entries[i].memclk_mhz =
find_max_memclk_for_voltage(clock_table, volt);
bw_params->clk_table.entries[i].socclk_mhz =
find_max_socclk_for_voltage(clock_table, volt);
} }
bw_params->vram_type = bios_info->memory_type; bw_params->vram_type = bios_info->memory_type;
......
...@@ -1575,12 +1575,10 @@ static struct _vcs_dpi_voltage_scaling_st construct_low_pstate_lvl(struct clk_li ...@@ -1575,12 +1575,10 @@ static struct _vcs_dpi_voltage_scaling_st construct_low_pstate_lvl(struct clk_li
low_pstate_lvl.phyclk_d18_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].phyclk_d18_mhz; low_pstate_lvl.phyclk_d18_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].phyclk_d18_mhz;
low_pstate_lvl.phyclk_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].phyclk_mhz; low_pstate_lvl.phyclk_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].phyclk_mhz;
if (clk_table->num_entries < MAX_NUM_DPM_LVL) { for (i = clk_table->num_entries; i > 1; i--)
for (i = clk_table->num_entries; i > 1; i--) clk_table->entries[i] = clk_table->entries[i-1];
clk_table->entries[i] = clk_table->entries[i-1]; clk_table->entries[1] = clk_table->entries[0];
clk_table->entries[1] = clk_table->entries[0]; clk_table->num_entries++;
clk_table->num_entries++;
}
return low_pstate_lvl; return low_pstate_lvl;
} }
...@@ -1612,6 +1610,10 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param ...@@ -1612,6 +1610,10 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param
} }
} }
/* clk_table[1] is reserved for min DF PState. skip here to fill in later. */
if (i == 1)
k++;
clock_limits[k].state = k; clock_limits[k].state = k;
clock_limits[k].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz; clock_limits[k].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
clock_limits[k].fabricclk_mhz = clk_table->entries[i].fclk_mhz; clock_limits[k].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
...@@ -1628,25 +1630,14 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param ...@@ -1628,25 +1630,14 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param
k++; k++;
} }
for (i = 0; i < clk_table->num_entries + 1; i++)
if (clk_table->num_entries >= MAX_NUM_DPM_LVL) { dcn2_1_soc.clock_limits[i] = clock_limits[i];
for (i = 0; i < clk_table->num_entries + 1; i++)
dcn2_1_soc.clock_limits[i] = clock_limits[i];
} else {
dcn2_1_soc.clock_limits[0] = clock_limits[0];
for (i = 2; i < clk_table->num_entries + 1; i++) {
dcn2_1_soc.clock_limits[i] = clock_limits[i - 1];
dcn2_1_soc.clock_limits[i].state = i;
}
}
if (clk_table->num_entries) { if (clk_table->num_entries) {
dcn2_1_soc.num_states = clk_table->num_entries + 1;
/* fill in min DF PState */ /* fill in min DF PState */
dcn2_1_soc.clock_limits[1] = construct_low_pstate_lvl(clk_table, closest_clk_lvl); dcn2_1_soc.clock_limits[1] = construct_low_pstate_lvl(clk_table, closest_clk_lvl);
dcn2_1_soc.num_states = clk_table->num_entries;
/* duplicate last level */ /* duplicate last level */
dcn2_1_soc.clock_limits[dcn2_1_soc.num_states] = dcn2_1_soc.clock_limits[dcn2_1_soc.num_states] = dcn2_1_soc.clock_limits[dcn2_1_soc.num_states - 1];
dcn2_1_soc.clock_limits[dcn2_1_soc.num_states - 1];
dcn2_1_soc.clock_limits[dcn2_1_soc.num_states].state = dcn2_1_soc.num_states; dcn2_1_soc.clock_limits[dcn2_1_soc.num_states].state = dcn2_1_soc.num_states;
} }
......
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