From patchwork Tue Nov 3 10:47:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 7541561 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 602919FCBC for ; Tue, 3 Nov 2015 10:47:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1BE62063B for ; Tue, 3 Nov 2015 10:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AEB0205FD for ; Tue, 3 Nov 2015 10:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753035AbbKCKrW (ORCPT ); Tue, 3 Nov 2015 05:47:22 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:48628 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbbKCKrR (ORCPT ); Tue, 3 Nov 2015 05:47:17 -0500 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NX8001SCJAPL640@mailout1.samsung.com> for linux-samsung-soc@vger.kernel.org; Tue, 03 Nov 2015 19:47:13 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id BA.CB.05272.1B098365; Tue, 3 Nov 2015 19:47:13 +0900 (KST) X-AuditID: cbfee68e-f791c6d000001498-23-563890b17a8d Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id B6.67.18629.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 4/7] drm/exynos: add pm_runtime to Mixer Date: Tue, 03 Nov 2015 19:47:06 +0900 Message-id: <1446547629-12521-5-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+NgFjrLLMWRmVeSWpSXmKPExsWyRsSkUHfjBIswg/OXVSx6z51ksrjy9T2b xafVrewWk+5PYLGYcX4fkwOrx9/n11k8tn97wOpxv/s4k0ffllWMHp83yQWwRnHZpKTmZJal FunbJXBlvNz/lqngqUHFgu9rWRoY76p3MXJySAiYSJzY8ocFwhaTuHBvPVsXIxeHkMAKRomH fRvYYIp6v29iArGFBJYySsw6Ygxhf2eUmHdUB8RmE1CVmLjiPli9iICyxN+JqxhBbGaBfkaJ H+cVQGxhAWuJjZdOsILYLED153+vBqrh4OAVcJHo3JgCsUpO4uSxyWAlnAKuEmtOrwArEQIq ubfeCKKknV1iVzcHxBQBiW+TD7GAlEgIyEpsOsAMUSIpcXDFDZYJjMILGBlWMYqmFiQXFCel FxnpFSfmFpfmpesl5+duYgSG8ul/z/p2MN48YH2IUYCDUYmHd8ES8zAh1sSy4srcQ4ymQBsm MkuJJucDIyavJN7Q2MzIwtTE1NjI3NJMSZw3QepnsJBAemJJanZqakFqUXxRaU5q8SFGJg5O qQbGCI5axiXfhVRaRPRUDI4dMQveWn3Zr7g7uU1KYcF8W06d8PvFjVkM75ROZ53LMvo3Ler2 u4vb86TtG6e8zJ/05W7XsYJtRoL+Zr7/t282m+uctXlH75dTQllnnoc1O799Hhp77/uUTyfX 361890HybO2PgqWK3KznpVetahQ5eDJbpK6Mk3eDEktxRqKhFnNRcSIAOkOZgmACAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRmVeSWpSXmKPExsVy+t9jAd2NEyzCDDZ0yFv0njvJZHHl63s2 i0+rW9ktJt2fwGIx4/w+JgdWj7/Pr7N4bP/2gNXjfvdxJo++LasYPT5vkgtgjWpgtMlITUxJ LVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wB2q6kUJaYUwoUCkgs LlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzHi5/y1TwVODigXf17I0MN5V72Lk5JAQMJHo /b6JCcIWk7hwbz0biC0ksJRRYtYRYwj7O6PEvKM6IDabgKrExBX3wWpEBJQl/k5cxQhiMwv0 M0r8OK8AYgsLWEtsvHSCFcRmAao//3s1UA0HB6+Ai0TnxhSIVXISJ49NBivhFHCVWHN6BViJ EFDJvfVGExh5FzAyrGKUSC1ILihOSs81ykst1ytOzC0uzUvXS87P3cQIjphn0jsYD+9yP8Qo wMGoxMO7YIl5mBBrYllxZe4hRgkOZiUR3sk9FmFCvCmJlVWpRfnxRaU5qcWHGE2BzprILCWa nA+M5rySeENjEzMjSyNzQwsjY3MlcV59T6MwIYH0xJLU7NTUgtQimD4mDk6pBsaS1aezc6fb se1ZqGuf+0pqJ+/j9N2lkgYC/aHrLpe2nfYxZpuUdOaOkFn70iPvXoj881zp6VZ5R8V1r/jz zFdfjI6sW6NhGrqj/ZfFpNQIBoaa7HMxV6LvMEx9ti/meByvrNWiB1WPV+yWXRwTMo8xd7Nk YorKicn7tkd80Wzz/arQvFEgqkCJpTgj0VCLuag4EQCdvHqkrgIAAA== 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=-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. Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_mixer.c | 125 +++++++++++++++++----------------- 1 file changed, 61 insertions(+), 64 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index d09f8f9..7498c6e 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -70,7 +70,6 @@ enum mixer_version_id { }; enum mixer_flag_bits { - MXR_BIT_POWERED, MXR_BIT_VSYNC, }; @@ -926,8 +925,6 @@ static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) struct mixer_resources *res = &mixer_ctx->mixer_res; __set_bit(MXR_BIT_VSYNC, &mixer_ctx->flags); - if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) - return 0; /* enable vsync interrupt */ mixer_reg_writemask(res, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC); @@ -943,9 +940,6 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) __clear_bit(MXR_BIT_VSYNC, &mixer_ctx->flags); - if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) - return; - /* disable vsync interrupt */ mixer_reg_writemask(res, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC); mixer_reg_writemask(res, MXR_INT_EN, 0, MXR_INT_EN_VSYNC); @@ -958,9 +952,6 @@ static void mixer_update_plane(struct exynos_drm_crtc *crtc, DRM_DEBUG_KMS("win: %d\n", plane->zpos); - if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) - return; - if (plane->zpos > 1 && mixer_ctx->vp_enabled) vp_video_buffer(mixer_ctx, plane); else @@ -976,9 +967,6 @@ static void mixer_disable_plane(struct exynos_drm_crtc *crtc, DRM_DEBUG_KMS("win: %d\n", plane->zpos); - if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) - return; - spin_lock_irqsave(&res->reg_slock, flags); mixer_vsync_set_update(mixer_ctx, false); @@ -993,9 +981,6 @@ static void mixer_wait_for_vblank(struct exynos_drm_crtc *crtc) struct mixer_context *mixer_ctx = crtc->ctx; int err; - if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) - return; - err = drm_vblank_get(mixer_ctx->drm_dev, mixer_ctx->pipe); if (err < 0) { DRM_DEBUG_KMS("failed to acquire vblank counter\n"); @@ -1020,43 +1005,9 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) { struct mixer_context *ctx = crtc->ctx; struct mixer_resources *res = &ctx->mixer_res; - int ret; - - if (test_bit(MXR_BIT_POWERED, &ctx->flags)) - return; pm_runtime_get_sync(ctx->dev); - ret = clk_prepare_enable(res->mixer); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the mixer clk [%d]\n", ret); - return; - } - ret = clk_prepare_enable(res->hdmi); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the hdmi clk [%d]\n", ret); - return; - } - if (ctx->vp_enabled) { - ret = clk_prepare_enable(res->vp); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the vp clk [%d]\n", - ret); - return; - } - if (ctx->has_sclk) { - ret = clk_prepare_enable(res->sclk_mixer); - if (ret < 0) { - DRM_ERROR("Failed to prepare_enable the " \ - "sclk_mixer clk [%d]\n", - ret); - return; - } - } - } - - set_bit(MXR_BIT_POWERED, &ctx->flags); - mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET); if (test_bit(MXR_BIT_VSYNC, &ctx->flags)) { @@ -1069,29 +1020,15 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) static void mixer_disable(struct exynos_drm_crtc *crtc) { struct mixer_context *ctx = crtc->ctx; - struct mixer_resources *res = &ctx->mixer_res; int i; - if (!test_bit(MXR_BIT_POWERED, &ctx->flags)) - return; - mixer_stop(ctx); mixer_regs_dump(ctx); for (i = 0; i < MIXER_WIN_NR; i++) mixer_disable_plane(crtc, &ctx->planes[i]); - clear_bit(MXR_BIT_POWERED, &ctx->flags); - - clk_disable_unprepare(res->hdmi); - clk_disable_unprepare(res->mixer); - if (ctx->vp_enabled) { - clk_disable_unprepare(res->vp); - if (ctx->has_sclk) - clk_disable_unprepare(res->sclk_mixer); - } - - pm_runtime_put_sync(ctx->dev); + pm_runtime_put(ctx->dev); } /* Only valid for Mixer version 16.0.33.0 */ @@ -1293,10 +1230,70 @@ static int mixer_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int exynos_mixer_suspend(struct device *dev) +{ + struct mixer_context *ctx = dev_get_drvdata(dev); + struct mixer_resources *res = &ctx->mixer_res; + + clk_disable_unprepare(res->hdmi); + clk_disable_unprepare(res->mixer); + if (ctx->vp_enabled) { + clk_disable_unprepare(res->vp); + if (ctx->has_sclk) + clk_disable_unprepare(res->sclk_mixer); + } + + return 0; +} + +static int exynos_mixer_resume(struct device *dev) +{ + struct mixer_context *ctx = dev_get_drvdata(dev); + struct mixer_resources *res = &ctx->mixer_res; + int ret; + + ret = clk_prepare_enable(res->mixer); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the mixer clk [%d]\n", ret); + return ret; + } + ret = clk_prepare_enable(res->hdmi); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the hdmi clk [%d]\n", ret); + return ret; + } + if (ctx->vp_enabled) { + ret = clk_prepare_enable(res->vp); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the vp clk [%d]\n", + ret); + return ret; + } + if (ctx->has_sclk) { + ret = clk_prepare_enable(res->sclk_mixer); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the " \ + "sclk_mixer clk [%d]\n", + ret); + return ret; + } + } + } + + return 0; +} +#endif + +static const struct dev_pm_ops exynos_mixer_pm_ops = { + SET_RUNTIME_PM_OPS(exynos_mixer_suspend, exynos_mixer_resume, NULL) +}; + struct platform_driver mixer_driver = { .driver = { .name = "exynos-mixer", .owner = THIS_MODULE, + .pm = &exynos_mixer_pm_ops, .of_match_table = mixer_match_types, }, .probe = mixer_probe,