diff mbox

drm: Factor-out drm_emit_vblank_event code. (v2)

Message ID 1304049430-10109-1-git-send-email-christopher.halse.rogers@canonical.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christopher James Halse Rogers April 29, 2011, 3:57 a.m. UTC
From: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>

v2: Also pull out the drm_vblank_put call.
Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
---
 drivers/gpu/drm/drm_irq.c |   44 ++++++++++++++++++--------------------------
 1 files changed, 18 insertions(+), 26 deletions(-)

Comments

Michel Dänzer April 29, 2011, 6:43 a.m. UTC | #1
On Fre, 2011-04-29 at 13:57 +1000, christopher.halse.rogers@canonical.com wrote:
> From: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
> 
> v2: Also pull out the drm_vblank_put call.
> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>

Reviewed-by: Michel Dänzer <michel@daenzer.net>
Marcin Ślusarz April 29, 2011, 3:55 p.m. UTC | #2
On Fri, Apr 29, 2011 at 01:57:10PM +1000, christopher.halse.rogers@canonical.com wrote:
> From: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
> 
> v2: Also pull out the drm_vblank_put call.
> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
> ---
>  drivers/gpu/drm/drm_irq.c |   44 ++++++++++++++++++--------------------------
>  1 files changed, 18 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 982ca8c..da56685 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -931,6 +931,20 @@ void drm_vblank_put(struct drm_device *dev, int crtc)
>  }
>  EXPORT_SYMBOL(drm_vblank_put);
>  
> +static void drm_emit_vblank_event (struct drm_device *dev,
> +				   struct drm_pending_vblank_event *e,
> +				   unsigned int seq, struct timeval *now)
> +{
> +	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);
> +}
> +
>  void drm_vblank_off(struct drm_device *dev, int crtc)
>  {
>  	struct drm_pending_vblank_event *e, *t;
> @@ -951,14 +965,7 @@ void drm_vblank_off(struct drm_device *dev, int crtc)
>  			  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);
> +		drm_emit_vblank_event(dev, e, seq, &now);
>  	}
>  
>  	WARN_ON(atomic_read(&dev->vblank_refcount[crtc]) != 0);
> @@ -1104,18 +1111,10 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
>  				      vblwait->request.sequence);
>  
>  	e->event.sequence = vblwait->request.sequence;
> +	list_add_tail(&e->base.link, &dev->vblank_event_list);

Is &dev->vblank_event_list == &e->base.file_priv->event_list?
If they are not equal this is changing the behavior...

>  	if ((seq - vblwait->request.sequence) <= (1 << 23)) {
> -		e->event.sequence = seq;
> -		e->event.tv_sec = now.tv_sec;
> -		e->event.tv_usec = now.tv_usec;
> -		drm_vblank_put(dev, pipe);
> -		list_add_tail(&e->base.link, &e->base.file_priv->event_list);
> -		wake_up_interruptible(&e->base.file_priv->event_wait);
> -		vblwait->reply.sequence = seq;

Is it OK to drop this substitution?

> -		trace_drm_vblank_event_delivered(current->pid, pipe,
> -						 vblwait->request.sequence);
> +		drm_emit_vblank_event(dev, e, seq, &now);
>  	} else {
> -		list_add_tail(&e->base.link, &dev->vblank_event_list);
>  		vblwait->reply.sequence = vblwait->request.sequence;
>  	}
>  
> @@ -1249,14 +1248,7 @@ void drm_handle_vblank_events(struct drm_device *dev, int crtc)
>  		DRM_DEBUG("vblank event on %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);
> +		drm_emit_vblank_event(dev, e, seq, &now);
>  	}
>  
>  	spin_unlock_irqrestore(&dev->event_lock, flags);
> --
Christopher James Halse Rogers May 1, 2011, 11:55 p.m. UTC | #3
On Fri, 2011-04-29 at 17:55 +0200, Marcin Slusarz wrote:
> On Fri, Apr 29, 2011 at 01:57:10PM +1000, christopher.halse.rogers@canonical.com wrote:
> > From: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
> > 
> > v2: Also pull out the drm_vblank_put call.
> > Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
> > ---
> >  drivers/gpu/drm/drm_irq.c |   44 ++++++++++++++++++--------------------------
> >  1 files changed, 18 insertions(+), 26 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> > index 982ca8c..da56685 100644
> > --- a/drivers/gpu/drm/drm_irq.c
> > +++ b/drivers/gpu/drm/drm_irq.c
> > @@ -931,6 +931,20 @@ void drm_vblank_put(struct drm_device *dev, int crtc)
> >  }
> >  EXPORT_SYMBOL(drm_vblank_put);
> >  
> > +static void drm_emit_vblank_event (struct drm_device *dev,
> > +				   struct drm_pending_vblank_event *e,
> > +				   unsigned int seq, struct timeval *now)
> > +{
> > +	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);
> > +}
> > +
> >  void drm_vblank_off(struct drm_device *dev, int crtc)
> >  {
> >  	struct drm_pending_vblank_event *e, *t;
> > @@ -951,14 +965,7 @@ void drm_vblank_off(struct drm_device *dev, int crtc)
> >  			  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);
> > +		drm_emit_vblank_event(dev, e, seq, &now);
> >  	}
> >  
> >  	WARN_ON(atomic_read(&dev->vblank_refcount[crtc]) != 0);
> > @@ -1104,18 +1111,10 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
> >  				      vblwait->request.sequence);
> >  
> >  	e->event.sequence = vblwait->request.sequence;
> > +	list_add_tail(&e->base.link, &dev->vblank_event_list);
> 
> Is &dev->vblank_event_list == &e->base.file_priv->event_list?
> If they are not equal this is changing the behavior...

