From patchwork Tue Nov 3 10:47:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 7541621 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CA6A5BEEA4 for ; Tue, 3 Nov 2015 10:47:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9347205DE for ; Tue, 3 Nov 2015 10:47:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 878D7205D6 for ; Tue, 3 Nov 2015 10:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753211AbbKCKrf (ORCPT ); Tue, 3 Nov 2015 05:47:35 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:47728 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834AbbKCKrR (ORCPT ); Tue, 3 Nov 2015 05:47:17 -0500 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NX802IV2JAQ5M70@mailout2.samsung.com> for linux-samsung-soc@vger.kernel.org; Tue, 03 Nov 2015 19:47:14 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.116]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id F0.10.05342.2B098365; Tue, 3 Nov 2015 19:47:14 +0900 (KST) X-AuditID: cbfee690-f794e6d0000014de-92-563890b22708 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id E5.3D.23663.1B098365; Tue, 3 Nov 2015 19:47:13 +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 <0NX800N1DJAN2C90@mmp1.samsung.com>; Tue, 03 Nov 2015 19:47:13 +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 v2 5/7] drm/exynos: add pm_runtime to FIMD Date: Tue, 03 Nov 2015 19:47:07 +0900 Message-id: <1446547629-12521-6-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1446547629-12521-1-git-send-email-inki.dae@samsung.com> References: <1446547629-12521-1-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsWyRsSkRHfTBIswg0sn2Cx6z51ksrjy9T2b xafVrewWk+5PYLGYcX4fkwOrx9/n11k8tn97wOpxv/s4k0ffllWMHp83yQWwRnHZpKTmZJal FunbJXBlrPrcy1JwxbDi2Ko/LA2MP9S7GDk4JARMJJ61GHYxcgKZYhIX7q1n62Lk4hASWMEo sW3TJhaIhInEwZ6t7BCJpYwSe/9dZgdJCAl8Z5SYd1QHxGYTUJWYuOI+G4gtIqAs8XfiKkYQ m1mgn1Hix3kFEFtYwEpi0aXPrCA2C1D9h2u9jCBH8Aq4SLS31kHskpM4eWwyWAmngKvEmtMr wEqEgErurTcCOUFCoJtd4sjOB0wQYwQkvk0+xALxi6zEpgPMEGMkJQ6uuMEygVF4ASPDKkbR 1ILkguKk9CITveLE3OLSvHS95PzcTYzAYD7979mEHYz3DlgfYhTgYFTi4f2xzDxMiDWxrLgy 9xCjKdCGicxSosn5wJjJK4k3NDYzsjA1MTU2Mrc0UxLnfS31M1hIID2xJDU7NbUgtSi+qDQn tfgQIxMHp1QDY1hf2MJaHiMVtlM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R: 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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 v2: - Remove unnecessary changes which removed commit callback from decon drivers and modify CONFIG_PM_SLEEP -> CONFIG_PM Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 91 +++++++++++++------------------- 1 file changed, 37 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index bd75c15..ae97271 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -160,7 +160,6 @@ struct fimd_context { u32 vidout_con; u32 i80ifcon; bool i80_if; - bool suspended; int pipe; wait_queue_head_t wait_vsync_queue; atomic_t wait_vsync_event; @@ -209,9 +208,6 @@ static int fimd_enable_vblank(struct exynos_drm_crtc *crtc) struct fimd_context *ctx = crtc->ctx; u32 val; - if (ctx->suspended) - return -EPERM; - if (!test_and_set_bit(0, &ctx->irq_flags)) { val = readl(ctx->regs + VIDINTCON0); @@ -241,9 +237,6 @@ static void fimd_disable_vblank(struct exynos_drm_crtc *crtc) struct fimd_context *ctx = crtc->ctx; u32 val; - if (ctx->suspended) - return; - if (test_and_clear_bit(0, &ctx->irq_flags)) { val = readl(ctx->regs + VIDINTCON0); @@ -264,9 +257,6 @@ static void fimd_wait_for_vblank(struct exynos_drm_crtc *crtc) { struct fimd_context *ctx = crtc->ctx; - if (ctx->suspended) - return; - atomic_set(&ctx->wait_vsync_event, 1); /* @@ -339,14 +329,12 @@ static void fimd_clear_channels(struct exynos_drm_crtc *crtc) int pipe = ctx->pipe; /* ensure that vblank interrupt won't be reported to core */ - ctx->suspended = false; ctx->pipe = -1; fimd_enable_vblank(ctx->crtc); fimd_wait_for_vblank(ctx->crtc); fimd_disable_vblank(ctx->crtc); - ctx->suspended = true; ctx->pipe = pipe; } @@ -384,9 +372,6 @@ static void fimd_commit(struct exynos_drm_crtc *crtc) void *timing_base = ctx->regs + driver_data->timing_base; u32 val, clkdiv; - if (ctx->suspended) - return; - /* nothing to do if we haven't set the mode yet */ if (mode->htotal == 0 || mode->vtotal == 0) return; @@ -620,9 +605,6 @@ static void fimd_atomic_begin(struct exynos_drm_crtc *crtc, { struct fimd_context *ctx = crtc->ctx; - if (ctx->suspended) - return; - fimd_shadow_protect_win(ctx, plane->zpos, true); } @@ -631,9 +613,6 @@ static void fimd_atomic_flush(struct exynos_drm_crtc *crtc, { struct fimd_context *ctx = crtc->ctx; - if (ctx->suspended) - return; - fimd_shadow_protect_win(ctx, plane->zpos, false); } @@ -649,9 +628,6 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc, unsigned int bpp = state->fb->bits_per_pixel >> 3; unsigned int pitch = state->fb->pitches[0]; - if (ctx->suspended) - return; - offset = plane->src_x * bpp; offset += plane->src_y * pitch; @@ -733,9 +709,6 @@ static void fimd_disable_plane(struct exynos_drm_crtc *crtc, struct fimd_context *ctx = crtc->ctx; unsigned int win = plane->zpos; - if (ctx->suspended) - return; - fimd_enable_video_output(ctx, win, false); if (ctx->driver_data->has_shadowcon) @@ -745,27 +718,9 @@ static void fimd_disable_plane(struct exynos_drm_crtc *crtc, static void fimd_enable(struct exynos_drm_crtc *crtc) { struct fimd_context *ctx = crtc->ctx; - int ret; - - if (!ctx->suspended) - return; - - ctx->suspended = false; pm_runtime_get_sync(ctx->dev); - ret = clk_prepare_enable(ctx->bus_clk); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the bus clk [%d]\n", ret); - return; - } - - ret = clk_prepare_enable(ctx->lcd_clk); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the lcd clk [%d]\n", ret); - return; - } - /* if vblank was enabled status, enable it again. */ if (test_and_clear_bit(0, &ctx->irq_flags)) fimd_enable_vblank(ctx->crtc); @@ -778,9 +733,6 @@ static void fimd_disable(struct exynos_drm_crtc *crtc) struct fimd_context *ctx = crtc->ctx; int i; - if (ctx->suspended) - return; - /* * We need to make sure that all windows are disabled before we * suspend that connector. Otherwise we might try to scan from @@ -795,12 +747,7 @@ static void fimd_disable(struct exynos_drm_crtc *crtc) writel(0, ctx->regs + VIDCON0); - clk_disable_unprepare(ctx->lcd_clk); - clk_disable_unprepare(ctx->bus_clk); - pm_runtime_put_sync(ctx->dev); - - ctx->suspended = true; } static void fimd_trigger(struct device *dev) @@ -1011,7 +958,6 @@ static int fimd_probe(struct platform_device *pdev) return -ENOMEM; ctx->dev = dev; - ctx->suspended = true; ctx->driver_data = drm_fimd_get_driver_data(pdev); if (of_property_read_bool(dev->of_node, "samsung,invert-vden")) @@ -1121,12 +1067,49 @@ static int fimd_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int exynos_fimd_suspend(struct device *dev) +{ + struct fimd_context *ctx = dev_get_drvdata(dev); + + clk_disable_unprepare(ctx->lcd_clk); + clk_disable_unprepare(ctx->bus_clk); + + return 0; +} + +static int exynos_fimd_resume(struct device *dev) +{ + struct fimd_context *ctx = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(ctx->bus_clk); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the bus clk [%d]\n", ret); + return ret; + } + + ret = clk_prepare_enable(ctx->lcd_clk); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the lcd clk [%d]\n", ret); + return ret; + } + + return 0; +} +#endif + +static const struct dev_pm_ops exynos_fimd_pm_ops = { + SET_RUNTIME_PM_OPS(exynos_fimd_suspend, exynos_fimd_resume, NULL) +}; + struct platform_driver fimd_driver = { .probe = fimd_probe, .remove = fimd_remove, .driver = { .name = "exynos4-fb", .owner = THIS_MODULE, + .pm = &exynos_fimd_pm_ops, .of_match_table = fimd_driver_dt_match, }, };