All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel@daenzer.net>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/4] drm: Refactor vblank sequence number comparison
Date: Wed, 22 Mar 2017 17:54:49 +0900	[thread overview]
Message-ID: <d60796bd-f662-c1ea-67d3-7629e5236ec7@daenzer.net> (raw)
In-Reply-To: <20170317202030.24410-3-chris@chris-wilson.co.uk>

On 18/03/17 05:20 AM, Chris Wilson wrote:
> Move the repeated (a - b) <= (1 << 23) to its own function.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_irq.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index a164cf51d093..253505da57bd 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -1492,6 +1492,11 @@ int drm_legacy_modeset_ctl(struct drm_device *dev, void *data,
>  	return 0;
>  }
>  
> +static inline bool vblank_passed(u32 seq, u32 ref)
> +{
> +	return (seq - ref) <= (1 << 23);
> +}

As a followup, maybe we could try changing this to

    return (s32)(seq - ref) >= 0;


> @@ -1542,7 +1547,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
>  				      vblwait->request.sequence);
>  
>  	e->event.sequence = vblwait->request.sequence;
> -	if ((seq - vblwait->request.sequence) <= (1 << 23)) {
> +	if (vblank_passed(seq, vblwait->request.sequence)) {
>  		drm_vblank_put(dev, pipe);
>  		send_vblank_event(dev, e, seq, &now);
>  		vblwait->reply.sequence = seq;
> @@ -1632,9 +1637,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
>  	}
>  
>  	if ((flags & _DRM_VBLANK_NEXTONMISS) &&
> -	    (seq - vblwait->request.sequence) <= (1 << 23)) {
> +	    vblank_passed(seq, vblwait->request.sequence))
>  		vblwait->request.sequence = seq + 1;
> -	}
>  
>  	if (flags & _DRM_VBLANK_EVENT) {
>  		/* must hold on to the vblank ref until the event fires
> @@ -1647,8 +1651,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
>  		DRM_DEBUG("waiting on vblank count %u, crtc %u\n",
>  			  vblwait->request.sequence, pipe);
>  		DRM_WAIT_ON(ret, vblank->queue, 3 * HZ,
> -			    (drm_vblank_count(dev, pipe) -
> -			     vblwait->request.sequence) <= (1 << 23) ||
> +			    vblank_passed(drm_vblank_count(dev, pipe),
> +					  vblwait->request.sequence) ||
>  			    !READ_ONCE(vblank->enabled));
>  	}
>  
> 

There's another instance in drm_handle_vblank_events.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-03-22  8:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17 20:20 [PATCH v2 1/4] drm: Mark up accesses of vblank->enabled outside of its spinlock Chris Wilson
2017-03-17 20:20 ` [PATCH v2 2/4] drm: vblank cannot be enabled if dev->irq_enabled is false Chris Wilson
2017-03-17 20:20 ` [PATCH v2 3/4] drm: Refactor vblank sequence number comparison Chris Wilson
2017-03-22  8:54   ` Michel Dänzer [this message]
2017-03-22 10:06   ` [PATCH v2] " Chris Wilson
2017-03-23  3:23     ` Michel Dänzer
2017-03-29 11:32       ` Ville Syrjälä
2017-03-17 20:20 ` [PATCH v2 4/4] drm: Peek at the current counter/timestamp for vblank queries Chris Wilson
2017-03-17 20:37 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/4] drm: Mark up accesses of vblank->enabled outside of its spinlock Patchwork
2017-03-17 20:44 ` [PATCH v2 1/4] " Ville Syrjälä
2017-03-22 10:37 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/4] drm: Mark up accesses of vblank->enabled outside of its spinlock (rev2) Patchwork

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=d60796bd-f662-c1ea-67d3-7629e5236ec7@daenzer.net \
    --to=michel@daenzer.net \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --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.