From patchwork Fri Sep 4 20:15:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 7125881 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 CC1959F32B for ; Fri, 4 Sep 2015 20:16:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2D0820755 for ; Fri, 4 Sep 2015 20:16:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F91520895 for ; Fri, 4 Sep 2015 20:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760480AbbIDUQJ (ORCPT ); Fri, 4 Sep 2015 16:16:09 -0400 Received: from mail-yk0-f193.google.com ([209.85.160.193]:33606 "EHLO mail-yk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760474AbbIDUQI (ORCPT ); Fri, 4 Sep 2015 16:16:08 -0400 Received: by ykdg206 with SMTP id g206so2763482ykd.0 for ; Fri, 04 Sep 2015 13:16:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QZP6T0CPuw5rkDtdmKEZ55Qrk8iChgAJnSjQAhUVWzg=; b=FGsp7+BG9u+ZEUCoKsDGAIO3GQyBzZs0Y3zzeJdeJ+0k/tPVRhlwdcTH9uRU1DOc4g 4v+jXwXYYHIMYSPed7yj43EwzIyLm7R0ZRyVYXSQu+xQfOs3nN8LUWb57sG47z3OH+Um EXo7FH3Vl3BULyxHpiJ4SnhoSWu85ptEIz2c3DPqM3tYAIDAeWj9hA0bYzIjekOE+7ew SZoWZN9+yNiGUdVNb/4l1it9l74+t6w8jiaVJjoUFHhdVKI3IbTaUmFhf3L5BtkGqoI2 UjtFzwrqfT+4jZuBbbiQ9k3H+DkhwbdIz+85BmoY5ny4NAUkWlgQXohH3BO1q4uVP2EL R3HA== X-Received: by 10.170.44.19 with SMTP id 19mr6425468ykm.4.1441397767758; Fri, 04 Sep 2015 13:16:07 -0700 (PDT) Received: from jade.localdomain ([187.64.235.140]) by smtp.gmail.com with ESMTPSA id w186sm3228710ywf.18.2015.09.04.13.16.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2015 13:16:07 -0700 (PDT) From: Gustavo Padovan To: linux-samsung-soc@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, inki.dae@samsung.com, jy0922.shim@samsung.com, tjakobi@math.uni-bielefeld.de, Gustavo Padovan Subject: [PATCH 04/10] drm/exynos: add pm_runtime to Mixer Date: Fri, 4 Sep 2015 17:15:46 -0300 Message-Id: <1441397752-6672-5-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1441397752-6672-1-git-send-email-gustavo@padovan.org> References: <1441397752-6672-1-git-send-email-gustavo@padovan.org> 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, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 --- 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 2484277..dc48084 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -71,7 +71,6 @@ enum mixer_version_id { }; enum mixer_flag_bits { - MXR_BIT_POWERED, MXR_BIT_VSYNC, }; @@ -927,8 +926,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); @@ -944,9 +941,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); @@ -959,9 +953,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 @@ -977,9 +968,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); @@ -994,9 +982,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"); @@ -1021,43 +1006,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)) { @@ -1070,29 +1021,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 */ @@ -1288,10 +1225,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,