All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 5/5] drm/vblank: Lock down vblank->hwmode more
Date: Wed, 3 May 2017 17:09:08 +0300	[thread overview]
Message-ID: <20170503140908.GL12629@intel.com> (raw)
In-Reply-To: <20170503072638.16826-6-daniel.vetter@ffwll.ch>

On Wed, May 03, 2017 at 09:26:38AM +0200, Daniel Vetter wrote:
> 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.
> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_irq.c            |  8 +++++++-
>  drivers/gpu/drm/i915/i915_irq.c      | 10 ++++++----
>  drivers/gpu/drm/i915/intel_display.c | 11 ++---------
>  3 files changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 89f0928b042a..942183a2aa3c 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -775,8 +775,10 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
>  	/* If mode timing undefined, just return as no-op:
>  	 * Happens during initial modesetting of a crtc.
>  	 */
> -	if (mode->crtc_clock == 0) {
> +	if (WARN_ON(mode->crtc_clock == 0)) {
>  		DRM_DEBUG("crtc %u: Noop due to uninitialized mode.\n", pipe);
> +		WARN_ON(drm_drv_uses_atomic_modeset(dev));

I would make these _ONCE() otherwise the machine might end up
practically dead.

> +
>  		return false;
>  	}
>  
> @@ -1338,6 +1340,10 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc)
>  		send_vblank_event(dev, e, seq, &now);
>  	}
>  	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);

Shouldn't we do this in drm_crtc_vblank_reset() as well?

Hmm. Except we call that after drm_calc_timestamping_constants(). I
guess we should be able to move the reset() into
intel_modeset_readout_hw_state(). And possibly move the vblank_on()
call as well?

>  
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 837e5bc2019a..ff18b3fc00d2 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -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);
>  	i915_reg_t high_frame, low_frame;
>  	u32 high1, high2, low, pixel, vbl_start, hsync_start, htotal;
> -	struct intel_crtc *intel_crtc = intel_get_crtc_for_pipe(dev_priv,
> -								pipe);
> -	const struct drm_display_mode *mode = &intel_crtc->base.hwmode;
> +	const struct drm_display_mode *mode = &dev->vblank[pipe].hwmode;
>  	unsigned long irqflags;
>  
>  	htotal = mode->crtc_htotal;
> @@ -779,13 +777,17 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
>  {
>  	struct drm_device *dev = crtc->base.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;
>  	int position, vtotal;
>  
>  	if (!crtc->active)
>  		return -1;
>  
> +	vblank = &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
> +	mode = &vblank->hwmode;
> +
>  	vtotal = mode->crtc_vtotal;
>  	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
>  		vtotal /= 2;
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 85b9e2f521a0..a190973daeee 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -11443,12 +11443,6 @@ intel_modeset_update_crtc_state(struct drm_atomic_state *state)
>  	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
>  		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
>  		 * be removed when fbc uses the atomic state.
> @@ -15425,8 +15419,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
>  			to_intel_crtc_state(crtc->base.state);
>  		int pixclk = 0;
>  
> -		crtc->base.hwmode = crtc_state->base.adjusted_mode;
> -
>  		memset(&crtc->base.mode, 0, sizeof(crtc->base.mode));
>  		if (crtc_state->base.active) {
>  			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)
>  			if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled)
>  				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);
>  		}
>  
> -- 
> 2.11.0

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-05-03 14:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03  7:26 [PATCH 0/5] vblanke cleanup resend Daniel Vetter
2017-05-03  7:26 ` [PATCH 1/5] drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool Daniel Vetter
2017-05-03  7:26 ` [PATCH 2/5] drm/vblank: Switch to bool in_vblank_irq in get_vblank_timestamp Daniel Vetter
2017-05-04 10:08   ` kbuild test robot
2017-05-03  7:26 ` [PATCH 3/5] drm/vblank: Add FIXME comments about moving the vblank ts hooks Daniel Vetter
2017-05-03  7:26 ` [PATCH 4/5] drm/vblank: drop the mode argument from drm_calc_vbltimestamp_from_scanoutpos Daniel Vetter
2017-05-03  7:26 ` [PATCH 5/5] drm/vblank: Lock down vblank->hwmode more Daniel Vetter
2017-05-03 14:09   ` Ville Syrjälä [this message]
2017-05-04 13:20     ` Daniel Vetter
2017-05-08 11:33       ` Ville Syrjälä
2017-05-03  7:46 ` ✓ Fi.CI.BAT: success for vblanke cleanup resend Patchwork
2017-05-09 14:03 [PATCH 1/5] drm/vblank: Switch drm_driver->get_vblank_timestamp to return a bool Daniel Vetter
2017-05-09 14:03 ` [PATCH 5/5] drm/vblank: Lock down vblank->hwmode more Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170503140908.GL12629@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.