Commit 5caa0fea authored by Daniel Vetter's avatar Daniel Vetter

drm/vblank: Lock down vblank->hwmode more

In the previous patch we've implemented hwmode tracking a la i915 for
the vblank timestamp calculations. But that was just the basic
semantics, i915 has some nice sanity checks to make sure we keep
getting this right. Move them over too.

v2:
- WARN_ON_ONCE to avoid excessive spam (Ville)
- Really only WARN on atomic drivers.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Acked-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170509140329.24114-5-daniel.vetter@ffwll.ch
parent 1bf6ad62
...@@ -777,6 +777,8 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, ...@@ -777,6 +777,8 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
*/ */
if (mode->crtc_clock == 0) { if (mode->crtc_clock == 0) {
DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe); DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
WARN_ON_ONCE(drm_drv_uses_atomic_modeset(dev));
return false; return false;
} }
...@@ -1338,6 +1340,10 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc) ...@@ -1338,6 +1340,10 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc)
send_vblank_event(dev, e, seq, &now); send_vblank_event(dev, e, seq, &now);
} }
spin_unlock_irqrestore(&dev->event_lock, irqflags); spin_unlock_irqrestore(&dev->event_lock, irqflags);
/* Will be reset by the modeset helpers when re-enabling the crtc by
* calling drm_calc_timestamping_constants(). */
vblank->hwmode.crtc_clock = 0;
} }
EXPORT_SYMBOL(drm_crtc_vblank_off); EXPORT_SYMBOL(drm_crtc_vblank_off);
......
...@@ -720,9 +720,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, unsigned int pipe) ...@@ -720,9 +720,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
struct drm_i915_private *dev_priv = to_i915(dev); struct drm_i915_private *dev_priv = to_i915(dev);
i915_reg_t high_frame, low_frame; i915_reg_t high_frame, low_frame;
u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal; u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal;
struct intel_crtc *intel_crtc = intel_get_crtc_for_pipe(dev_priv, const struct drm_display_mode *mode = &dev->vblank[pipe].hwmode;
pipe);
const struct drm_display_mode *mode = &intel_crtc->base.hwmode;
unsigned long irqflags; unsigned long irqflags;
htotal = mode->crtc_htotal; htotal = mode->crtc_htotal;
...@@ -779,13 +777,17 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) ...@@ -779,13 +777,17 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
{ {
struct drm_device *dev = crtc->base.dev; struct drm_device *dev = crtc->base.dev;
struct drm_i915_private *dev_priv = to_i915(dev); struct drm_i915_private *dev_priv = to_i915(dev);
const struct drm_display_mode *mode = &crtc->base.hwmode; const struct drm_display_mode *mode;
struct drm_vblank_crtc *vblank;
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
int position, vtotal; int position, vtotal;
if (!crtc->active) if (!crtc->active)
return -1; return -1;
vblank = &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
mode = &vblank->hwmode;
vtotal = mode->crtc_vtotal; vtotal = mode->crtc_vtotal;
if (mode->flags & DRM_MODE_FLAG_INTERLACE) if (mode->flags & DRM_MODE_FLAG_INTERLACE)
vtotal /= 2; vtotal /= 2;
......
...@@ -11444,12 +11444,6 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state) ...@@ -11444,12 +11444,6 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
to_intel_crtc(crtc)->config = to_intel_crtc_state(new_crtc_state); to_intel_crtc(crtc)->config = to_intel_crtc_state(new_crtc_state);
/* Update hwmode for vblank functions */
if (new_crtc_state->active)
crtc->hwmode = new_crtc_state->adjusted_mode;
else
crtc->hwmode.crtc_clock = 0;
/* /*
* Update legacy state to satisfy fbc code. This can * Update legacy state to satisfy fbc code. This can
* be removed when fbc uses the atomic state. * be removed when fbc uses the atomic state.
...@@ -15425,8 +15419,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) ...@@ -15425,8 +15419,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
to_intel_crtc_state(crtc->base.state); to_intel_crtc_state(crtc->base.state);
int pixclk = 0; int pixclk = 0;
crtc->base.hwmode = crtc_state->base.adjusted_mode;
memset(&crtc->base.mode, 0, sizeof(crtc->base.mode)); memset(&crtc->base.mode, 0, sizeof(crtc->base.mode));
if (crtc_state->base.active) { if (crtc_state->base.active) {
intel_mode_from_pipe_config(&crtc->base.mode, crtc_state); intel_mode_from_pipe_config(&crtc->base.mode, crtc_state);
...@@ -15456,7 +15448,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) ...@@ -15456,7 +15448,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled) if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled)
pixclk = DIV_ROUND_UP(pixclk * 100, 95); pixclk = DIV_ROUND_UP(pixclk * 100, 95);
drm_calc_timestamping_constants(&crtc->base, &crtc->base.hwmode); drm_calc_timestamping_constants(&crtc->base,
&crtc_state->base.adjusted_mode);
update_scanline_offset(crtc); update_scanline_offset(crtc);
} }
......
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