All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 2/4] drm: Only update final vblank count when precise ts is available
Date: Thu, 11 Sep 2014 07:09:43 -0700	[thread overview]
Message-ID: <20140911140943.GA26680@intel.com> (raw)
In-Reply-To: <1410363371-11282-2-git-send-email-daniel.vetter@ffwll.ch>

On Wed, Sep 10, 2014 at 05:36:09PM +0200, Daniel Vetter wrote:
> Drivers without a hardware vblank counter simply can't account for the
> vblanks that happened while the vblank interrupt was off. To check
> this grab a vblank timestamp and if the result is dubious follow the
> normal save-and-disable logic.
> 
> Drivers should prevent this by setting vblank_disable_allowed = false,
> but since running vblank interrupts constantly is not good for power
> consumption most drivers lie. Testing for precise vblank timestamps is
> the next best thing we can check for.
> 
> Suggested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
> Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/drm_irq.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 6eb015020af2..922721ead29a 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -163,8 +163,15 @@ static void vblank_disable_and_save(struct drm_device *dev, int crtc)
>  	 * has been ticking all along until this time. This makes the
>  	 * count account for the entire time between drm_vblank_on() and
>  	 * drm_vblank_off().
> +	 *
> +	 * But only do this if precise vblank timestamps are available.
> +	 * Otherwise we might read a totally bogus timestamp since drivers
> +	 * lacking precise timestamp support rely upon sampling the system clock
> +	 * at vblank interrupt time. Which obviously won't work out well if the
> +	 * vblank interrupt is disabled.
>  	 */
> -	if (!vblank->enabled) {
> +	if (!vblank->enabled &&
> +	    drm_get_last_vbltimestamp(dev, crtc, &tvblank, 0) > 0) {
>  		drm_update_vblank_count(dev, crtc);
>  		spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
>  		return;
> -- 
> 1.9.3
> 

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795

  reply	other threads:[~2014-09-11 14:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 15:36 [PATCH 1/4] drm: Really never disable vblank irqs for offdelay==0 Daniel Vetter
2014-09-10 15:36 ` [PATCH 2/4] drm: Only update final vblank count when precise ts is available Daniel Vetter
2014-09-11 14:09   ` Matt Roper [this message]
2014-09-10 15:36 ` [PATCH 3/4] drm: Simplify return value of drm_get_last_vbltimestamp Daniel Vetter
2014-09-11 11:28   ` Mario Kleiner
2014-09-11 11:30     ` Daniel Vetter
2014-09-10 15:36 ` [PATCH 4/4] drm: Clarify vblank ts/scanoutpos sampling #defines Daniel Vetter
2014-09-10 22:24 ` [PATCH 1/4] drm: Really never disable vblank irqs for offdelay==0 Matt Roper

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=20140911140943.GA26680@intel.com \
    --to=matthew.d.roper@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.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 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.