Skip to content

Commit c42656f

Browse files
Dmytro Laktyushkinalexdeucher
authored andcommitted
drm/amd/display: Fix dcn21 num_states
[Why] DML expects num_states to exclude the duplicate state. [How] Set num_states to correct value to prevent array off-by-one error. Also refactor max clock level code for diags. Signed-off-by: Dmytro Laktyushkin <[email protected]> Signed-off-by: George Shen <[email protected]> Reviewed-by: Dmytro Laktyushkin <[email protected]> Acked-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 00755bb commit c42656f

File tree

4 files changed

+18
-30
lines changed

4 files changed

+18
-30
lines changed

drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3343,7 +3343,7 @@ void dcn20_cap_soc_clocks(
33433343
void dcn20_update_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_st *bb,
33443344
struct pp_smu_nv_clock_table *max_clocks, unsigned int *uclk_states, unsigned int num_states)
33453345
{
3346-
struct _vcs_dpi_voltage_scaling_st calculated_states[MAX_CLOCK_LIMIT_STATES];
3346+
struct _vcs_dpi_voltage_scaling_st calculated_states[DC__VOLTAGE_STATES];
33473347
int i;
33483348
int num_calculated_states = 0;
33493349
int min_dcfclk = 0;

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

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = {
300300
.xfc_bus_transport_time_us = 4,
301301
.xfc_xbuf_latency_tolerance_us = 4,
302302
.use_urgent_burst_bw = 1,
303-
.num_states = 9
303+
.num_states = 8
304304
};
305305

306306
#ifndef MAX
@@ -1377,21 +1377,8 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param
13771377
unsigned int i, j, k;
13781378
int closest_clk_lvl;
13791379

1380-
// diags does not retrieve proper values from SMU
1381-
// cap states to 5 and make state 5 the max state
1382-
if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) || IS_DIAG_DC(dc->ctx->dce_environment)) {
1383-
dcn2_1_soc.num_states = 5;
1384-
1385-
dcn2_1_soc.clock_limits[5].state = 5;
1386-
dcn2_1_soc.clock_limits[5].dcfclk_mhz = 810.0;
1387-
dcn2_1_soc.clock_limits[5].fabricclk_mhz = 1600.0;
1388-
dcn2_1_soc.clock_limits[5].dispclk_mhz = 1395.0;
1389-
dcn2_1_soc.clock_limits[5].dppclk_mhz = 1285.0;
1390-
dcn2_1_soc.clock_limits[5].phyclk_mhz = 1325.0;
1391-
dcn2_1_soc.clock_limits[5].socclk_mhz = 953.0;
1392-
dcn2_1_soc.clock_limits[5].dscclk_mhz = 489.0;
1393-
dcn2_1_soc.clock_limits[5].dram_speed_mts = 4266.0;
1394-
} else {
1380+
// 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)) {
13951382
dcn2_1_ip.max_num_otg = pool->base.res_cap->num_timing_generator;
13961383
dcn2_1_ip.max_num_dpp = pool->base.pipe_count;
13971384
dcn2_1_soc.num_chans = bw_params->num_channels;
@@ -1404,16 +1391,16 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param
14041391
dcn2_1_soc.clock_limits[0].dram_speed_mts = clk_table->entries[0].memclk_mhz * 2;
14051392

14061393
/*
1407-
* Other levels: find cloest DCN clocks that fit the given clock limit using dcfclk
1408-
* as indicater
1394+
* Other levels: find closest DCN clocks that fit the given clock limit using dcfclk
1395+
* as indicator
14091396
*/
14101397

14111398
closest_clk_lvl = -1;
14121399
/* index currently being filled */
14131400
k = 1;
14141401
for (i = 1; i < clk_table->num_entries; i++) {
1415-
/* loop backwards, skip duplicate state, +1 because SMU has precision issue */
1416-
for (j = dcn2_1_soc.num_states - 2; j >= k; j--) {
1402+
/* loop backwards, skip duplicate state*/
1403+
for (j = dcn2_1_soc.num_states - 1; j >= k; j--) {
14171404
if ((unsigned int) dcn2_1_soc.clock_limits[j].dcfclk_mhz <= clk_table->entries[i].dcfclk_mhz) {
14181405
closest_clk_lvl = j;
14191406
break;
@@ -1438,13 +1425,13 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param
14381425
k++;
14391426
}
14401427
}
1441-
1442-
/* duplicate last level */
1443-
dcn2_1_soc.clock_limits[k] = dcn2_1_soc.clock_limits[k - 1];
1444-
dcn2_1_soc.clock_limits[k].state = k;
1445-
dcn2_1_soc.num_states = k + 1;
1428+
dcn2_1_soc.num_states = k;
14461429
}
14471430

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+
14481435
dml_init_instance(&dc->dml, &dcn2_1_soc, &dcn2_1_ip, DML_PROJECT_DCN21);
14491436
}
14501437

drivers/gpu/drm/amd/display/dc/dml/dc_features.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#define DC__PRESENT 1
3030
#define DC__PRESENT__1 1
3131
#define DC__NUM_DPP 4
32-
#define DC__VOLTAGE_STATES 7
32+
#define DC__VOLTAGE_STATES 9
3333
#define DC__NUM_DPP__4 1
3434
#define DC__NUM_DPP__0_PRESENT 1
3535
#define DC__NUM_DPP__1_PRESENT 1

drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
* Authors: AMD
2323
*
2424
*/
25+
26+
#include "dc_features.h"
27+
2528
#ifndef __DISPLAY_MODE_STRUCTS_H__
2629
#define __DISPLAY_MODE_STRUCTS_H__
2730

28-
#define MAX_CLOCK_LIMIT_STATES 9
29-
3031
typedef struct _vcs_dpi_voltage_scaling_st voltage_scaling_st;
3132
typedef struct _vcs_dpi_soc_bounding_box_st soc_bounding_box_st;
3233
typedef struct _vcs_dpi_ip_params_st ip_params_st;
@@ -68,7 +69,7 @@ struct _vcs_dpi_voltage_scaling_st {
6869
};
6970

7071
struct _vcs_dpi_soc_bounding_box_st {
71-
struct _vcs_dpi_voltage_scaling_st clock_limits[MAX_CLOCK_LIMIT_STATES];
72+
struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES];
7273
unsigned int num_states;
7374
double sr_exit_time_us;
7475
double sr_enter_plus_exit_time_us;

0 commit comments

Comments
 (0)