This gets moved to e->base.file_priv->event_list in
drm_emit_vblank_event ().  So it's doing a bit of useless work setting a
couple of pointers, but this doesn't change the behaviour.

> 
> >  	if ((seq - vblwait->request.sequence) <= (1 << 23)) {
> > -		e->event.sequence = seq;
> > -		e->event.tv_sec = now.tv_sec;
> > -		e->event.tv_usec = now.tv_usec;
> > -		drm_vblank_put(dev, pipe);
> > -		list_add_tail(&e->base.link, &e->base.file_priv->event_list);
> > -		wake_up_interruptible(&e->base.file_priv->event_wait);
> > -		vblwait->reply.sequence = seq;
> 
> Is it OK to drop this substitution?

Ahem.  No, it's not.  That's an overzealous delete key going off.  Hm.
Either the clients I was testing don't care about the reply, or the
clients I was testing always set _DRM_BLANK_NEXTONMISS.  I think it's
the latter.

Updated patch coming.

> 
> > -		trace_drm_vblank_event_delivered(current->pid, pipe,
> > -						 vblwait->request.sequence);
> > +		drm_emit_vblank_event(dev, e, seq, &now);
> >  	} else {
> > -		list_add_tail(&e->base.link, &dev->vblank_event_list);
> >  		vblwait->reply.sequence = vblwait->request.sequence;
> >  	}
> >  
> > @@ -1249,14 +1248,7 @@ void drm_handle_vblank_events(struct drm_device *dev, int crtc)
> >  		DRM_DEBUG("vblank event on %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);
> > +		drm_emit_vblank_event(dev, e, seq, &now);
> >  	}
> >  
> >  	spin_unlock_irqrestore(&dev->event_lock, flags);
> > --
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 982ca8c..da56685 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -931,6 +931,20 @@  void drm_vblank_put(struct drm_device *dev, int crtc)
 }
 EXPORT_SYMBOL(drm_vblank_put);
 
+static void drm_emit_vblank_event (struct drm_device *dev,
+				   struct drm_pending_vblank_event *e,
+				   unsigned int seq, struct timeval *now)
+{
+	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);
+}
+
 void drm_vblank_off(struct drm_device *dev, int crtc)
 {
 	struct drm_pending_vblank_event *e, *t;
@@ -951,14 +965,7 @@  void drm_vblank_off(struct drm_device *dev, int crtc)
 			  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);
+		drm_emit_vblank_event(dev, e, seq, &now);
 	}
 
 	WARN_ON(atomic_read(&dev->vblank_refcount[crtc]) != 0);
@@ -1104,18 +1111,10 @@  static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
 				      vblwait->request.sequence);
 
 	e->event.sequence = vblwait->request.sequence;
+	list_add_tail(&e->base.link, &dev->vblank_event_list);
 	if ((seq - vblwait->request.sequence) <= (1 << 23)) {
-		e->event.sequence = seq;
-		e->event.tv_sec = now.tv_sec;
-		e->event.tv_usec = now.tv_usec;
-		drm_vblank_put(dev, pipe);
-		list_add_tail(&e->base.link, &e->base.file_priv->event_list);
-		wake_up_interruptible(&e->base.file_priv->event_wait);
-		vblwait->reply.sequence = seq;
-		trace_drm_vblank_event_delivered(current->pid, pipe,
-						 vblwait->request.sequence);
+		drm_emit_vblank_event(dev, e, seq, &now);
 	} else {
-		list_add_tail(&e->base.link, &dev->vblank_event_list);
 		vblwait->reply.sequence = vblwait->request.sequence;
 	}
 
@@ -1249,14 +1248,7 @@  void drm_handle_vblank_events(struct drm_device *dev, int crtc)
 		DRM_DEBUG("vblank event on %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);
+		drm_emit_vblank_event(dev, e, seq, &now);
 	}
 
 	spin_unlock_irqrestore(&dev->event_lock, flags);