dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: christopher.halse.rogers@canonical.com
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm: Send pending vblank events before disabling vblank.
Date: Thu, 28 Apr 2011 13:34:14 -0700	[thread overview]
Message-ID: <20110428133414.270834b5@jbarnes-desktop> (raw)
In-Reply-To: <1303884659-739-1-git-send-email-christopher.halse.rogers@canonical.com>

On Wed, 27 Apr 2011 16:10:57 +1000
christopher.halse.rogers@canonical.com wrote:

> From: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
> 
> This is the least-bad behaviour.  It means that we signal the
> vblank event before it actually happens, but since we're disabling
> vblanks there's no guarantee that it will *ever* happen otherwise.
> 
> This prevents GL applications which use WaitMSC from hanging
> indefinitely.
> 
> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
> ---
>  drivers/gpu/drm/drm_irq.c |   23 +++++++++++++++++++++++
>  1 files changed, 23 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 741457b..a1f12cb 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -932,11 +932,34 @@ EXPORT_SYMBOL(drm_vblank_put);
>  
>  void drm_vblank_off(struct drm_device *dev, int crtc)
>  {
> +	struct drm_pending_vblank_event *e, *t;
> +	struct timeval now;
>  	unsigned long irqflags;
> +	unsigned int seq;
>  
>  	spin_lock_irqsave(&dev->vbl_lock, irqflags);
>  	vblank_disable_and_save(dev, crtc);
>  	DRM_WAKEUP(&dev->vbl_queue[crtc]);
> +
> +	/* Send any queued vblank events, lest the natives grow disquiet */
> +	seq = drm_vblank_count_and_time(dev, crtc, &now);
> +	list_for_each_entry_safe(e, t, &dev->vblank_event_list, base.link) {
> +		if (e->pipe != crtc)
> +			continue;
> +		DRM_DEBUG("Sending premature vblank event on disable: \
> +			  wanted %d, current %d\n",
> +			  e->event.sequence, seq);
> +
> +		e->event.sequence = seq;
> +		e->event.tv_sec = now.tv_sec;
> +		e->event.tv_usec = now.tv_usec;
> +		drm_vblank_put(dev, e->pipe);
> +		list_move_tail(&e->base.link, &e->base.file_priv->event_list);
> +		wake_up_interruptible(&e->base.file_priv->event_wait);
> +		trace_drm_vblank_event_delivered(e->base.pid, e->pipe,
> +						 e->event.sequence);
> +	}
> +
>  	spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
>  }
>  EXPORT_SYMBOL(drm_vblank_off);

Yeah, this matches what we do for the blocking waits, and it's probably
a good idea.  Userspace can decide what to do with apps running against
a disabled CRTC.

Would be nice to share the code with drm_handle_vblank_events though
somehow.  Looks like

		e->event.sequence = seq;
		e->event.tv_sec = now.tv_sec;
		e->event.tv_usec = now.tv_usec;
		drm_vblank_put(dev, e->pipe);
		list_move_tail(&e->base.link, &e->base.file_priv->event_list);
		wake_up_interruptible(&e->base.file_priv->event_wait);
		trace_drm_vblank_event_delivered(e->base.pid, e->pipe,
						 e->event.sequence);

could be pulled out into a separate function for both to use.

-- 
Jesse Barnes, Intel Open Source Technology Center

      parent reply	other threads:[~2011-04-28 20:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27  6:10 [PATCH 1/3] drm: Send pending vblank events before disabling vblank christopher.halse.rogers
2011-04-27  6:10 ` [PATCH 2/3] drm: Warn if vblank state has become inconsistent christopher.halse.rogers
2011-04-27  8:38   ` Michel Dänzer
2011-04-27  6:10 ` [PATCH 3/3] drm: Factor-out drm_emit_vblank_event code christopher.halse.rogers
2011-04-27  8:36   ` Michel Dänzer
2011-04-27  8:48     ` Christopher James Halse Rogers
2011-04-27  9:06       ` Michel Dänzer
2011-04-28 20:36   ` Jesse Barnes
2011-04-29  3:57     ` [PATCH] drm: Factor-out drm_emit_vblank_event code. (v2) christopher.halse.rogers
2011-04-29  6:43       ` Michel Dänzer
2011-04-29 15:55       ` Marcin Slusarz
2011-05-01 23:55         ` Christopher James Halse Rogers
2011-05-02  0:09         ` [PATCH] drm: Factor-out drm_emit_vblank_event code. (v3) christopher.halse.rogers
2011-04-27  8:32 ` [PATCH 1/3] drm: Send pending vblank events before disabling vblank Michel Dänzer
2011-04-27  8:58   ` Christopher James Halse Rogers
2011-04-27  9:08     ` Michel Dänzer
2011-04-27  9:17       ` Christopher James Halse Rogers
2011-04-28  8:09       ` Christopher James Halse Rogers
2011-04-28 20:46         ` Jesse Barnes
2011-04-28 20:53           ` Jesse Barnes
2011-04-28 20:42   ` Jesse Barnes
2011-04-28 20:34 ` Jesse Barnes [this message]

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=20110428133414.270834b5@jbarnes-desktop \
    --to=jbarnes@virtuousgeek.org \
    --cc=christopher.halse.rogers@canonical.com \
    --cc=dri-devel@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