The hardware does not support DisplayPort configurations where the ceiling
of the Link M/Link N ratio exceeds 10. Enforce this constraint for MST
as well.

Add a check to reject mode for which where the M/N ratio exceeds the
supported limit. For MST, in compute config phase currently we use the
maximum link rate so just check if the M/N ratio is with in limit,
and bail out.

Signed-off-by: Ankit Nautiyal <ankit.k.nauti...@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dp.c     |  2 +-
 drivers/gpu/drm/i915/display/intel_dp.h     |  1 +
 drivers/gpu/drm/i915/display/intel_dp_mst.c | 20 ++++++++++++++++----
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 4245dd65b2af..a1077a7ba7da 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -1413,7 +1413,7 @@ intel_dp_get_max_m_n_ratio(void)
        return 10;
 }
 
-static bool
+bool
 intel_dp_can_support_m_n(int pixel_clock,
                         int link_rate)
 {
diff --git a/drivers/gpu/drm/i915/display/intel_dp.h 
b/drivers/gpu/drm/i915/display/intel_dp.h
index 0657f5681196..16555a9c53c4 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.h
+++ b/drivers/gpu/drm/i915/display/intel_dp.h
@@ -214,5 +214,6 @@ int intel_dp_compute_min_hblank(struct intel_crtc_state 
*crtc_state,
 
 int intel_dp_dsc_bpp_step_x16(const struct intel_connector *connector);
 void intel_dp_dpcd_set_probe(struct intel_dp *intel_dp, bool 
force_on_external);
+bool intel_dp_can_support_m_n(int pixel_clock, int link_rate);
 
 #endif /* __INTEL_DP_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c 
b/drivers/gpu/drm/i915/display/intel_dp_mst.c
index 74497c9a0554..62da0cb70607 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -202,10 +202,10 @@ static int intel_dp_mst_bw_overhead(const struct 
intel_crtc_state *crtc_state,
        return max(overhead, intel_dp_bw_fec_overhead(crtc_state->fec_enable));
 }
 
-static void intel_dp_mst_compute_m_n(const struct intel_crtc_state *crtc_state,
-                                    int overhead,
-                                    int bpp_x16,
-                                    struct intel_link_m_n *m_n)
+static int intel_dp_mst_compute_m_n(const struct intel_crtc_state *crtc_state,
+                                   int overhead,
+                                   int bpp_x16,
+                                   struct intel_link_m_n *m_n)
 {
        const struct drm_display_mode *adjusted_mode =
                &crtc_state->hw.adjusted_mode;
@@ -218,6 +218,8 @@ static void intel_dp_mst_compute_m_n(const struct 
intel_crtc_state *crtc_state,
                               m_n);
 
        m_n->tu = DIV_ROUND_UP_ULL(mul_u32_u32(m_n->data_m, 64), m_n->data_n);
+
+       return 0;
 }
 
 static int intel_dp_mst_calc_pbn(int pixel_clock, int bpp_x16, int bw_overhead)
@@ -445,6 +447,11 @@ static int mst_stream_compute_link_config(struct intel_dp 
*intel_dp,
 {
        crtc_state->lane_count = limits->max_lane_count;
        crtc_state->port_clock = limits->max_rate;
+       const struct drm_display_mode *adjusted_mode =
+               &crtc_state->hw.adjusted_mode;
+
+       if (!intel_dp_can_support_m_n(adjusted_mode->clock, 
crtc_state->port_clock))
+               return -EINVAL;
 
        /*
         * FIXME: allocate the BW according to link_bpp, which in the case of
@@ -1551,6 +1558,11 @@ mst_connector_mode_valid_ctx(struct drm_connector 
*_connector,
                return 0;
        }
 
+       if (!intel_dp_can_support_m_n(mode->clock, max_rate)) {
+               *status = MODE_CLOCK_HIGH;
+               return 0;
+       }
+
        *status = intel_mode_valid_max_plane_size(display, mode, 
num_joined_pipes);
        return 0;
 }
-- 
2.45.2

Reply via email to