From patchwork Mon May 2 00:09:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher James Halse Rogers X-Patchwork-Id: 746482 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p420A3hL027636 for ; Mon, 2 May 2011 00:10:25 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4BD4A9E95F for ; Sun, 1 May 2011 17:10:02 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DED39E782 for ; Sun, 1 May 2011 17:09:54 -0700 (PDT) Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QGgi1-0001rZ-Aj; Mon, 02 May 2011 00:09:53 +0000 Received: from ppp105-211.static.internode.on.net ([150.101.105.211] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QGgi0-0006qh-Er; Mon, 02 May 2011 00:09:53 +0000 From: christopher.halse.rogers@canonical.com To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Factor-out drm_emit_vblank_event code. (v3) Date: Mon, 2 May 2011 10:09:31 +1000 Message-Id: <1304294971-5539-1-git-send-email-christopher.halse.rogers@canonical.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <20110429155528.GA3022@joi.lan> References: <20110429155528.GA3022@joi.lan> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 02 May 2011 00:10:26 +0000 (UTC) From: Christopher James Halse Rogers v2: Also pull out the drm_vblank_put call. v3: Always set the reply.sequence value properly. Signed-off-by: Christopher James Halse Rogers --- drivers/gpu/drm/drm_irq.c | 43 ++++++++++++++++++------------------------- 1 files changed, 18 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 982ca8c..c05fe41 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,11 @@ 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); + drm_emit_vblank_event(dev, e, seq, &now); vblwait->reply.sequence = seq; - trace_drm_vblank_event_delivered(current->pid, pipe, - vblwait->request.sequence); } else { - list_add_tail(&e->base.link, &dev->vblank_event_list); vblwait->reply.sequence = vblwait->request.sequence; } @@ -1249,14 +1249,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);