aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2018-05-24 08:54:03 -0400
committerJani Nikula <jani.nikula@intel.com>2018-06-19 08:47:49 -0400
commit541ab84d2b6ea79021d5df0b54d81600334fa2a4 (patch)
tree9d73faf2e202d0d95959ef5e81c7db898ae5fb1e
parenta5bfcdf0e16b33c1690ded31f863466136480ddc (diff)
drm/i915: Allow DBLSCAN user modes with eDP/LVDS/DSI
When encountering a connector with the scaling mode property both intel and modesetting ddxs sometimes add tons of DBLSCAN modes to the output's mode list. The idea presumably being that since the output will be going through the panel fitter anyway we can pretend to use any kind of mode. Sadly that means we can't reject user modes with the DBLSCAN flag until we know whether we're going to be using the panel's native mode or the user mode directly. Doing otherwise means X clients using xf86vidmode/xrandr will get a protocol error (and often self terminate as a result) when the kernel refuses to use the requested mode with the DBLSCAN flag. To undo the regression we'll move the DBLSCAN checks into the connector->mode_valid() and encoder->compute_config() hooks. Cc: stable@vger.kernel.org Cc: Vito Caputo <vcaputo@pengaru.com> Reported-by: Vito Caputo <vcaputo@pengaru.com> Fixes: e995ca0b8139 ("drm/i915: Provide a device level .mode_valid() hook") References: https://lkml.org/lkml/2018/5/21/715 Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180524125403.23445-1-ville.syrjala@linux.intel.com Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106804 Tested-by: Arkadiusz Miskiewicz <arekm@maven.pl> (cherry picked from commit e4dd27aadd205417a2e9ea9902b698a0252ec3a0) Signed-off-by: Jani Nikula <jani.nikula@intel.com>
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c20
-rw-r--r--drivers/gpu/drm/i915/intel_display.c16
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c6
-rw-r--r--drivers/gpu/drm/i915/intel_dp_mst.c6
-rw-r--r--drivers/gpu/drm/i915/intel_dsi.c6
-rw-r--r--drivers/gpu/drm/i915/intel_dvo.c6
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c6
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c5
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c6
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c12
10 files changed, 84 insertions, 5 deletions
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index de0e22322c76..072b326d5ee0 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -304,6 +304,9 @@ intel_crt_mode_valid(struct drm_connector *connector,
304 int max_dotclk = dev_priv->max_dotclk_freq; 304 int max_dotclk = dev_priv->max_dotclk_freq;
305 int max_clock; 305 int max_clock;
306 306
307 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
308 return MODE_NO_DBLESCAN;
309
307 if (mode->clock < 25000) 310 if (mode->clock < 25000)
308 return MODE_CLOCK_LOW; 311 return MODE_CLOCK_LOW;
309 312
@@ -337,6 +340,12 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder,
337 struct intel_crtc_state *pipe_config, 340 struct intel_crtc_state *pipe_config,
338 struct drm_connector_state *conn_state) 341 struct drm_connector_state *conn_state)
339{ 342{
343 struct drm_display_mode *adjusted_mode =
344 &pipe_config->base.adjusted_mode;
345
346 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
347 return false;
348
340 return true; 349 return true;
341} 350}
342 351
@@ -344,6 +353,12 @@ static bool pch_crt_compute_config(struct intel_encoder *encoder,
344 struct intel_crtc_state *pipe_config, 353 struct intel_crtc_state *pipe_config,
345 struct drm_connector_state *conn_state) 354 struct drm_connector_state *conn_state)
346{ 355{
356 struct drm_display_mode *adjusted_mode =
357 &pipe_config->base.adjusted_mode;
358
359 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
360 return false;
361
347 pipe_config->has_pch_encoder = true; 362 pipe_config->has_pch_encoder = true;
348 363
349 return true; 364 return true;
@@ -354,6 +369,11 @@ static bool hsw_crt_compute_config(struct intel_encoder *encoder,
354 struct drm_connector_state *conn_state) 369 struct drm_connector_state *conn_state)
355{ 370{
356 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 371 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
372 struct drm_display_mode *adjusted_mode =
373 &pipe_config->base.adjusted_mode;
374
375 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
376 return false;
357 377
358 pipe_config->has_pch_encoder = true; 378 pipe_config->has_pch_encoder = true;
359 379
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index dee3a8e659f1..2cc6faa1daa8 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -14469,12 +14469,22 @@ static enum drm_mode_status
14469intel_mode_valid(struct drm_device *dev, 14469intel_mode_valid(struct drm_device *dev,
14470 const struct drm_display_mode *mode) 14470 const struct drm_display_mode *mode)
14471{ 14471{
14472 /*
14473 * Can't reject DBLSCAN here because Xorg ddxen can add piles
14474 * of DBLSCAN modes to the output's mode list when they detect
14475 * the scaling mode property on the connector. And they don't
14476 * ask the kernel to validate those modes in any way until
14477 * modeset time at which point the client gets a protocol error.
14478 * So in order to not upset those clients we silently ignore the
14479 * DBLSCAN flag on such connectors. For other connectors we will
14480 * reject modes with the DBLSCAN flag in encoder->compute_config().
14481 * And we always reject DBLSCAN modes in connector->mode_valid()
14482 * as we never want such modes on the connector's mode list.
14483 */
14484
14472 if (mode->vscan > 1) 14485 if (mode->vscan > 1)
14473 return MODE_NO_VSCAN; 14486 return MODE_NO_VSCAN;
14474 14487
14475 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
14476 return MODE_NO_DBLESCAN;
14477
14478 if (mode->flags & DRM_MODE_FLAG_HSKEW) 14488 if (mode->flags & DRM_MODE_FLAG_HSKEW)
14479 return MODE_H_ILLEGAL; 14489 return MODE_H_ILLEGAL;
14480 14490
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 8320f0e8e3be..6cce43a6eaad 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -420,6 +420,9 @@ intel_dp_mode_valid(struct drm_connector *connector,
420 int max_rate, mode_rate, max_lanes, max_link_clock; 420 int max_rate, mode_rate, max_lanes, max_link_clock;
421 int max_dotclk; 421 int max_dotclk;
422 422
423 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
424 return MODE_NO_DBLESCAN;
425
423 max_dotclk = intel_dp_downstream_max_dotclock(intel_dp); 426 max_dotclk = intel_dp_downstream_max_dotclock(intel_dp);
424 427
425 if (intel_dp_is_edp(intel_dp) && fixed_mode) { 428 if (intel_dp_is_edp(intel_dp) && fixed_mode) {
@@ -1862,6 +1865,9 @@ intel_dp_compute_config(struct intel_encoder *encoder,
1862 conn_state->scaling_mode); 1865 conn_state->scaling_mode);
1863 } 1866 }
1864 1867
1868 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
1869 return false;
1870
1865 if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && 1871 if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) &&
1866 adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) 1872 adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE)
1867 return false; 1873 return false;
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
index 9e6956c08688..5890500a3a8b 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -48,6 +48,9 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,
48 bool reduce_m_n = drm_dp_has_quirk(&intel_dp->desc, 48 bool reduce_m_n = drm_dp_has_quirk(&intel_dp->desc,
49 DP_DPCD_QUIRK_LIMITED_M_N); 49 DP_DPCD_QUIRK_LIMITED_M_N);
50 50
51 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
52 return false;
53
51 pipe_config->has_pch_encoder = false; 54 pipe_config->has_pch_encoder = false;
52 bpp = 24; 55 bpp = 24;
53 if (intel_dp->compliance.test_data.bpc) { 56 if (intel_dp->compliance.test_data.bpc) {
@@ -366,6 +369,9 @@ intel_dp_mst_mode_valid(struct drm_connector *connector,
366 if (!intel_dp) 369 if (!intel_dp)
367 return MODE_ERROR; 370 return MODE_ERROR;
368 371
372 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
373 return MODE_NO_DBLESCAN;
374
369 max_link_clock = intel_dp_max_link_rate(intel_dp); 375 max_link_clock = intel_dp_max_link_rate(intel_dp);
370 max_lanes = intel_dp_max_lane_count(intel_dp); 376 max_lanes = intel_dp_max_lane_count(intel_dp);
371 377
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index cf39ca90d887..f349b3920199 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -326,6 +326,9 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
326 conn_state->scaling_mode); 326 conn_state->scaling_mode);
327 } 327 }
328 328
329 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
330 return false;
331
329 /* DSI uses short packets for sync events, so clear mode flags for DSI */ 332 /* DSI uses short packets for sync events, so clear mode flags for DSI */
330 adjusted_mode->flags = 0; 333 adjusted_mode->flags = 0;
331 334
@@ -1266,6 +1269,9 @@ intel_dsi_mode_valid(struct drm_connector *connector,
1266 1269
1267 DRM_DEBUG_KMS("\n"); 1270 DRM_DEBUG_KMS("\n");
1268 1271
1272 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1273 return MODE_NO_DBLESCAN;
1274
1269 if (fixed_mode) { 1275 if (fixed_mode) {
1270 if (mode->hdisplay > fixed_mode->hdisplay) 1276 if (mode->hdisplay > fixed_mode->hdisplay)
1271 return MODE_PANEL; 1277 return MODE_PANEL;
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
index a70d767313aa..61d908e0df0e 100644
--- a/drivers/gpu/drm/i915/intel_dvo.c
+++ b/drivers/gpu/drm/i915/intel_dvo.c
@@ -219,6 +219,9 @@ intel_dvo_mode_valid(struct drm_connector *connector,
219 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 219 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
220 int target_clock = mode->clock; 220 int target_clock = mode->clock;
221 221
222 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
223 return MODE_NO_DBLESCAN;
224
222 /* XXX: Validate clock range */ 225 /* XXX: Validate clock range */
223 226
224 if (fixed_mode) { 227 if (fixed_mode) {
@@ -254,6 +257,9 @@ static bool intel_dvo_compute_config(struct intel_encoder *encoder,
254 if (fixed_mode) 257 if (fixed_mode)
255 intel_fixed_panel_mode(fixed_mode, adjusted_mode); 258 intel_fixed_panel_mode(fixed_mode, adjusted_mode);
256 259
260 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
261 return false;
262
257 return true; 263 return true;
258} 264}
259 265
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index ee929f31f7db..d8cb53ef4351 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1557,6 +1557,9 @@ intel_hdmi_mode_valid(struct drm_connector *connector,
1557 bool force_dvi = 1557 bool force_dvi =
1558 READ_ONCE(to_intel_digital_connector_state(connector->state)->force_audio) == HDMI_AUDIO_OFF_DVI; 1558 READ_ONCE(to_intel_digital_connector_state(connector->state)->force_audio) == HDMI_AUDIO_OFF_DVI;
1559 1559
1560 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1561 return MODE_NO_DBLESCAN;
1562
1560 clock = mode->clock; 1563 clock = mode->clock;
1561 1564
1562 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING) 1565 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING)
@@ -1677,6 +1680,9 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
1677 int desired_bpp; 1680 int desired_bpp;
1678 bool force_dvi = intel_conn_state->force_audio == HDMI_AUDIO_OFF_DVI; 1681 bool force_dvi = intel_conn_state->force_audio == HDMI_AUDIO_OFF_DVI;
1679 1682
1683 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
1684 return false;
1685
1680 pipe_config->has_hdmi_sink = !force_dvi && intel_hdmi->has_hdmi_sink; 1686 pipe_config->has_hdmi_sink = !force_dvi && intel_hdmi->has_hdmi_sink;
1681 1687
1682 if (pipe_config->has_hdmi_sink) 1688 if (pipe_config->has_hdmi_sink)
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index d278f24ba6ae..48f618dc9abb 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -380,6 +380,8 @@ intel_lvds_mode_valid(struct drm_connector *connector,
380 struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; 380 struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
381 int max_pixclk = to_i915(connector->dev)->max_dotclk_freq; 381 int max_pixclk = to_i915(connector->dev)->max_dotclk_freq;
382 382
383 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
384 return MODE_NO_DBLESCAN;
383 if (mode->hdisplay > fixed_mode->hdisplay) 385 if (mode->hdisplay > fixed_mode->hdisplay)
384 return MODE_PANEL; 386 return MODE_PANEL;
385 if (mode->vdisplay > fixed_mode->vdisplay) 387 if (mode->vdisplay > fixed_mode->vdisplay)
@@ -429,6 +431,9 @@ static bool intel_lvds_compute_config(struct intel_encoder *intel_encoder,
429 intel_fixed_panel_mode(intel_connector->panel.fixed_mode, 431 intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
430 adjusted_mode); 432 adjusted_mode);
431 433
434 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
435 return false;
436
432 if (HAS_PCH_SPLIT(dev_priv)) { 437 if (HAS_PCH_SPLIT(dev_priv)) {
433 pipe_config->has_pch_encoder = true; 438 pipe_config->has_pch_encoder = true;
434 439
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 25005023c243..26975df4e593 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -1160,6 +1160,9 @@ static bool intel_sdvo_compute_config(struct intel_encoder *encoder,
1160 adjusted_mode); 1160 adjusted_mode);
1161 } 1161 }
1162 1162
1163 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
1164 return false;
1165
1163 /* 1166 /*
1164 * Make the CRTC code factor in the SDVO pixel multiplier. The 1167 * Make the CRTC code factor in the SDVO pixel multiplier. The
1165 * SDVO device will factor out the multiplier during mode_set. 1168 * SDVO device will factor out the multiplier during mode_set.
@@ -1621,6 +1624,9 @@ intel_sdvo_mode_valid(struct drm_connector *connector,
1621 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); 1624 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1622 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 1625 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
1623 1626
1627 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1628 return MODE_NO_DBLESCAN;
1629
1624 if (intel_sdvo->pixel_clock_min > mode->clock) 1630 if (intel_sdvo->pixel_clock_min > mode->clock)
1625 return MODE_CLOCK_LOW; 1631 return MODE_CLOCK_LOW;
1626 1632
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index 885fc3809f7f..b55b5c157e38 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -850,6 +850,9 @@ intel_tv_mode_valid(struct drm_connector *connector,
850 const struct tv_mode *tv_mode = intel_tv_mode_find(connector->state); 850 const struct tv_mode *tv_mode = intel_tv_mode_find(connector->state);
851 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 851 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
852 852
853 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
854 return MODE_NO_DBLESCAN;
855
853 if (mode->clock > max_dotclk) 856 if (mode->clock > max_dotclk)
854 return MODE_CLOCK_HIGH; 857 return MODE_CLOCK_HIGH;
855 858
@@ -877,16 +880,21 @@ intel_tv_compute_config(struct intel_encoder *encoder,
877 struct drm_connector_state *conn_state) 880 struct drm_connector_state *conn_state)
878{ 881{
879 const struct tv_mode *tv_mode = intel_tv_mode_find(conn_state); 882 const struct tv_mode *tv_mode = intel_tv_mode_find(conn_state);
883 struct drm_display_mode *adjusted_mode =
884 &pipe_config->base.adjusted_mode;
880 885
881 if (!tv_mode) 886 if (!tv_mode)
882 return false; 887 return false;
883 888
884 pipe_config->base.adjusted_mode.crtc_clock = tv_mode->clock; 889 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
890 return false;
891
892 adjusted_mode->crtc_clock = tv_mode->clock;
885 DRM_DEBUG_KMS("forcing bpc to 8 for TV\n"); 893 DRM_DEBUG_KMS("forcing bpc to 8 for TV\n");
886 pipe_config->pipe_bpp = 8*3; 894 pipe_config->pipe_bpp = 8*3;
887 895
888 /* TV has it's own notion of sync and other mode flags, so clear them. */ 896 /* TV has it's own notion of sync and other mode flags, so clear them. */
889 pipe_config->base.adjusted_mode.flags = 0; 897 adjusted_mode->flags = 0;
890 898
891 /* 899 /*
892 * FIXME: We don't check whether the input mode is actually what we want 900 * FIXME: We don't check whether the input mode is actually what we want