On 2018-07-13 01:40 PM, Bhawanpreet Lakha wrote: > Some receivers seem to fail the first link training but are good on > subsequent tries. Check if the max setting was good otherwise retry > link training. > > This fixes HTC vive pro issue where it would fail to light up after > being disabled. > > Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> Reviewed-by: Harry Wentland <harry.wentland at amd.com> Harry > --- > drivers/gpu/drm/amd/display/dc/core/dc_link.c | 21 +++++++++++++++++++-- > drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 9 ++++++--- > drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h | 3 ++- > 3 files changed, 27 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c > index 4de68fa074a0..34ab1a91baab 100644 > --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c > +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c > @@ -60,7 +60,14 @@ > > enum { > LINK_RATE_REF_FREQ_IN_MHZ = 27, > - PEAK_FACTOR_X1000 = 1006 > + PEAK_FACTOR_X1000 = 1006, > + /* > + * Some receivers fail to train on first try and are good > + * on subsequent tries. 2 retries should be plenty. If we > + * don't have a successful training then we don't expect to > + * ever get one. > + */ > + LINK_TRAINING_MAX_VERIFY_RETRY = 2 > }; > > /******************************************************************************* > @@ -760,7 +767,17 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) > */ > > /* deal with non-mst cases */ > - dp_hbr_verify_link_cap(link, &link->reported_link_cap); > + for (i = 0; i < LINK_TRAINING_MAX_VERIFY_RETRY; i++) { > + int fail_count = 0; > + > + dp_hbr_verify_link_cap(link, > + &link->reported_link_cap, > + &fail_count); > + > + if (fail_count == 0) > + break; > + } > + > } > > /* HDMI-DVI Dongle */ > diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c > index 8fbb999e4a8a..18258944f442 100644 > --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c > +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c > @@ -1088,7 +1088,8 @@ static struct dc_link_settings get_max_link_cap(struct dc_link *link) > > bool dp_hbr_verify_link_cap( > struct dc_link *link, > - struct dc_link_settings *known_limit_link_setting) > + struct dc_link_settings *known_limit_link_setting, > + int *fail_count) > { > struct dc_link_settings max_link_cap = {0}; > struct dc_link_settings cur_link_setting = {0}; > @@ -1146,15 +1147,17 @@ bool dp_hbr_verify_link_cap( > cur); > > > - if (skip_link_training) > + if (skip_link_training) { > success = true; > - else { > + } else { > status = dc_link_dp_perform_link_training( > link, > cur, > skip_video_pattern); > if (status == LINK_TRAINING_SUCCESS) > success = true; > + else > + (*fail_count)++; > } > > if (success) > diff --git a/drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h b/drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h > index 2f783c650084..5eed19153de5 100644 > --- a/drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h > +++ b/drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h > @@ -35,7 +35,8 @@ struct dc_link_settings; > > bool dp_hbr_verify_link_cap( > struct dc_link *link, > - struct dc_link_settings *known_limit_link_setting); > + struct dc_link_settings *known_limit_link_setting, > + int *fail_count); > > bool dp_validate_mode_timing( > struct dc_link *link, >