From patchwork Thu Dec 13 09:14:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1871611 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 4FD36DF2EF for ; Thu, 13 Dec 2012 08:52:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51408E5E98 for ; Thu, 13 Dec 2012 00:52:08 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A2F8E5E98 for ; Thu, 13 Dec 2012 00:51:56 -0800 (PST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MEY00D3TOLUU3R0@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 13 Dec 2012 17:51:54 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 31.18.12699.A2799C05; Thu, 13 Dec 2012 17:51:54 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-f7-50c9972a0253 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 11.18.12699.A2799C05; Thu, 13 Dec 2012 17:51:54 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MEY00DLTOMBF860@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 13 Dec 2012 17:51:54 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/exynos: clear windows in fimd dpms off Date: Thu, 13 Dec 2012 14:44:38 +0530 Message-id: <1355390078-2044-1-git-send-email-prathyush.k@samsung.com> X-Mailer: git-send-email 1.7.0.4 DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCLMWRmVeSWpSXmKPExsWyRsSkTldr+skAg2n3VS2ufH3P5sDocb/7 OFMAYxSXTUpqTmZZapG+XQJXxvXXvcwF0+Qq1r86wdzA+FCii5GTQ0LARGLusz+sELaYxIV7 69m6GLk4hASWMkoc+L6EBaZo4tI17BCJRYwSU3cfhnJWM0l8u/WWGaSKTUBb4tecu2CjRASU Jf5OXMUIYjMLSEgcaT/LBmILC9hJ9Fw+CjSVg4NFQFVi/c90kDCvgJvEqr6JUFcoSLQuO8QO YrMICEh8m3wIrFxCQFZi0wFmkLUSAnvYJKacv8cGUS8pcXDFDZYJjIILGBlWMYqmFiQXFCel 5xrpFSfmFpfmpesl5+duYgQG1el/z6R3MK5qsDjEKMDBqMTDWxh+MkCINbGsuDL3EKMEB7OS CG/LJKAQb0piZVVqUX58UWlOavEhRh+gSyYyS4km5wMDPq8k3tDYxNzU2NTSyMjM1BSHsJI4 b7NHSoCQQHpiSWp2ampBahHMOCYOTqkGRmXx4ktb6hrKRZawHry6lneDw8l50z8KsZYocajp PVq3bIPQ24NhZe6qhRU53GaMqofPLZNsbA1c//Se+qrzooVT/rbaPhHP+aEa8D6/WPf2p6XP dQuWxRs5t8h/r224UVaybZ22upSRTf+V5VdWaok371S/13Ow5I07+zlxc+EJYWf+CfkZKLEU ZyQaajEXFScCAMslPdZXAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsVy+t9jAV2t6ScDDFYekrW48vU9mwOjx/3u 40wBjFENjDYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5 QGOVFMoSc0qBQgGJxcVK+naYJoSGuOlawDRG6PqGBMH1GBmggYQ1jBnXX/cyF0yTq1j/6gRz A+NDiS5GTg4JAROJiUvXsEPYYhIX7q1n62Lk4hASWMQoMXX3YXYIZzWTxLdbb5lBqtgEtCV+ zbnLCmKLCChL/J24ihHEZhaQkDjSfpYNxBYWsJPouXyUpYuRg4NFQFVi/c90kDCvgJvEqr6J rBDLFCRalx1in8DIvYCRYRWjaGpBckFxUnqukV5xYm5xaV66XnJ+7iZGcMg+k97BuKrB4hCj AAejEg9vYfjJACHWxLLiytxDjBIczEoivC2TgEK8KYmVValF+fFFpTmpxYcYfYCWT2SWEk3O B8ZTXkm8obGJuamxqaWJhYmZJQ5hJXHeZo+UACGB9MSS1OzU1ILUIphxTBycUg2MTMKC3h0r nmvPumHVyHx07TTteNV8/TV3fz7R8+Dj2jXtY56NVLfJ7477qsejTTlCpmQ7GlldOPCy4+HZ iW5HXnA6GXhMKRER/2sZF1Uo8Vwtz+bInGPNkWuPlp/f63J6+4vEwKLUw++zF56wb89uWvk5 VE32wrWO29tnPjkiyDDft+1P9osOJZbijERDLeai4kQAotnwRIYCAAA= 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 Changelog v2: Added details of original patch in chromium kernel Changelog v1: When fimd is turned off, we disable the clocks which will stop the dma. Now if we remove the current framebuffer, we cannot disable the overlay but the current framebuffer will still be freed. When fimd resumes, the dma will continue from where it left off and will throw a PAGE FAULT since the memory was freed. This patch fixes the above problem by disabling the fimd windows before disabling the fimd clocks. It also keeps track of which windows were currently active by setting the 'resume' flag. When fimd resumes, the window with a resume flag set is enabled again. Now if a current fb is removed when fimd is off, fimd_win_disable will set the 'resume' flag of that window to zero and return. So when fimd resumes, that window will not be resumed. This patch is based on the following two patches: http://git.chromium.org/gitweb/?p=chromiumos/third_party/kernel.git;a=commitdiff;h=341e973c967304976a762211b6465b0074de62ef http://git.chromium.org/gitweb/?p=chromiumos/third_party/kernel.git;a=commitdiff;h=cfa22e49b7408547c73532c4bb03de47cc034a05 These two patches are rebased onto the current kernel with additional changes like removing 'fimd_win_commit' call from the resume function since this is taken care by encoder dpms, and the modification of resume flag in win_disable. Signed-off-by: Prathyush K Signed-off-by: Sean Paul Signed-off-by: Stephane Marchesin Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 40 +++++++++++++++++++++++++++++- 1 files changed, 39 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 9b5c77d..5067ece 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -83,6 +83,7 @@ struct fimd_win_data { unsigned int buf_offsize; unsigned int line_size; /* bytes */ bool enabled; + bool resume; }; struct fimd_context { @@ -602,6 +603,12 @@ static void fimd_win_disable(struct device *dev, int zpos) win_data = &ctx->win_data[win]; + if (ctx->suspended) { + /* do not resume this window*/ + win_data->resume = false; + return; + } + /* protect windows */ val = readl(ctx->regs + SHADOWCON); val |= SHADOWCON_WINx_PROTECT(win); @@ -815,11 +822,38 @@ static int fimd_clock(struct fimd_context *ctx, bool enable) return 0; } +static void fimd_window_suspend(struct device *dev) +{ + struct fimd_context *ctx = get_fimd_context(dev); + struct fimd_win_data *win_data; + int i; + + for (i = 0; i < WINDOWS_NR; i++) { + win_data = &ctx->win_data[i]; + win_data->resume = win_data->enabled; + fimd_win_disable(dev, i); + } + fimd_wait_for_vblank(dev); +} + +static void fimd_window_resume(struct device *dev) +{ + struct fimd_context *ctx = get_fimd_context(dev); + struct fimd_win_data *win_data; + int i; + + for (i = 0; i < WINDOWS_NR; i++) { + win_data = &ctx->win_data[i]; + win_data->enabled = win_data->resume; + win_data->resume = false; + } +} + static int fimd_activate(struct fimd_context *ctx, bool enable) { + struct device *dev = ctx->subdrv.dev; if (enable) { int ret; - struct device *dev = ctx->subdrv.dev; ret = fimd_clock(ctx, true); if (ret < 0) @@ -830,7 +864,11 @@ static int fimd_activate(struct fimd_context *ctx, bool enable) /* if vblank was enabled status, enable it again. */ if (test_and_clear_bit(0, &ctx->irq_flags)) fimd_enable_vblank(dev); + + fimd_window_resume(dev); } else { + fimd_window_suspend(dev); + fimd_clock(ctx, false); ctx->suspended = true; }