From patchwork Thu May 26 08:46:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 9136803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D20D26075C for ; Thu, 26 May 2016 08:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCCA627D11 for ; Thu, 26 May 2016 08:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFE8628299; Thu, 26 May 2016 08:47:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C30D27D11 for ; Thu, 26 May 2016 08:47:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA5136EA40; Thu, 26 May 2016 08:47:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3ED276EA40 for ; Thu, 26 May 2016 08:47:09 +0000 (UTC) Received: by mail-wm0-x235.google.com with SMTP id a136so15713156wme.0 for ; Thu, 26 May 2016 01:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=RNYVxr5GBo3Xxh7LDewuJ42d9vfNFPBW4v0iWyz5NG4=; b=j9VMPfZ4a8mlunhKphJI6GawpnyrH8apEtMNGC+FDWedZWCSlxdWRRth5Cam7AKm2W dv6RClFTzjH6olExiOy2tDW2bmb8nPYVTLWF9L4wVxeARTy3054TGp/BAo22n1QT+yQT qwewgO0XhRPK+99jRheUvSh9mU5V8zP1cqMrU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RNYVxr5GBo3Xxh7LDewuJ42d9vfNFPBW4v0iWyz5NG4=; b=METi+akZK5WOvIp0AP0cSujXbVxwyZvfAFkS8nHXyxBi+q/1hMYcSwGR/s3jaxAtjQ WiRrIvXbWcPILYhnzr+BTcOYuBAi4Y1y5glT9kojYnLFJ83an+q75VASP1YaTeavdyGf 105l+YiuZNGjRUqysaR2xNdycM04nH0AkPQkRoS8ikmhJXdLYMZUGliqhfrX53teq/mW WnJwtHJfV/L82fqi6wVlzcBwmVI913ElLnL2ZuRbogW8MSuaIWc/4/pTElL1k56YLuQE 5wROXyoYdM21gRHxjln7+JewmJsuaE2eZ6ztE4BY+2xUA+18lfO4tn4lprDMHo/XbQGC r2MA== X-Gm-Message-State: ALyK8tIeKvYZ6S41ZY/PsdUGTqARuB4kxdEJH6waJMqTtYBvqu8VUVNYdonTkC07AOtjgCaj X-Received: by 10.28.63.5 with SMTP id m5mr2511260wma.24.1464252427326; Thu, 26 May 2016 01:47:07 -0700 (PDT) Received: from lmenx321.st.com. ([80.12.51.32]) by smtp.gmail.com with ESMTPSA id w10sm13180019wjk.18.2016.05.26.01.47.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 May 2016 01:47:06 -0700 (PDT) From: Benjamin Gaignard To: dri-devel@lists.freedesktop.org, fabien.dessenne@st.com, vincent.abriou@st.com Subject: [PATCH] drm: sti: fix clocking issues in crtc Date: Thu, 26 May 2016 10:46:54 +0200 Message-Id: <1464252414-31655-1-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP fix and simplify clock management in crtc to avoid unbalanced call to clk_prepare_enable and clk_disable_unprepare functions remove unused functions Signed-off-by: Benjamin Gaignard --- drivers/gpu/drm/sti/sti_crtc.c | 57 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c index 505620c..5261b00 100644 --- a/drivers/gpu/drm/sti/sti_crtc.c +++ b/drivers/gpu/drm/sti/sti_crtc.c @@ -30,15 +30,6 @@ static void sti_crtc_enable(struct drm_crtc *crtc) mixer->status = STI_MIXER_READY; - /* Prepare and enable the compo IP clock */ - if (mixer->id == STI_MIXER_MAIN) { - if (clk_prepare_enable(compo->clk_compo_main)) - DRM_INFO("Failed to prepare/enable compo_main clk\n"); - } else { - if (clk_prepare_enable(compo->clk_compo_aux)) - DRM_INFO("Failed to prepare/enable compo_aux clk\n"); - } - drm_crtc_vblank_on(crtc); } @@ -66,9 +57,8 @@ sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode) struct sti_mixer *mixer = to_sti_mixer(crtc); struct device *dev = mixer->dev; struct sti_compositor *compo = dev_get_drvdata(dev); - struct clk *clk; + struct clk *compo_clk, *pix_clk; int rate = mode->clock * 1000; - int res; DRM_DEBUG_KMS("CRTC:%d (%s) mode:%d (%s)\n", crtc->base.id, sti_mixer_to_str(mixer), @@ -83,32 +73,46 @@ sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode) mode->vsync_start, mode->vsync_end, mode->vtotal, mode->type, mode->flags); - /* Set rate and prepare/enable pixel clock */ - if (mixer->id == STI_MIXER_MAIN) - clk = compo->clk_pix_main; - else - clk = compo->clk_pix_aux; + if (mixer->id == STI_MIXER_MAIN) { + compo_clk = compo->clk_compo_main; + pix_clk = compo->clk_pix_main; + } else { + compo_clk = compo->clk_compo_aux; + pix_clk = compo->clk_pix_aux; + } - res = clk_set_rate(clk, rate); - if (res < 0) { + /* Prepare and enable the compo IP clock */ + if (clk_prepare_enable(compo_clk)) { + DRM_INFO("Failed to prepare/enable compositor clk\n"); + goto compo_error; + } + + /* Set rate and prepare/enable pixel clock */ + if (clk_set_rate(pix_clk, rate) < 0) { DRM_ERROR("Cannot set rate (%dHz) for pix clk\n", rate); - return -EINVAL; + goto pix_error; } - if (clk_prepare_enable(clk)) { + if (clk_prepare_enable(pix_clk)) { DRM_ERROR("Failed to prepare/enable pix clk\n"); - return -EINVAL; + goto pix_error; } sti_vtg_set_config(mixer->id == STI_MIXER_MAIN ? compo->vtg_main : compo->vtg_aux, &crtc->mode); - res = sti_mixer_active_video_area(mixer, &crtc->mode); - if (res) { + if (sti_mixer_active_video_area(mixer, &crtc->mode)) { DRM_ERROR("Can't set active video area\n"); - return -EINVAL; + goto mixer_error; } - return res; + return 0; + +mixer_error: + clk_disable_unprepare(pix_clk); +pix_error: + clk_disable_unprepare(compo_clk); +compo_error: + return -EINVAL; } static void sti_crtc_disable(struct drm_crtc *crtc) @@ -139,7 +143,6 @@ static void sti_crtc_disable(struct drm_crtc *crtc) static void sti_crtc_mode_set_nofb(struct drm_crtc *crtc) { - sti_crtc_enable(crtc); sti_crtc_mode_set(crtc, &crtc->state->adjusted_mode); } @@ -231,9 +234,7 @@ static const struct drm_crtc_helper_funcs sti_crtc_helper_funcs = { .enable = sti_crtc_enable, .disable = sti_crtc_disabling, .mode_fixup = sti_crtc_mode_fixup, - .mode_set = drm_helper_crtc_mode_set, .mode_set_nofb = sti_crtc_mode_set_nofb, - .mode_set_base = drm_helper_crtc_mode_set_base, .atomic_begin = sti_crtc_atomic_begin, .atomic_flush = sti_crtc_atomic_flush, };