Skip to content

Commit 6eb3f7d

Browse files
Dmytro Laktyushkinalexdeucher
authored andcommitted
drm/amd/display: fix rn soc bb update
Currently RN SOC bounding box update assumes we will get at least 2 clock states from SMU. This isn't always true and because of special casing on first clock state we end up with low disp, dpp, dsc and phy clocks. This change removes the special casing allowing the first state to acquire correct clocks. Signed-off-by: Dmytro Laktyushkin <[email protected]> Reviewed-by: Eric Yang <[email protected]> Acked-by: Aurabindo Pillai <[email protected]> Acked-by: Tony Cheng <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 3159d41 commit 6eb3f7d

File tree

1 file changed

+28
-43
lines changed

1 file changed

+28
-43
lines changed

drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,64 +1374,49 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param
13741374
{
13751375
struct dcn21_resource_pool *pool = TO_DCN21_RES_POOL(dc->res_pool);
13761376
struct clk_limit_table *clk_table = &bw_params->clk_table;
1377-
unsigned int i, j, k;
1378-
int closest_clk_lvl;
1377+
struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES];
1378+
unsigned int i, j, closest_clk_lvl;
13791379

13801380
// Default clock levels are used for diags, which may lead to overclocking.
1381-
if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) && !IS_DIAG_DC(dc->ctx->dce_environment)) {
1381+
if (!IS_DIAG_DC(dc->ctx->dce_environment)) {
13821382
dcn2_1_ip.max_num_otg = pool->base.res_cap->num_timing_generator;
13831383
dcn2_1_ip.max_num_dpp = pool->base.pipe_count;
13841384
dcn2_1_soc.num_chans = bw_params->num_channels;
13851385

1386-
/* Vmin: leave lowest DCN clocks, override with dcfclk, fclk, memclk from fuse */
1387-
dcn2_1_soc.clock_limits[0].state = 0;
1388-
dcn2_1_soc.clock_limits[0].dcfclk_mhz = clk_table->entries[0].dcfclk_mhz;
1389-
dcn2_1_soc.clock_limits[0].fabricclk_mhz = clk_table->entries[0].fclk_mhz;
1390-
dcn2_1_soc.clock_limits[0].socclk_mhz = clk_table->entries[0].socclk_mhz;
1391-
dcn2_1_soc.clock_limits[0].dram_speed_mts = clk_table->entries[0].memclk_mhz * 2;
1392-
1393-
/*
1394-
* Other levels: find closest DCN clocks that fit the given clock limit using dcfclk
1395-
* as indicator
1396-
*/
1397-
1398-
closest_clk_lvl = -1;
1399-
/* index currently being filled */
1400-
k = 1;
1401-
for (i = 1; i < clk_table->num_entries; i++) {
1402-
/* loop backwards, skip duplicate state*/
1403-
for (j = dcn2_1_soc.num_states - 1; j >= k; j--) {
1386+
ASSERT(clk_table->num_entries);
1387+
for (i = 0; i < clk_table->num_entries; i++) {
1388+
/* loop backwards*/
1389+
for (closest_clk_lvl = 0, j = dcn2_1_soc.num_states - 1; j >= 0; j--) {
14041390
if ((unsigned int) dcn2_1_soc.clock_limits[j].dcfclk_mhz <= clk_table->entries[i].dcfclk_mhz) {
14051391
closest_clk_lvl = j;
14061392
break;
14071393
}
14081394
}
14091395

1410-
/* if found a lvl that fits, use the DCN clks from it, if not, go to next clk limit*/
1411-
if (closest_clk_lvl != -1) {
1412-
dcn2_1_soc.clock_limits[k].state = i;
1413-
dcn2_1_soc.clock_limits[k].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
1414-
dcn2_1_soc.clock_limits[k].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
1415-
dcn2_1_soc.clock_limits[k].socclk_mhz = clk_table->entries[i].socclk_mhz;
1416-
dcn2_1_soc.clock_limits[k].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2;
1417-
1418-
dcn2_1_soc.clock_limits[k].dispclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dispclk_mhz;
1419-
dcn2_1_soc.clock_limits[k].dppclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dppclk_mhz;
1420-
dcn2_1_soc.clock_limits[k].dram_bw_per_chan_gbps = dcn2_1_soc.clock_limits[closest_clk_lvl].dram_bw_per_chan_gbps;
1421-
dcn2_1_soc.clock_limits[k].dscclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dscclk_mhz;
1422-
dcn2_1_soc.clock_limits[k].dtbclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dtbclk_mhz;
1423-
dcn2_1_soc.clock_limits[k].phyclk_d18_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].phyclk_d18_mhz;
1424-
dcn2_1_soc.clock_limits[k].phyclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].phyclk_mhz;
1425-
k++;
1426-
}
1396+
clock_limits[i].state = i;
1397+
clock_limits[i].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
1398+
clock_limits[i].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
1399+
clock_limits[i].socclk_mhz = clk_table->entries[i].socclk_mhz;
1400+
clock_limits[i].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2;
1401+
1402+
clock_limits[i].dispclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dispclk_mhz;
1403+
clock_limits[i].dppclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dppclk_mhz;
1404+
clock_limits[i].dram_bw_per_chan_gbps = dcn2_1_soc.clock_limits[closest_clk_lvl].dram_bw_per_chan_gbps;
1405+
clock_limits[i].dscclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dscclk_mhz;
1406+
clock_limits[i].dtbclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dtbclk_mhz;
1407+
clock_limits[i].phyclk_d18_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].phyclk_d18_mhz;
1408+
clock_limits[i].phyclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].phyclk_mhz;
1409+
}
1410+
for (i = 0; i < clk_table->num_entries; i++)
1411+
dcn2_1_soc.clock_limits[i] = clock_limits[i];
1412+
if (clk_table->num_entries) {
1413+
dcn2_1_soc.num_states = clk_table->num_entries;
1414+
/* duplicate last level */
1415+
dcn2_1_soc.clock_limits[dcn2_1_soc.num_states] = dcn2_1_soc.clock_limits[dcn2_1_soc.num_states - 1];
1416+
dcn2_1_soc.clock_limits[dcn2_1_soc.num_states].state = dcn2_1_soc.num_states;
14271417
}
1428-
dcn2_1_soc.num_states = k;
14291418
}
14301419

1431-
/* duplicate last level */
1432-
dcn2_1_soc.clock_limits[dcn2_1_soc.num_states] = dcn2_1_soc.clock_limits[dcn2_1_soc.num_states - 1];
1433-
dcn2_1_soc.clock_limits[dcn2_1_soc.num_states].state = dcn2_1_soc.num_states;
1434-
14351420
dml_init_instance(&dc->dml, &dcn2_1_soc, &dcn2_1_ip, DML_PROJECT_DCN21);
14361421
}
14371422

0 commit comments

Comments
 (0)