From patchwork Thu Dec 6 14:46:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1844991 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 B7A2F400ED for ; Thu, 6 Dec 2012 14:33:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 89B24E67AF for ; Thu, 6 Dec 2012 06:33:20 -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 04D11E6752 for ; Thu, 6 Dec 2012 06:25:15 -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 <0MEM00JTE5DXO1N0@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 06 Dec 2012 23:25:14 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 51.D3.01231.9CAA0C05; Thu, 06 Dec 2012 23:25:14 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-31-50c0aac902bd Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 31.D3.01231.9CAA0C05; Thu, 06 Dec 2012 23:25:13 +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:13 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/7] drm/exynos: modify wait_for_vblank of mixer Date: Thu, 06 Dec 2012 20:16:03 +0530 Message-id: <1354805166-29365-5-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+NgFrrDLMWRmVeSWpSXmKPExsWyRsSkSvfUqgMBBof3MVtc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujCd7n7MXvBOpWPf5JHMD43rBLkZODgkBE4nrL3+xQthiEhfu rWfrYuTiEBJYyiix6MEeZpiiFec2QiWmM0os7r0O5axmkrjxZBVYFZuAtsSvOXfBRokIKEv8 nbiKEcRmFpCQONJ+lg3EFhZwkDjbvwcsziKgKtHY/gKsl1fAXeJk60RGiG0KEq3LDrF3MXJw cAp4SKz7nwkSFgIq2fWnnRWiVUDi2+RDLCAlEgKyEpsOMIOcIyFwmU3i6fqjbBBjJCUOrrjB MoFReAEjwypG0dSC5ILipPRcQ73ixNzi0rx0veT83E2MwCA8/e+Z1A7GlQ0WhxgFOBiVeHgt q/cHCLEmlhVX5h5ilOBgVhLhjek4ECDEm5JYWZValB9fVJqTWnyI0QfokonMUqLJ+cAIySuJ NzQ2MTc1NrU0MjIzNcUhrCTO2+yREiAkkJ5YkpqdmlqQWgQzjomDU6qBkfd17e3f0jeXXNvJ tORPwZx8r4PHKvWaUhdp2qddjJ+uuCZJ6nnhlyX8axljAyXLTMTraq1TZ2rcin+neqc5Qbqn vjqX9S9rh/ZVaSvmgqMHE5f8O/D+ounzff8f7jrD4b978UO/uO1uga5d154fYvkyJ1MiXtb1 qeSSDNXw1XKP+x2ZhRLVlViKMxINtZiLihMB5vaiNG8CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42I5/e+xoO7JVQcCDKbttrC48vU9mwOjx/3u 40wBjFENjDYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5 QGOVFMoSc0qBQgGJxcVK+naYJoSGuOlawDRG6PqGBMH1GBmggYQ1jBlP9j5nL3gnUrHu80nm Bsb1gl2MnBwSAiYSK85tZIOwxSQu3FsPZHNxCAlMZ5RY3HsdylnNJHHjySpmkCo2AW2JX3Pu soLYIgLKEn8nrmIEsZkFJCSOtJ8FmyQs4CBxtn8PWJxFQFWisf0FWC+vgLvEydaJjBDbFCRa lx1i72Lk4OAU8JBY9z8TJCwEVLLrTzvrBEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNz NzGCQ/yZ1A7GlQ0WhxgFOBiVeHgtq/cHCLEmlhVX5h5ilOBgVhLhjek4ECDEm5JYWZValB9f VJqTWnyI0QfoqInMUqLJ+cD4yyuJNzQ2MTc1NrU0sTAxs8QhrCTO2+yREiAkkJ5YkpqdmlqQ WgQzjomDU6qBcZIDQ8G8n+EuG6PqQ+K5tDRWssyzPiobfie8OGrPpVNLtixgYP4s7BjgJO/v fS/NcllIzf0/orfWq5V6XVtbFqy4wnp2UuSmgrykHdMXmLqw64Y1nqhrLbUSrt+3jzv0k6Dr 06j4vs+Oi7lkmkOv2U36lH4re563ztSLp61aNJe8c3j29MxRJZbijERDLeai4kQAI+BNEJ4C AAA= 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 mixer. Signed-off-by: Prathyush K --- drivers/gpu/drm/exynos/exynos_mixer.c | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index b6f12fb..b20c063 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -93,6 +93,8 @@ struct mixer_context { struct hdmi_win_data win_data[MIXER_WIN_NR]; enum mixer_version_id mxr_ver; void *parent_ctx; + wait_queue_head_t wait_vsync_queue; + atomic_t wait_vsync_event; }; struct mixer_drv_data { @@ -876,12 +878,23 @@ static void mixer_win_disable(void *ctx, int win) static void mixer_wait_for_vblank(void *ctx) { struct mixer_context *mixer_ctx = ctx; - struct mixer_resources *res = &mixer_ctx->mixer_res; - int ret; - ret = wait_for((mixer_reg_read(res, MXR_INT_STATUS) & - MXR_INT_STATUS_VSYNC), 50); - if (ret < 0) + mutex_lock(&mixer_ctx->mixer_mutex); + if (!mixer_ctx->powered) { + mutex_unlock(&mixer_ctx->mixer_mutex); + return; + } + mutex_unlock(&mixer_ctx->mixer_mutex); + + atomic_set(&mixer_ctx->wait_vsync_event, 1); + + /* + * wait for MIXER to signal VSYNC interrupt or return after + * timeout which is set to 50ms (refresh rate of 20). + */ + if (!wait_event_timeout(mixer_ctx->wait_vsync_queue, + !atomic_read(&mixer_ctx->wait_vsync_event), + DRM_HZ/20)) DRM_DEBUG_KMS("vblank wait timed out.\n"); } @@ -957,6 +970,12 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg) drm_handle_vblank(drm_hdmi_ctx->drm_dev, ctx->pipe); mixer_finish_pageflip(drm_hdmi_ctx->drm_dev, ctx->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: @@ -1139,6 +1158,8 @@ static int __devinit mixer_probe(struct platform_device *pdev) drm_hdmi_ctx->ctx = (void *)ctx; ctx->vp_enabled = drv->is_vp_enabled; ctx->mxr_ver = drv->version; + DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue); + atomic_set(&ctx->wait_vsync_event, 0); platform_set_drvdata(pdev, drm_hdmi_ctx);