From patchwork Tue Oct 1 05:51:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 2968281 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BB4B59F289 for ; Tue, 1 Oct 2013 05:52:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E51A220383 for ; Tue, 1 Oct 2013 05:52:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9EE0620377 for ; Tue, 1 Oct 2013 05:52:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DA0FE6B40 for ; Mon, 30 Sep 2013 22:52:35 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id B3838E64E0 for ; Mon, 30 Sep 2013 22:52:18 -0700 (PDT) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MTZ00ISL6XT1CO0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 01 Oct 2013 14:51:38 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.112]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id D1.3B.17682.AE26A425; Tue, 01 Oct 2013 14:51:38 +0900 (KST) X-AuditID: cbfee68e-b7f756d000004512-1c-524a62ea58d7 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 1F.B3.09055.AE26A425; Tue, 01 Oct 2013 14:51:38 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.252.75.62]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MTZ000ZY6Y1UXY0@mmp1.samsung.com>; Tue, 01 Oct 2013 14:51:37 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/exynos: release unhandled page flip events at postclose. Date: Tue, 01 Oct 2013 14:51:37 +0900 Message-id: <1380606697-30684-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCLMWRmVeSWpSXmKPExsWyRsSkQPdVkleQwbntQha9504yWVz5+p7N YtL9CSwWZ5vesDuweGz/9oDV4373cSaPvi2rGAOYo7hsUlJzMstSi/TtErgyduz/yVhwX6Li 9NrlzA2MJ0S6GDk4JARMJCbfl+hi5AQyxSQu3FvPBmILCSxllFjwIA8ibiLx7ek79i5GLqD4 IkaJ3r03oZxuJolXs0+yg1SxCahKTFxxH6xbRMBUomPSUhYQm1nATmLXg36wGmGBAIntt9eA xVmA6icvOssKYvMKuEh8PruQCeIgBYk5k2xA5ksI3GeTeHDwOTNEvYDEt8mHWCBqZCU2HWCG OE5S4uCKGywTGAUXMDKsYhRNLUguKE5KLzLSK07MLS7NS9dLzs/dxAgMwdP/nvXtYLx5wPoQ YzLQuInMUqLJ+cAQziuJNzQ2M7IwNTE1NjK3NCNNWEmcV63FOlBIID2xJDU7NbUgtSi+qDQn tfgQIxMHp1QDo5DloQOv191+KCPpqv4qSplH/X+a2+MqU6dHDH8PKTBfXn+LwzJ96aotWgWG J2oWur3eWbCFTWHJ8xe9zC6H37B7b/JITlbllEk88O88Y8QJSZV/e4OKexZrsKx49ydj2rqw XxWJZyPnvSmfesxR5bWa1Y6CB/23b5yokbs76cK9z0VtbAy/TiqxFGckGmoxFxUnAgBXhUxL VwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRmVeSWpSXmKPExsVy+t9jAd1XSV5BBrsmcFv0njvJZHHl63s2 i0n3J7BYnG16w+7A4rH92wNWj/vdx5k8+rasYgxgjmpgtMlITUxJLVJIzUvOT8nMS7dV8g6O d443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wB2qekUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC 1zckCK7HyAANJKxhzNix/ydjwX2JitNrlzM3MJ4Q6WLk5JAQMJH49vQdO4QtJnHh3nq2LkYu DiGBRYwSvXtvskM43UwSr2afBKtiE1CVmLjiPhuILSJgKtExaSkLiM0sYCex60E/WI2wQIDE 9ttrwOIsQPWTF51lBbF5BVwkPp9dyNTFyAG0TUFiziSbCYzcCxgZVjGKphYkFxQnpeca6hUn 5haX5qXrJefnbmIEB/kzqR2MKxssDjEKcDAq8fAa1HsGCbEmlhVX5h5ilOBgVhLhZYrzChLi TUmsrEotyo8vKs1JLT7EmAy0fCKzlGhyPjAC80riDY1NzIwsjcwNLYyMzUkTVhLnPdBqHSgk kJ5YkpqdmlqQWgSzhYmDU6qB0XPRLstQz9u/PILFz9yKD0ucfWTzzY23VT/OK22bszNEM2GR R87J7vhgsydfJgjNn8xnE8bYVM0ltcE8vO1HUZ+kfe8zp/I3J36X/zPz6PZ6cHFjtEt4e5ep f1M316JrsiHSZ74s/TK3YOsShztTMm9bTwrXrzoq+XrVyz82JR68648Kic+fqMRSnJFoqMVc VJwIAGHnnTO2AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: kyungmin.park@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 X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch resolves a dead lock issue that could be incurred when exynos_drm_crtc_dpms function was called. The exynos_drm_crtc_dpms function waits for the completion of pended page flip events. However, preclose callback - this releases all unhandled page flip events - is called prior to the exynos_drm_crtc_dpms function call when drm is closed. So at this time, this will make the exynos_drm_crtc_dpms to wait infiniately for the completion of the page flip events. This patch releases the unhandled page flip events at postclose instead of preclose so that exynos_drm_crtc_dpms function can be waked up. Changelog v2: - fix a memory leak when drm is closed. . it has a memory leak when a requeste page flip is handled after drm_events_release() is called and before drm_fb_release() is called. At this time, a drm_pending_event will not be freed. So also this chage releases the drm_pending_event at postclose(). And it calls drm_vblank_put() for pair if there is any unhandled page flip event. Signed-off-by: Inki Dae Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 35 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index bb82ef7..1851860 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -173,28 +173,37 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file) static void exynos_drm_preclose(struct drm_device *dev, struct drm_file *file) { + exynos_drm_subdrv_close(dev, file); +} + +static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file) +{ struct exynos_drm_private *private = dev->dev_private; - struct drm_pending_vblank_event *e, *t; + struct drm_pending_vblank_event *v, *vt; + struct drm_pending_event *e, *et; unsigned long flags; - /* release events of current file */ + if (!file->driver_priv) + return; + + /* Release all events not unhandled by page flip handler. */ spin_lock_irqsave(&dev->event_lock, flags); - list_for_each_entry_safe(e, t, &private->pageflip_event_list, + list_for_each_entry_safe(v, vt, &private->pageflip_event_list, base.link) { - if (e->base.file_priv == file) { - list_del(&e->base.link); - e->base.destroy(&e->base); + if (v->base.file_priv == file) { + list_del(&v->base.link); + drm_vblank_put(dev, v->pipe); + v->base.destroy(&v->base); } } - spin_unlock_irqrestore(&dev->event_lock, flags); - exynos_drm_subdrv_close(dev, file); -} + /* Release all events handled by page flip handler but not freed. */ + list_for_each_entry_safe(e, et, &file->event_list, link) { + list_del(&e->link); + e->destroy(e); + } + spin_unlock_irqrestore(&dev->event_lock, flags); -static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file) -{ - if (!file->driver_priv) - return; kfree(file->driver_priv); file->driver_priv = NULL;