Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Flush the pending flips on the CRTC before modification
Date: Fri, 28 Sep 2012 13:05:51 +0300	[thread overview]
Message-ID: <20120928100551.GM19732@intel.com> (raw)
In-Reply-To: <1348777558-17881-1-git-send-email-chris@chris-wilson.co.uk>

On Thu, Sep 27, 2012 at 09:25:58PM +0100, Chris Wilson wrote:
> This was meant to be the purpose of the
> intel_crtc_wait_for_pending_flips() function which is called whilst
> preparing the CRTC for a modeset or before disabling. However, as Ville
> Syrjala pointed out, we set the pending flip notification on the old
> framebuffer that is no longer attached to the CRTC by the time we come
> to flush the pending operations. Instead, we can simply wait on the
> pending unpin work to be finished on this CRTC, knowning that the
> hardware has therefore finished modifying the registers, before proceeding
> with our direct access.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_display.c |   24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index a262326..39df185 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -2896,15 +2896,36 @@ static void ironlake_fdi_disable(struct drm_crtc *crtc)
>  	udelay(100);
>  }
>  
> +static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc)
> +{
> +	struct drm_device *dev = crtc->dev;
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +	unsigned long flags;
> +	bool pending;
> +
> +	if (atomic_read(&dev_priv->mm.wedged))
> +		return false;
> +
> +	spin_lock_irqsave(&dev->event_lock, flags);
> +	pending = to_intel_crtc(crtc)->unpin_work != NULL;
> +	spin_unlock_irqrestore(&dev->event_lock, flags);

The locking looks pointless here.

> +
> +	return pending;
> +}
> +
>  static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
>  {
>  	struct drm_device *dev = crtc->dev;
> +	struct drm_i915_private *dev_priv = dev->dev_private;
>  
>  	flush_work_sync(&to_intel_crtc(crtc)->vblank_work.work);
>  
>  	if (crtc->fb == NULL)
>  		return;
>  
> +	wait_event(dev_priv->pending_flip_queue,
> +		   !intel_crtc_has_pending_flip(crtc));
> +
>  	mutex_lock(&dev->struct_mutex);
>  	intel_finish_fb(crtc->fb);
>  	mutex_unlock(&dev->struct_mutex);
> @@ -6388,9 +6409,8 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
>  
>  	atomic_clear_mask(1 << intel_crtc->plane,
>  			  &obj->pending_flip.counter);
> -	if (atomic_read(&obj->pending_flip) == 0)
> -		wake_up(&dev_priv->pending_flip_queue);
>  
> +	wake_up(&dev_priv->pending_flip_queue);
>  	queue_work(dev_priv->wq, &work->work);
>  
>  	trace_i915_flip_complete(intel_crtc->plane, work->pending_flip_obj);

-- 
Ville Syrjälä
Intel OTC

  parent reply	other threads:[~2012-09-28 10:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27 20:25 [PATCH] drm/i915: Flush the pending flips on the CRTC before modification Chris Wilson
2012-09-28  6:37 ` Daniel Vetter
2012-09-28  8:10   ` Chris Wilson
2012-09-28 12:04   ` Chris Wilson
2012-10-02  9:52     ` Daniel Vetter
2012-09-28 10:05 ` Ville Syrjälä [this message]
2012-09-28 10:22   ` Chris Wilson
2012-09-28 10:31     ` Daniel Vetter
2012-09-28 10:45     ` Ville Syrjälä

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=20120928100551.GM19732@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox