From patchwork Thu Dec 6 14:46:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1845001 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id D7E4A400ED for ; Thu, 6 Dec 2012 14:34:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8697E67DB for ; Thu, 6 Dec 2012 06:34:52 -0800 (PST) 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 6EE54E5EAC for ; Thu, 6 Dec 2012 06:25:40 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MEM00MXH5EP38L0@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 06 Dec 2012 23:25:39 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.124]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id EA.D3.01231.3EAA0C05; Thu, 06 Dec 2012 23:25:39 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-5c-50c0aae3b180 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id CA.D3.01231.3EAA0C05; Thu, 06 Dec 2012 23:25:39 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MEM009QO5AHQGB0@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 06 Dec 2012 23:25:39 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/7] drm/exynos: modify wait_for_vblank of fimd Date: Thu, 06 Dec 2012 20:16:04 +0530 Message-id: <1354805166-29365-6-git-send-email-prathyush.k@samsung.com> X-Mailer: git-send-email 1.7.0.4 In-reply-to: <1354805166-29365-1-git-send-email-prathyush.k@samsung.com> References: <1354805166-29365-1-git-send-email-prathyush.k@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDLMWRmVeSWpSXmKPExsWyRsSkRvfxqgMBBsueyVpc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujH27L7MUfBWqePRqDWsD40n+LkZODgkBE4lt3+axQdhiEhfu rQeyuTiEBJYySvT2XWCBKZrdtp4dIjGdUeJE00eoqtVMEnv/7GMEqWIT0Jb4NecuK4gtIqAs 8XfiKrA4s4CExJH2s2ArhAXsJVoe3QObyiKgKnF1+3ywel4Bd4mds7YzQWxTkGhddghoGwcH p4CHxLr/mSBhIaCSXX/aWSFaBSS+TT7EAlIiISArsekAM8g5EgLX2SQWNvyHGiMpcXDFDZYJ jMILGBlWMYqmFiQXFCel5xrqFSfmFpfmpesl5+duYgQG4el/z6R2MK5ssDjEKMDBqMTDa1m9 P0CINbGsuDL3EKMEB7OSCG9Mx4EAId6UxMqq1KL8+KLSnNTiQ4w+QJdMZJYSTc4HRkheSbyh sYm5qbGppZGRmakpDmElcd5mj5QAIYH0xJLU7NTUgtQimHFMHJxSDYzyaq/CQjQ/CJ8SiPyx vKgsZtGU7JOvD6xjbBY4Y1vn9VV6VUecluneX1zNjMs+6Pbv6NzwiWWTdIi4u5fE17pFS3da tav/P+ejIf+9Vm7uuffc4snLdV7+aZTLcm/OrVCNUSrPmmCwa4/My58z689EMuiZFq0vZFz2 YnPLusBYj/tPLFovLlJiKc5INNRiLipOBAAw9KsvbwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42I5/e+xoO7jVQcCDJasFLO48vU9mwOjx/3u 40wBjFENjDYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5 QGOVFMoSc0qBQgGJxcVK+naYJoSGuOlawDRG6PqGBMH1GBmggYQ1jBn7dl9mKfgqVPHo1RrW BsaT/F2MnBwSAiYSs9vWs0PYYhIX7q1n62Lk4hASmM4ocaLpI5Szmkli7599jCBVbALaEr/m 3GUFsUUElCX+TlwFFmcWkJA40n6WDcQWFrCXaHl0jwXEZhFQlbi6fT5YPa+Au8TOWduZILYp SLQuOwS0mYODU8BDYt3/TJCwEFDJrj/trBMYeRcwMqxiFE0tSC4oTkrPNdQrTswtLs1L10vO z93ECA7xZ1I7GFc2WBxiFOBgVOLhtazeHyDEmlhWXJl7iFGCg1lJhDem40CAEG9KYmVValF+ fFFpTmrxIUYfoKMmMkuJJucD4y+vJN7Q2MTc1NjU0sTCxMwSh7CSOG+zR0qAkEB6Yklqdmpq QWoRzDgmDk4pYHjedPt2ZoYv6xz7w182CW0zVf7beXjfN5tvPBohXl116/wts56mpKbbX6zO KT9y5VHXik+WBkIy/4x7+U75Lf7h3rZr7o/iBSJPpkj0Fe99GPZvRVW0wT7V2R/1GBJ9WP8c +Xxq6sfWbSc+Hzk/Uz7A//EGoQ0XPyrr3Lsh8CopazXfvP7MbjclluKMREMt5qLiRACt0QiF ngIAAA== X-CFilter-Loop: Reflected 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 It is more optimium to use wait queues while waiting for vsync so that the current task is put to sleep. This way, the task wont hog the CPU while waiting. We use wait_event_timeout and not an interruptible function since we dont want the function to exit when a signal is pending (e.g. drm release). This patch modifies the wait for vblank function of fimd. Signed-off-by: Prathyush K --- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 1d46286..1517d15 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -100,6 +100,8 @@ struct fimd_context { u32 vidcon1; bool suspended; struct mutex lock; + wait_queue_head_t wait_vsync_queue; + atomic_t wait_vsync_event; struct exynos_drm_panel_info *panel; }; @@ -311,11 +313,19 @@ static void fimd_disable_vblank(struct device *dev) static void fimd_wait_for_vblank(struct device *dev) { struct fimd_context *ctx = get_fimd_context(dev); - int ret; - ret = wait_for((__raw_readl(ctx->regs + VIDCON1) & - VIDCON1_VSTATUS_VSYNC), 50); - if (ret < 0) + if (ctx->suspended) + return; + + atomic_set(&ctx->wait_vsync_event, 1); + + /* + * wait for FIMD to signal VSYNC interrupt or return after + * timeout which is set to 50ms (refresh rate of 20). + */ + if (!wait_event_timeout(ctx->wait_vsync_queue, + !atomic_read(&ctx->wait_vsync_event), + DRM_HZ/20)) DRM_DEBUG_KMS("vblank wait timed out.\n"); } @@ -667,6 +677,11 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id) drm_handle_vblank(drm_dev, manager->pipe); fimd_finish_pageflip(drm_dev, manager->pipe); + /* set wait vsync event to zero and wake up queue. */ + if (atomic_read(&ctx->wait_vsync_event)) { + atomic_set(&ctx->wait_vsync_event, 0); + DRM_WAKEUP(&ctx->wait_vsync_queue); + } out: return IRQ_HANDLED; } @@ -885,6 +900,8 @@ static int __devinit fimd_probe(struct platform_device *pdev) ctx->vidcon1 = pdata->vidcon1; ctx->default_win = pdata->default_win; ctx->panel = panel; + DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue); + atomic_set(&ctx->wait_vsync_event, 0); subdrv = &ctx->subdrv;