dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: "Daniel Vetter" <daniel.vetter@ffwll.ch>,
	intel-gfx@lists.freedesktop.org,
	"Michel Dänzer" <michel@daenzer.net>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/5] drm/vblank: Do not update vblank count if interrupts are already disabled.
Date: Thu, 18 Jan 2018 23:47:22 -0800	[thread overview]
Message-ID: <20180119074722.33k62hgprh2u2ixu@intel.com> (raw)
In-Reply-To: <20180112215707.3084-3-dhinakaran.pandiyan@intel.com>

On Fri, Jan 12, 2018 at 09:57:05PM +0000, Dhinakaran Pandiyan wrote:
> Updating vblank counts requires register reads and these reads may not
> return meaningful values if the device was in a low power state after
> vblank interrupts were last disabled. So, update the count only if vblank
> interrupts are enabled. Secondly, this means the registers should be read
> before disabling vblank interrupts.
> 
> v2: Don't check vblank->enabled outside it's lock (Chris)
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Michel Dänzer <michel@daenzer.net>
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> ---
>  drivers/gpu/drm/drm_vblank.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index f2bf1f5dbaa5..2559d2d7b907 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -347,23 +347,25 @@ void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
>  	spin_lock_irqsave(&dev->vblank_time_lock, irqflags);
>  
>  	/*
> -	 * Only disable vblank interrupts if they're enabled. This avoids
> -	 * calling the ->disable_vblank() operation in atomic context with the
> -	 * hardware potentially runtime suspended.
> +	 * Update vblank count and disable vblank interrupts only if the
> +	 * interrupts were enabled. This avoids calling the ->disable_vblank()
> +	 * operation in atomic context with the hardware potentially runtime
> +	 * suspended.
>  	 */
> -	if (vblank->enabled) {
> -		__disable_vblank(dev, pipe);
> -		vblank->enabled = false;
> -	}
> +	if (!vblank->enabled)
> +		goto out;
>  
>  	/*
> -	 * Always update the count and timestamp to maintain the
> +	 * Update the count and timestamp to maintain the
>  	 * appearance that the counter has been ticking all along until
>  	 * this time. This makes the count account for the entire time
>  	 * between drm_crtc_vblank_on() and drm_crtc_vblank_off().
>  	 */

I feel that this entire comment can be simply removed now...
The approach looks good and right to me so you can use

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

but please ping Ville to take a look here since he introduced this approach with
4dfd64862ff8 ("drm: Use vblank timestamps to guesstimate how many vblanks were missed")

>  	drm_update_vblank_count(dev, pipe, false);
> +	__disable_vblank(dev, pipe);
> +	vblank->enabled = false;
>  
> +out:
>  	spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
>  }
>  
> -- 
> 2.11.0
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-01-19  7:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 21:57 [PATCH 1/5] drm/vblank: Fix return type for drm_vblank_count() Dhinakaran Pandiyan
2018-01-12 21:57 ` [PATCH 2/5] drm/vblank: Fix data type width for drm_crtc_arm_vblank_event() Dhinakaran Pandiyan
2018-01-19  7:39   ` Rodrigo Vivi
2018-01-31  6:49   ` Keith Packard
2018-01-12 21:57 ` [PATCH 3/5] drm/vblank: Do not update vblank count if interrupts are already disabled Dhinakaran Pandiyan
2018-01-19  7:47   ` Rodrigo Vivi [this message]
2018-01-12 21:57 ` [PATCH 4/5] drm/vblank: Restoring vblank counts after device PM events Dhinakaran Pandiyan
2018-01-19  8:01   ` Rodrigo Vivi
2018-01-19 22:02     ` Pandiyan, Dhinakaran
2018-01-19 22:44       ` [Intel-gfx] " Rodrigo Vivi
2018-01-12 21:57 ` [PATCH 5/5] drm/i915: Estimate and update missed vblanks Dhinakaran Pandiyan
2018-01-15  9:45   ` Daniel Vetter
2018-01-19  7:26   ` Rodrigo Vivi
2018-01-19 21:42     ` [Intel-gfx] " Pandiyan, Dhinakaran
2018-01-19 22:45       ` Rodrigo Vivi
2018-01-15  9:38 ` [PATCH 1/5] drm/vblank: Fix return type for drm_vblank_count() Daniel Vetter
2018-01-16 21:26   ` [Intel-gfx] " Pandiyan, Dhinakaran
2018-01-19  4:53 ` Pandiyan, Dhinakaran
2018-01-19  8:03   ` Rodrigo Vivi
2018-01-19  7:36 ` Rodrigo Vivi
2018-01-19 21:30   ` Pandiyan, Dhinakaran
2018-01-31  6:42 ` Keith Packard

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=20180119074722.33k62hgprh2u2ixu@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dhinakaran.pandiyan@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=michel@daenzer.net \
    /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