diff mbox

[2/3] drm: Skip the waitqueue setup for vblank queries

Message ID 20170315204027.20160-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson March 15, 2017, 8:40 p.m. UTC
Avoid adding to the waitqueue and reprobing the current vblank if the
caller is only querying the current vblank sequence and timestamp, where
we know that the wait would return immediately.

v2: Add CRTC identifier to debug messages

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Michel Dänzer <michel@daenzer.net>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Dave Airlie <airlied@redhat.com>,
Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Michel Dänzer <michel@daenzer.net>
Reviewed-and-tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
---
 drivers/gpu/drm/drm_irq.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

Comments

Daniel Vetter March 16, 2017, 9:23 a.m. UTC | #1
On Wed, Mar 15, 2017 at 08:40:26PM +0000, Chris Wilson wrote:
> Avoid adding to the waitqueue and reprobing the current vblank if the
> caller is only querying the current vblank sequence and timestamp, where
> we know that the wait would return immediately.
> 
> v2: Add CRTC identifier to debug messages
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Michel Dänzer <michel@daenzer.net>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Dave Airlie <airlied@redhat.com>,
> Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
> Reviewed-by: Michel Dänzer <michel@daenzer.net>
> Reviewed-and-tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>

Merged the first two from this series, thanks.
-Daniel

> ---
>  drivers/gpu/drm/drm_irq.c | 24 +++++++++++++-----------
>  1 file changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index e64b05ea95ea..53a526c7b24d 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -1610,7 +1610,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
>  
>  	ret = drm_vblank_get(dev, pipe);
>  	if (ret) {
> -		DRM_DEBUG("failed to acquire vblank counter, %d\n", ret);
> +		DRM_DEBUG("crtc %d failed to acquire vblank counter, %d\n", pipe, ret);
>  		return ret;
>  	}
>  	seq = drm_vblank_count(dev, pipe);
> @@ -1638,13 +1638,15 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
>  		return drm_queue_vblank_event(dev, pipe, vblwait, file_priv);
>  	}
>  
> -	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->enabled ||
> -		     !dev->irq_enabled));
> +	if (vblwait->request.sequence != seq) {
> +		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->enabled ||
> +			     !dev->irq_enabled));
> +	}
>  
>  	if (ret != -EINTR) {
>  		struct timeval now;
> @@ -1653,10 +1655,10 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
>  		vblwait->reply.tval_sec = now.tv_sec;
>  		vblwait->reply.tval_usec = now.tv_usec;
>  
> -		DRM_DEBUG("returning %u to client\n",
> -			  vblwait->reply.sequence);
> +		DRM_DEBUG("crtc %d returning %u to client\n",
> +			  pipe, vblwait->reply.sequence);
>  	} else {
> -		DRM_DEBUG("vblank wait interrupted by signal\n");
> +		DRM_DEBUG("crtc %d vblank wait interrupted by signal\n", pipe);
>  	}
>  
>  done:
> -- 
> 2.11.0
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index e64b05ea95ea..53a526c7b24d 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1610,7 +1610,7 @@  int drm_wait_vblank(struct drm_device *dev, void *data,
 
 	ret = drm_vblank_get(dev, pipe);
 	if (ret) {
-		DRM_DEBUG("failed to acquire vblank counter, %d\n", ret);
+		DRM_DEBUG("crtc %d failed to acquire vblank counter, %d\n", pipe, ret);
 		return ret;
 	}
 	seq = drm_vblank_count(dev, pipe);
@@ -1638,13 +1638,15 @@  int drm_wait_vblank(struct drm_device *dev, void *data,
 		return drm_queue_vblank_event(dev, pipe, vblwait, file_priv);
 	}
 
-	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->enabled ||
-		     !dev->irq_enabled));
+	if (vblwait->request.sequence != seq) {
+		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->enabled ||
+			     !dev->irq_enabled));
+	}
 
 	if (ret != -EINTR) {
 		struct timeval now;
@@ -1653,10 +1655,10 @@  int drm_wait_vblank(struct drm_device *dev, void *data,
 		vblwait->reply.tval_sec = now.tv_sec;
 		vblwait->reply.tval_usec = now.tv_usec;
 
-		DRM_DEBUG("returning %u to client\n",
-			  vblwait->reply.sequence);
+		DRM_DEBUG("crtc %d returning %u to client\n",
+			  pipe, vblwait->reply.sequence);
 	} else {
-		DRM_DEBUG("vblank wait interrupted by signal\n");
+		DRM_DEBUG("crtc %d vblank wait interrupted by signal\n", pipe);
 	}
 
 done: