From patchwork Thu Dec 6 14:46:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1845031 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 87962DF2F9 for ; Thu, 6 Dec 2012 14:39:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62B11E677D for ; Thu, 6 Dec 2012 06:39:27 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 3ACF3E6766 for ; Thu, 6 Dec 2012 06:26:21 -0800 (PST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MEM009AN5FV2EI0@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 06 Dec 2012 23:26:20 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id D0.8A.12699.C0BA0C05; Thu, 06 Dec 2012 23:26:20 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-e5-50c0ab0c34fe Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B0.8A.12699.B0BA0C05; Thu, 06 Dec 2012 23:26:20 +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:26:19 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH 7/7] drm/exynos: clear windows in fimd dpms off Date: Thu, 06 Dec 2012 20:16:06 +0530 Message-id: <1354805166-29365-8-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+NgFrrNLMWRmVeSWpSXmKPExsWyRsSkSpdn9YEAgwkTOC2ufH3P5sDocb/7 OFMAYxSXTUpqTmZZapG+XQJXxtmj09gLOiUq1nZPY2lgXCPcxcjJISFgIrH92w02CFtM4sK9 9WC2kMBSRond3fUwNWt7u5m7GLmA4tMZJaZuAGkAcVYzSbyY95UVpIpNQFvi15y7YLaIgLLE 34mrGEFsZgEJiSPtZ8GmCgvYS7QtXQFWwyKgKvHryQIWEJtXwF3iw6aHLBDbFCRalx1i72Lk 4OAU8JBY9z8T4iB3iV1/2qFaBSS+TT7EAlIiISArsekA2G0SApfZJG5+6YUaIylxcMUNlgmM wgsYGVYxiqYWJBcUJ6XnGukVJ+YWl+al6yXn525iBIbg6X/PpHcwrmqwOMQowMGoxMNrUb0/ QIg1say4MvcQowQHs5IIb0zHgQAh3pTEyqrUovz4otKc1OJDjD5Al0xklhJNzgfGR15JvKGx ibmpsamlkZGZqSkOYSVx3maPlAAhgfTEktTs1NSC1CKYcUwcnFINjO4hLR5X3s8ykkjseKQU +bTo0r3w6O/ZoflHf0rFOt9h23dztVV0X6+zd9uUw6eV/xY+uGt96hTr98aJLWYPvdYzFM4v OHPnZ+TLNNMVh6eumrT9X96R2b+1baR2PLlo8aftzcnn+3h4YlbJb/jmztG+csXa3voa98KD x1NV+wNTGO03mi332azEUpyRaKjFXFScCAA+SzQpbgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42I5/e+xoC7P6gMBBr3nGS2ufH3P5sDocb/7 OFMAY1QDo01GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO 0FglhbLEnFKgUEBicbGSvh2mCaEhbroWMI0Rur4hQXA9RgZoIGENY8bZo9PYCzolKtZ2T2Np YFwj3MXIySEhYCKxtrebGcIWk7hwbz1bFyMXh5DAdEaJqRtuQDmrmSRezPvKClLFJqAt8WvO XTBbREBZ4u/EVYwgNrOAhMSR9rNsILawgL1E29IVYDUsAqoSv54sYAGxeQXcJT5sesgCsU1B onXZIfYuRg4OTgEPiXX/M0HCQkAlu/60s05g5F3AyLCKUTS1ILmgOCk910ivODG3uDQvXS85 P3cTIzjEn0nvYFzVYHGIUYCDUYmH16J6f4AQa2JZcWXuIUYJDmYlEd6YjgMBQrwpiZVVqUX5 8UWlOanFhxh9gI6ayCwlmpwPjL+8knhDYxNzU2NTSxMLEzNLHMJK4rzNHikBQgLpiSWp2amp BalFMOOYODilGhgXyoXKrJ+p68mdZJj3U2r/nObNxwJX2ax5IeJfKsm9ZJtw+ZpzXCv0D8x4 cdj8VlPnq9Lqwxtky+bPEnl7TzvH0s9Cne1ejIxNiX5g1j9xmVQfsX3BGS4bnaQCD8mlf2LR lVsVxjxLvcQ3x9s5x21OWvJmH6Md+/Od3p8SuLSlT+2+ueIjTyWW4oxEQy3mouJEAF8mU4We AgAA 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 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. Signed-off-by: Prathyush K --- 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 1517d15..7e66032 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 { @@ -596,6 +597,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); @@ -809,11 +816,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) @@ -824,7 +858,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; }