From patchwork Thu Nov 26 11:53:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 7706071 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5D0929F443 for ; Thu, 26 Nov 2015 11:54:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3673C207C7 for ; Thu, 26 Nov 2015 11:54:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CBA5207C5 for ; Thu, 26 Nov 2015 11:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750890AbbKZLx6 (ORCPT ); Thu, 26 Nov 2015 06:53:58 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:53024 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750755AbbKZLx5 (ORCPT ); Thu, 26 Nov 2015 06:53:57 -0500 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NYF029G77PVJ2E0@mailout1.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 26 Nov 2015 20:53:55 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 5C.FC.27792.3D2F6565; Thu, 26 Nov 2015 20:53:55 +0900 (KST) X-AuditID: cbfee691-f79bf6d000006c90-3d-5656f2d3c0cc Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 13.D7.00996.3D2F6565; Thu, 26 Nov 2015 20:53:55 +0900 (KST) Received: from localhost.localdomain ([10.252.83.67]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NYF00KJ47PV2MC1@mmp1.samsung.com>; Thu, 26 Nov 2015 20:53:55 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Cc: airlied@linux.ie, linux-samsung-soc@vger.kernel.org, Gustavo Padovan , Inki Dae Subject: [PATCH v3] drm/exynos: add pm_runtime to DECON 7 Date: Thu, 26 Nov 2015 20:53:50 +0900 Message-id: <1448538834-26378-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJLMWRmVeSWpSXmKPExsWyRsSkUPfyp7Awgwv/TSx6z51ksrjy9T2b xafVrewWk+5PYLGYcX4fkwOrx9/n11k8tn97wOpxv/s4k0ffllWMHp83yQWwRnHZpKTmZJal FunbJXBlnJ65kqngrmLF/UlPGRsYd0h3MXJySAiYSMxp/sUMYYtJXLi3nq2LkYtDSGAFo8S1 zUcYYYpm/m5lhkgsZZT4v/wWE4TznVHi59w7TCBVbAKqEhNX3GcDsUUElCX+TlwF1s0s0M8o 8eO8QhcjB4ewgKXEtR5lkDALUPnFvuMsIDavgIvElSW3oK6Qkzh5bDIryHwJgc9sEg8fTmSH aBCQ+Db5EAvIHAkBWYlNB6DqJSUOrrjBMoFRcAEjwypG0dSC5ILipPQiU73ixNzi0rx0veT8 3E2MwBA9/e/ZxB2M9w9YH2IU4GBU4uEtsA0LE2JNLCuuzD3EaAq0YSKzlGhyPjAS8kriDY3N jCxMTUyNjcwtzZTEeXWkfwYLCaQnlqRmp6YWpBbFF5XmpBYfYmTi4JRqYPR/7Gq6U9iJ0WJG idfU3tnCq3QKWI3XessIGfwPimhkit2+ehbPvNuVy5/tj+uxW2N/RCJc+a/xXoakXz3ydiJd rdfO35ZddejL93ORtYd8b5YaeClujbI5V376m5adD8cNNfW44/GPJl3fsW/9ua7ZQh8NTpq7 XfgvcuFX1xHuXZe/8frYFyqxFGckGmoxFxUnAgCTRw63TAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeLIzCtJLcpLzFFi42I5/e+xgO7lT2FhBo2z9Cx6z51ksrjy9T2b xafVrewWk+5PYLGYcX4fkwOrx9/n11k8tn97wOpxv/s4k0ffllWMHp83yQWwRjUw2mSkJqak Fimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYAbVdSKEvMKQUKBSQW Fyvp22GaEBripmsB0xih6xsSBNdjZIAGEtYwZpyeuZKp4K5ixf1JTxkbGHdIdzFyckgImEjM /N3KDGGLSVy4t56ti5GLQ0hgKaPE/+W3mCCc74wSP+feYQKpYhNQlZi44j4biC0ioCzxd+Iq RhCbWaCfUeLHeYUuRg4OYQFLiWs9yiBhFqDyi33HWUBsXgEXiStLbkEtk5M4eWwy6wRG7gWM DKsYJVILkguKk9JzjfJSy/WKE3OLS/PS9ZLzczcxguPgmfQOxsO73A8xCnAwKvHwFtiGhQmx JpYVV+YeYpTgYFYS4f3yECjEm5JYWZValB9fVJqTWnyI0RTogInMUqLJ+cAYzSuJNzQ2MTOy NDI3tDAyNlcS572w3y9MSCA9sSQ1OzW1ILUIpo+Jg1OqgbFmxaucfMP6+o2TD9z47SC9Sisp OWUOQ9D/mMVbNAWuHZ+015/1lu7OF7ONrT0DCuoc+289esHHbuAoorNdaL5PjF9fsVDIJMXe OHd/XoGI3HfvHk/qqePgN1GLiK04k7B1l4revjsB+1cyH2vqvrM8t+rny4KWqNIXgimnP8gG iv32kUtqVGIpzkg01GIuKk4EAIkNjlqZAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Gustavo Padovan Let pm_runtime handle the enabling/disabling of the device with proper refcnt instead of rely on specific flags to track the enabled state. Changelog v3: - revive suspended to keep current dpms mode Changelog v2: - Modify CONFIG_PM_SLEEP -> CONFIG_PM Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 93 ++++++++++++++++++------------ 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index ead2b16..38d7762 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -119,13 +119,8 @@ static void decon_clear_channels(struct exynos_drm_crtc *crtc) } /* Wait for vsync, as disable channel takes effect at next vsync */ - if (ch_enabled) { - unsigned int state = ctx->suspended; - - ctx->suspended = 0; + if (ch_enabled) decon_wait_for_vblank(ctx->crtc); - ctx->suspended = state; - } } static int decon_ctx_initialize(struct decon_context *ctx, @@ -555,39 +550,12 @@ static void decon_init(struct decon_context *ctx) static void decon_enable(struct exynos_drm_crtc *crtc) { struct decon_context *ctx = crtc->ctx; - int ret; if (!ctx->suspended) return; - ctx->suspended = false; - pm_runtime_get_sync(ctx->dev); - ret = clk_prepare_enable(ctx->pclk); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the pclk [%d]\n", ret); - return; - } - - ret = clk_prepare_enable(ctx->aclk); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the aclk [%d]\n", ret); - return; - } - - ret = clk_prepare_enable(ctx->eclk); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the eclk [%d]\n", ret); - return; - } - - ret = clk_prepare_enable(ctx->vclk); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the vclk [%d]\n", ret); - return; - } - decon_init(ctx); /* if vblank was enabled status, enable it again. */ @@ -595,6 +563,8 @@ static void decon_enable(struct exynos_drm_crtc *crtc) decon_enable_vblank(ctx->crtc); decon_commit(ctx->crtc); + + ctx->suspended = false; } static void decon_disable(struct exynos_drm_crtc *crtc) @@ -613,11 +583,6 @@ static void decon_disable(struct exynos_drm_crtc *crtc) for (i = 0; i < WINDOWS_NR; i++) decon_disable_plane(crtc, &ctx->planes[i]); - clk_disable_unprepare(ctx->vclk); - clk_disable_unprepare(ctx->eclk); - clk_disable_unprepare(ctx->aclk); - clk_disable_unprepare(ctx->pclk); - pm_runtime_put_sync(ctx->dev); ctx->suspended = true; @@ -843,11 +808,63 @@ static int decon_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int exynos7_decon_suspend(struct device *dev) +{ + struct decon_context *ctx = dev_get_drvdata(dev); + + clk_disable_unprepare(ctx->vclk); + clk_disable_unprepare(ctx->eclk); + clk_disable_unprepare(ctx->aclk); + clk_disable_unprepare(ctx->pclk); + + return 0; +} + +static int exynos7_decon_resume(struct device *dev) +{ + struct decon_context *ctx = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(ctx->pclk); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the pclk [%d]\n", ret); + return ret; + } + + ret = clk_prepare_enable(ctx->aclk); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the aclk [%d]\n", ret); + return ret; + } + + ret = clk_prepare_enable(ctx->eclk); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the eclk [%d]\n", ret); + return ret; + } + + ret = clk_prepare_enable(ctx->vclk); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the vclk [%d]\n", ret); + return ret; + } + + return 0; +} +#endif + +static const struct dev_pm_ops exynos7_decon_pm_ops = { + SET_RUNTIME_PM_OPS(exynos7_decon_suspend, exynos7_decon_resume, + NULL) +}; + struct platform_driver decon_driver = { .probe = decon_probe, .remove = decon_remove, .driver = { .name = "exynos-decon", + .pm = &exynos7_decon_pm_ops, .of_match_table = decon_driver_dt_match, }, };