Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/dp: Link train Fallback on eDP only if fallback link BW can fit panel's native mode

This patch fixes the original commit c0cfb10d9e1de49 ("drm/i915/edp:
Do not do link training fallback or prune modes on EDP") that causes
a blank screen in case of certain eDP panels (Eg: seen on Dell XPS13 9350)
where first link training fails and a retraining is required by falling
back to lower link rate/lane count.
In case of some panels they advertise higher link rate/lane count
than whats required for supporting the panel's native mode.
But we always link train at highest link rate/lane count for eDP
and if that fails we can still fallback to lower link rate/lane count
as long as the fallback link BW still fits the native mode to avoid
pruning the panel's native mode yet retraining at fallback values
to recover from a blank screen.

v3:
* Add const for fixed_mode (Ville)
v2:
* Send uevent if link failure on eDP unconditionally

Fixes: c0cfb10d9e1d ("drm/i915/edp: Do not do link training fallback or prune modes on EDP")
Cc: Clinton Taylor <clinton.a.taylor@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: <stable@vger.kernel.org> # v4.17+
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107489
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105338
Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
Tested-by: Alexander Wilson <alexander.wilson@ncf.edu>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181009212804.702-1-manasi.d.navare@intel.com
(cherry picked from commit 1e712535c51ab025ebc776d4405683d81521996d)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Manasi Navare and committed by
Rodrigo Vivi
04144445 4bbf0d47

+39 -17
+30
drivers/gpu/drm/i915/intel_dp.c
··· 557 557 return true; 558 558 } 559 559 560 + static bool intel_dp_can_link_train_fallback_for_edp(struct intel_dp *intel_dp, 561 + int link_rate, 562 + uint8_t lane_count) 563 + { 564 + const struct drm_display_mode *fixed_mode = 565 + intel_dp->attached_connector->panel.fixed_mode; 566 + int mode_rate, max_rate; 567 + 568 + mode_rate = intel_dp_link_required(fixed_mode->clock, 18); 569 + max_rate = intel_dp_max_data_rate(link_rate, lane_count); 570 + if (mode_rate > max_rate) 571 + return false; 572 + 573 + return true; 574 + } 575 + 560 576 int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp, 561 577 int link_rate, uint8_t lane_count) 562 578 { ··· 582 566 intel_dp->num_common_rates, 583 567 link_rate); 584 568 if (index > 0) { 569 + if (intel_dp_is_edp(intel_dp) && 570 + !intel_dp_can_link_train_fallback_for_edp(intel_dp, 571 + intel_dp->common_rates[index - 1], 572 + lane_count)) { 573 + DRM_DEBUG_KMS("Retrying Link training for eDP with same parameters\n"); 574 + return 0; 575 + } 585 576 intel_dp->max_link_rate = intel_dp->common_rates[index - 1]; 586 577 intel_dp->max_link_lane_count = lane_count; 587 578 } else if (lane_count > 1) { 579 + if (intel_dp_is_edp(intel_dp) && 580 + !intel_dp_can_link_train_fallback_for_edp(intel_dp, 581 + intel_dp_max_common_rate(intel_dp), 582 + lane_count >> 1)) { 583 + DRM_DEBUG_KMS("Retrying Link training for eDP with same parameters\n"); 584 + return 0; 585 + } 588 586 intel_dp->max_link_rate = intel_dp_max_common_rate(intel_dp); 589 587 intel_dp->max_link_lane_count = lane_count >> 1; 590 588 } else {