From patchwork Tue May 21 08:08:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 2596391 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 46327DFE75 for ; Tue, 21 May 2013 08:08:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38A7FE60B8 for ; Tue, 21 May 2013 01:08:45 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D719E5D51 for ; Tue, 21 May 2013 01:08:33 -0700 (PDT) Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MN500CRL2LBAPX0@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 21 May 2013 17:08:19 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.116]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 4E.35.17404.37B2B915; Tue, 21 May 2013 17:08:19 +0900 (KST) X-AuditID: cbfee68d-b7f096d0000043fc-98-519b2b738d29 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 1F.45.17674.37B2B915; Tue, 21 May 2013 17:08:19 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.90.8.53]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MN500K562LUBOF0@mmp1.samsung.com>; Tue, 21 May 2013 17:08:19 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/exynos: wait for the completion of pending page flip Date: Tue, 21 May 2013 17:08:18 +0900 Message-id: <1369123698-19503-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.5.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsWyRsSkRLdYe3agwZ//0hZXvr5ns5h0fwKL xYt7F1kszja9YbeYMfklmwOrx/3u40wefVtWMQYwRXHZpKTmZJalFunbJXBlzG+dxF7wWaxi 9s/nbA2MK4S7GDk4JARMJN6viO5i5AQyxSQu3FvP1sXIxSEksJRRouvvDRaIhIlE64oLLBCJ RYwSzf+WMkM4XUwSt/qfMYNUsQmoSkxccZ8NxBYRUJb4O3EVI4jNLJAm8f37XnYQW1jAU+LM 88lgNSxA9Qd+HQHr5RVwkXj9Yg8rxDYFiV9HVrGCLJAQuM8m8WnqfVaIBgGJb5MPsUCcLSux 6QAzRL2kxMEVN1gmMAouYGRYxSiaWpBcUJyUXmSoV5yYW1yal66XnJ+7iREYhqf/PevdwXj7 gPUhxmSgcROZpUST84FhnFcSb2hsZmRhamJqbGRuaUaasJI4r1qLdaCQQHpiSWp2ampBalF8 UWlOavEhRiYOTqkGxjYWo32sWu1Pwx6ybVgv9VT2cNUi9V6VrXrFIdb1S4KWdMyv4EjXdax4 fILh2jVbLlHx2X+/5PT2pJr0xovX93oKu3/9/PRnSXnR8UMHDD5MzL73dO2Ud4KnDsg/ND/1 Uuqf+93z1byaBiJhu1QX6/KsPWT5at6mR77MZ40072a0TVOfnOG5QomlOCPRUIu5qDgRANgv Q6xZAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRmVeSWpSXmKPExsVy+t9jAd1i7dmBBmsOCFtc+fqezWLS/Qks Fi/uXWSxONv0ht1ixuSXbA6sHve7jzN59G1ZxRjAFNXAaJORmpiSWqSQmpecn5KZl26r5B0c 7xxvamZgqGtoaWGupJCXmJtqq+TiE6DrlpkDtE9JoSwxpxQoFJBYXKykb4dpQmiIm64FTGOE rm9IEFyPkQEaSFjDmDG/dRJ7wWexitk/n7M1MK4Q7mLk5JAQMJFoXXGBBcIWk7hwbz1bFyMX h5DAIkaJ5n9LmSGcLiaJW/3PmEGq2ARUJSauuM8GYosIKEv8nbiKEcRmFkiT+P59LzuILSzg KXHm+WSwGhag+gO/joD18gq4SLx+sYcVYpuCxK8jq1gnMHIvYGRYxSiaWpBcUJyUnmukV5yY W1yal66XnJ+7iREc5s+kdzCuarA4xCjAwajEwytgOCtQiDWxrLgy9xCjBAezkghvnersQCHe lMTKqtSi/Pii0pzU4kOMyUDbJzJLiSbnA2MwryTe0NjEzMjSyNzQwsjYnDRhJXHeg63WgUIC 6YklqdmpqQWpRTBbmDg4pRoYvZm6/dd2s5VeVpnKsLtnQZPt7P9bO5niD3p+NZS1W1Lx+WjG C7GlCyt/fLjuUd2VqTLzjPqKC9Wn7ct2HLjv63bH8mJSaeHhqzJ6ez8cNtq27JqPw/bXM+rz +M0jVkZ/143pza/bbBTKrtzRJ/p2Y/hMD+FrF483TD/z5POmI3JvExLN70cmK7EUZyQaajEX FScCAItBotu3AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: kyungmin.park@samsung.com, sw0312.kim@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 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 This patch fixes the issue that drm_vblank_get() is failed. The issus occurs when next page flip request is tried if previous page flip event wasn't completed yet and then dpms became off. So this patch make sure that page flip event is completed before dpms goes to off. Signed-off-by: Inki Dae Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index e8894bc..69a77e9 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c @@ -48,6 +48,8 @@ struct exynos_drm_crtc { unsigned int pipe; unsigned int dpms; enum exynos_crtc_mode mode; + wait_queue_head_t pending_flip_queue; + atomic_t pending_flip; }; static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode) @@ -61,6 +63,13 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode) return; } + if (mode > DRM_MODE_DPMS_ON) { + /* wait for the completion of page flip. */ + wait_event(exynos_crtc->pending_flip_queue, + atomic_read(&exynos_crtc->pending_flip) == 0); + drm_vblank_off(crtc->dev, exynos_crtc->pipe); + } + exynos_drm_fn_encoder(crtc, &mode, exynos_drm_encoder_crtc_dpms); exynos_crtc->dpms = mode; } @@ -225,6 +234,7 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc, spin_lock_irq(&dev->event_lock); list_add_tail(&event->base.link, &dev_priv->pageflip_event_list); + atomic_set(&exynos_crtc->pending_flip, 1); spin_unlock_irq(&dev->event_lock); crtc->fb = fb; @@ -344,6 +354,8 @@ int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr) exynos_crtc->pipe = nr; exynos_crtc->dpms = DRM_MODE_DPMS_OFF; + init_waitqueue_head(&exynos_crtc->pending_flip_queue); + atomic_set(&exynos_crtc->pending_flip, 0); exynos_crtc->plane = exynos_plane_init(dev, 1 << nr, true); if (!exynos_crtc->plane) { kfree(exynos_crtc); @@ -398,6 +410,8 @@ void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int crtc) { struct exynos_drm_private *dev_priv = dev->dev_private; struct drm_pending_vblank_event *e, *t; + struct drm_crtc *drm_crtc = dev_priv->crtc[crtc]; + struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(drm_crtc); struct timeval now; unsigned long flags; @@ -419,6 +433,8 @@ void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int crtc) list_move_tail(&e->base.link, &e->base.file_priv->event_list); wake_up_interruptible(&e->base.file_priv->event_wait); drm_vblank_put(dev, crtc); + atomic_set(&exynos_crtc->pending_flip, 0); + wake_up(&exynos_crtc->pending_flip_queue); } spin_unlock_irqrestore(&dev->event_lock, flags);