Skip to content

Commit 5dc0ec7

Browse files
ahmed22002alexdeucher
authored andcommitted
drm/amd/display: Adding interface to log hw state when underflow happens
[why] Will help us better debug underflow issues. Reviewed-by: Nicholas Kazlauskas <[email protected]> Signed-off-by: Muhammad Ahmed <[email protected]> Signed-off-by: Roman Li <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 20ea30a commit 5dc0ec7

File tree

31 files changed

+236
-7
lines changed

31 files changed

+236
-7
lines changed

drivers/gpu/drm/amd/display/dc/core/dc.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6339,3 +6339,21 @@ bool dc_can_clear_cursor_limit(struct dc *dc)
63396339

63406340
return false;
63416341
}
6342+
6343+
void dc_get_underflow_debug_data_for_otg(struct dc *dc, int primary_otg_inst,
6344+
struct dc_underflow_debug_data *out_data)
6345+
{
6346+
struct timing_generator *tg = NULL;
6347+
6348+
for (int i = 0; i < MAX_PIPES; i++) {
6349+
if (dc->res_pool->timing_generators[i] &&
6350+
dc->res_pool->timing_generators[i]->inst == primary_otg_inst) {
6351+
tg = dc->res_pool->timing_generators[i];
6352+
break;
6353+
}
6354+
}
6355+
6356+
dc_exit_ips_for_hw_access(dc);
6357+
if (dc->hwss.get_underflow_debug_data)
6358+
dc->hwss.get_underflow_debug_data(dc, tg, out_data);
6359+
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,23 @@ struct dc_surface_update {
18191819
struct dc_bias_and_scale bias_and_scale;
18201820
};
18211821

1822+
struct dc_underflow_debug_data {
1823+
uint32_t otg_inst;
1824+
uint32_t otg_underflow;
1825+
uint32_t h_position;
1826+
uint32_t v_position;
1827+
uint32_t otg_frame_count;
1828+
struct dc_underflow_per_hubp_debug_data {
1829+
uint32_t hubp_underflow;
1830+
uint32_t hubp_in_blank;
1831+
uint32_t hubp_readline;
1832+
uint32_t det_config_error;
1833+
} hubps[MAX_PIPES];
1834+
uint32_t curr_det_sizes[MAX_PIPES];
1835+
uint32_t target_det_sizes[MAX_PIPES];
1836+
uint32_t compbuf_config_error;
1837+
};
1838+
18221839
/*
18231840
* Create a new surface with default parameters;
18241841
*/
@@ -2713,4 +2730,17 @@ bool dc_is_timing_changed(struct dc_stream_state *cur_stream,
27132730
bool dc_is_cursor_limit_pending(struct dc *dc);
27142731
bool dc_can_clear_cursor_limit(struct dc *dc);
27152732

2733+
/**
2734+
* dc_get_underflow_debug_data_for_otg() - Retrieve underflow debug data.
2735+
*
2736+
* @dc: Pointer to the display core context.
2737+
* @primary_otg_inst: Instance index of the primary OTG that underflowed.
2738+
* @out_data: Pointer to a dc_underflow_debug_data struct to be filled with debug information.
2739+
*
2740+
* This function collects and logs underflow-related HW states when underflow happens,
2741+
* including OTG underflow status, current read positions, frame count, and per-HUBP debug data.
2742+
* The results are stored in the provided out_data structure for further analysis or logging.
2743+
*/
2744+
void dc_get_underflow_debug_data_for_otg(struct dc *dc, int primary_otg_inst, struct dc_underflow_debug_data *out_data);
2745+
27162746
#endif /* DC_INTERFACE_H_ */

drivers/gpu/drm/amd/display/dc/hubbub/dcn30/dcn30_hubbub.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,35 @@ void hubbub3_init_watermarks(struct hubbub *hubbub)
440440
REG_WRITE(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_D, reg);
441441
}
442442

443+
void hubbub3_get_det_sizes(struct hubbub *hubbub, uint32_t *curr_det_sizes, uint32_t *target_det_sizes)
444+
{
445+
struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
446+
447+
REG_GET_2(DCHUBBUB_DET0_CTRL, DET0_SIZE_CURRENT, &curr_det_sizes[0],
448+
DET0_SIZE, &target_det_sizes[0]);
449+
450+
REG_GET_2(DCHUBBUB_DET1_CTRL, DET1_SIZE_CURRENT, &curr_det_sizes[1],
451+
DET1_SIZE, &target_det_sizes[1]);
452+
453+
REG_GET_2(DCHUBBUB_DET2_CTRL, DET2_SIZE_CURRENT, &curr_det_sizes[2],
454+
DET2_SIZE, &target_det_sizes[2]);
455+
456+
REG_GET_2(DCHUBBUB_DET3_CTRL, DET3_SIZE_CURRENT, &curr_det_sizes[3],
457+
DET3_SIZE, &target_det_sizes[3]);
458+
459+
}
460+
461+
uint32_t hubbub3_compbuf_config_error(struct hubbub *hubbub)
462+
{
463+
struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
464+
uint32_t compbuf_config_error = 0;
465+
466+
REG_GET(DCHUBBUB_COMPBUF_CTRL, CONFIG_ERROR,
467+
&compbuf_config_error);
468+
469+
return compbuf_config_error;
470+
}
471+
443472
static const struct hubbub_funcs hubbub30_funcs = {
444473
.update_dchub = hubbub2_update_dchub,
445474
.init_dchub_sys_ctx = hubbub3_init_dchub_sys_ctx,
@@ -457,6 +486,8 @@ static const struct hubbub_funcs hubbub30_funcs = {
457486
.force_pstate_change_control = hubbub3_force_pstate_change_control,
458487
.init_watermarks = hubbub3_init_watermarks,
459488
.hubbub_read_state = hubbub2_read_state,
489+
.get_det_sizes = hubbub3_get_det_sizes,
490+
.compbuf_config_error = hubbub3_compbuf_config_error,
460491
};
461492

462493
void hubbub3_construct(struct dcn20_hubbub *hubbub3,

drivers/gpu/drm/amd/display/dc/hubbub/dcn30/dcn30_hubbub.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,10 @@ void hubbub3_force_pstate_change_control(struct hubbub *hubbub,
133133

134134
void hubbub3_init_watermarks(struct hubbub *hubbub);
135135

136+
void hubbub3_get_det_sizes(struct hubbub *hubbub,
137+
uint32_t *curr_det_sizes,
138+
uint32_t *target_det_sizes);
139+
140+
uint32_t hubbub3_compbuf_config_error(struct hubbub *hubbub);
141+
136142
#endif

drivers/gpu/drm/amd/display/dc/hubbub/dcn31/dcn31_hubbub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,8 @@ static const struct hubbub_funcs hubbub31_funcs = {
10711071
.program_compbuf_size = dcn31_program_compbuf_size,
10721072
.init_crb = dcn31_init_crb,
10731073
.hubbub_read_state = hubbub2_read_state,
1074+
.get_det_sizes = hubbub3_get_det_sizes,
1075+
.compbuf_config_error = hubbub3_compbuf_config_error,
10741076
};
10751077

10761078
void hubbub31_construct(struct dcn20_hubbub *hubbub31,

drivers/gpu/drm/amd/display/dc/hubbub/dcn32/dcn32_hubbub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,8 @@ static const struct hubbub_funcs hubbub32_funcs = {
10091009
.force_usr_retraining_allow = hubbub32_force_usr_retraining_allow,
10101010
.set_request_limit = hubbub32_set_request_limit,
10111011
.get_mall_en = hubbub32_get_mall_en,
1012+
.get_det_sizes = hubbub3_get_det_sizes,
1013+
.compbuf_config_error = hubbub3_compbuf_config_error,
10121014
};
10131015

10141016
void hubbub32_construct(struct dcn20_hubbub *hubbub2,

drivers/gpu/drm/amd/display/dc/hubbub/dcn35/dcn35_hubbub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ static const struct hubbub_funcs hubbub35_funcs = {
589589
.hubbub_read_state = hubbub2_read_state,
590590
.force_usr_retraining_allow = hubbub32_force_usr_retraining_allow,
591591
.dchubbub_init = hubbub35_init,
592+
.get_det_sizes = hubbub3_get_det_sizes,
593+
.compbuf_config_error = hubbub3_compbuf_config_error,
592594
};
593595

594596
void hubbub35_construct(struct dcn20_hubbub *hubbub2,

drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,8 @@ static const struct hubbub_funcs hubbub4_01_funcs = {
12471247
.program_compbuf_segments = dcn401_program_compbuf_segments,
12481248
.wait_for_det_update = dcn401_wait_for_det_update,
12491249
.program_arbiter = dcn401_program_arbiter,
1250+
.get_det_sizes = hubbub3_get_det_sizes,
1251+
.compbuf_config_error = hubbub3_compbuf_config_error,
12501252
};
12511253

12521254
void hubbub401_construct(struct dcn20_hubbub *hubbub2,

drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
SRI(DCN_SURF1_TTU_CNTL1, HUBPREQ, id),\
105105
SRI(DCN_CUR0_TTU_CNTL0, HUBPREQ, id),\
106106
SRI(DCN_CUR0_TTU_CNTL1, HUBPREQ, id),\
107-
SRI(HUBP_CLK_CNTL, HUBP, id)
107+
SRI(HUBP_CLK_CNTL, HUBP, id),\
108+
SRI(HUBPRET_READ_LINE_VALUE, HUBPRET, id)
108109

109110
/* Register address initialization macro for ASICs with VM */
110111
#define HUBP_REG_LIST_DCN_VM(id)\
@@ -249,7 +250,8 @@
249250
uint32_t CURSOR_POSITION; \
250251
uint32_t CURSOR_HOT_SPOT; \
251252
uint32_t CURSOR_DST_OFFSET; \
252-
uint32_t HUBP_CLK_CNTL
253+
uint32_t HUBP_CLK_CNTL; \
254+
uint32_t HUBPRET_READ_LINE_VALUE
253255

254256
#define HUBP_SF(reg_name, field_name, post_fix)\
255257
.field_name = reg_name ## __ ## field_name ## post_fix
@@ -622,6 +624,8 @@
622624
type DCN_VM_SYSTEM_APERTURE_DEFAULT_SYSTEM;\
623625
type DCN_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB;\
624626
type DCN_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB;\
627+
type PIPE_READ_LINE;\
628+
type HUBP_SEG_ALLOC_ERR_STATUS;\
625629
/* todo: get these from GVM instead of reading registers ourselves */\
626630
type PAGE_DIRECTORY_ENTRY_HI32;\
627631
type PAGE_DIRECTORY_ENTRY_LO32;\

drivers/gpu/drm/amd/display/dc/hubp/dcn30/dcn30_hubp.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,30 @@ void hubp3_init(struct hubp *hubp)
505505
hubp_reset(hubp);
506506
}
507507

508+
uint32_t hubp3_get_current_read_line(struct hubp *hubp)
509+
{
510+
uint32_t read_line = 0;
511+
struct dcn20_hubp *hubp2 = TO_DCN20_HUBP(hubp);
512+
513+
REG_GET(HUBPRET_READ_LINE_VALUE,
514+
PIPE_READ_LINE,
515+
&read_line);
516+
517+
return read_line;
518+
}
519+
520+
unsigned int hubp3_get_underflow_status(struct hubp *hubp)
521+
{
522+
uint32_t hubp_underflow = 0;
523+
struct dcn20_hubp *hubp2 = TO_DCN20_HUBP(hubp);
524+
525+
REG_GET(DCHUBP_CNTL,
526+
HUBP_UNDERFLOW_STATUS,
527+
&hubp_underflow);
528+
529+
return hubp_underflow;
530+
}
531+
508532
static struct hubp_funcs dcn30_hubp_funcs = {
509533
.hubp_enable_tripleBuffer = hubp2_enable_triplebuffer,
510534
.hubp_is_triplebuffer_enabled = hubp2_is_triplebuffer_enabled,
@@ -534,6 +558,8 @@ static struct hubp_funcs dcn30_hubp_funcs = {
534558
.hubp_soft_reset = hubp1_soft_reset,
535559
.hubp_set_flip_int = hubp1_set_flip_int,
536560
.hubp_clear_tiling = hubp3_clear_tiling,
561+
.hubp_get_underflow_status = hubp3_get_underflow_status,
562+
.hubp_get_current_read_line = hubp3_get_current_read_line,
537563
};
538564

539565
bool hubp3_construct(

0 commit comments

Comments
 (0)