Commit df2f59c5 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Reject excessive dotclocks early

Make sure modes with crazy big dotclocks are rejected early,
so as to not cause problems for subsequent code via integer
overflows and whatnot.

These would eventually be rejected in intel_crtc_compute_pipe_mode()
but that is now too late as we do the clock computations a bit
earlier than that. And we don't want to just reorder the two since
we still want to check the final computed dotclock against the
hardware limit to make sure we didn't end up above the limit due
to rounding/etc.

Fixes: 0ff0e219 ("drm/i915: Compute clocks earlier")
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220927182455.3422-1-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent d5c45330
...@@ -8134,6 +8134,17 @@ static void intel_setup_outputs(struct drm_i915_private *dev_priv) ...@@ -8134,6 +8134,17 @@ static void intel_setup_outputs(struct drm_i915_private *dev_priv)
drm_helper_move_panel_connectors_to_head(&dev_priv->drm); drm_helper_move_panel_connectors_to_head(&dev_priv->drm);
} }
static int max_dotclock(struct drm_i915_private *i915)
{
int max_dotclock = i915->max_dotclk_freq;
/* icl+ might use bigjoiner */
if (DISPLAY_VER(i915) >= 11)
max_dotclock *= 2;
return max_dotclock;
}
static enum drm_mode_status static enum drm_mode_status
intel_mode_valid(struct drm_device *dev, intel_mode_valid(struct drm_device *dev,
const struct drm_display_mode *mode) const struct drm_display_mode *mode)
...@@ -8171,6 +8182,13 @@ intel_mode_valid(struct drm_device *dev, ...@@ -8171,6 +8182,13 @@ intel_mode_valid(struct drm_device *dev,
DRM_MODE_FLAG_CLKDIV2)) DRM_MODE_FLAG_CLKDIV2))
return MODE_BAD; return MODE_BAD;
/*
* Reject clearly excessive dotclocks early to
* avoid having to worry about huge integers later.
*/
if (mode->clock > max_dotclock(dev_priv))
return MODE_CLOCK_HIGH;
/* Transcoder timing limits */ /* Transcoder timing limits */
if (DISPLAY_VER(dev_priv) >= 11) { if (DISPLAY_VER(dev_priv) >= 11) {
hdisplay_max = 16384; hdisplay_max = 16384;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment