From patchwork Tue Oct 3 07:06:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 9981825 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 AE36060365 for ; Tue, 3 Oct 2017 07:06:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1B6E28877 for ; Tue, 3 Oct 2017 07:06:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9699C2887B; Tue, 3 Oct 2017 07:06:34 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1845D28877 for ; Tue, 3 Oct 2017 07:06:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0D7C26E3DA; Tue, 3 Oct 2017 07:06:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id D47BB6E3C9 for ; Tue, 3 Oct 2017 07:06:27 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2017 00:06:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,473,1500966000"; d="scan'208";a="906141513" Received: from mrsarkar-mobl2.amr.corp.intel.com (HELO rdvivi-vienna.intel.com) ([10.252.138.57]) by FMSMGA003.fm.intel.com with ESMTP; 03 Oct 2017 00:06:27 -0700 From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Tue, 3 Oct 2017 00:06:12 -0700 Message-Id: <20171003070614.18396-12-rodrigo.vivi@intel.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20171003070614.18396-1-rodrigo.vivi@intel.com> References: <20171003070614.18396-1-rodrigo.vivi@intel.com> Cc: Paulo Zanoni , Rodrigo Vivi Subject: [Intel-gfx] [PATCH 11/13] drm/i915/cnl: Only request voltage frequency switching when needed. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP At cdclk initialization at spec they tell us to always use dvfs or avoid change cdclk if it fails. Here on pll sequence, spec tells us to only use dvfs "if the frequency will result in a change to the voltage requirement." So in order to respect that and avoid necessary interactions with PCODE we compare our current needed level with the current set level and only perform dvfs sequences when we need to change that level. v2: - Add missing blank line after declaration block - s/need/needs: When adding doc needs sounded better. Cc: Mika Kahola Cc: Paulo Zanoni Signed-off-by: Rodrigo Vivi Reviewed-by: Mika Kahola --- drivers/gpu/drm/i915/intel_cdclk.c | 10 ++++++++++ drivers/gpu/drm/i915/intel_dpll_mgr.c | 16 +++++++++------- drivers/gpu/drm/i915/intel_drv.h | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_cdclk.c b/drivers/gpu/drm/i915/intel_cdclk.c index c62d6e752fb7..8111a13079e1 100644 --- a/drivers/gpu/drm/i915/intel_cdclk.c +++ b/drivers/gpu/drm/i915/intel_cdclk.c @@ -1545,6 +1545,16 @@ int cnl_dvfs_new_level(int cdclk, int portclk) return 2; } +bool cnl_dvfs_needs_change(struct drm_i915_private *dev_priv, int level) +{ + int old_level; + + mutex_lock(&dev_priv->rps.hw_lock); + sandybridge_pcode_read(dev_priv, SKL_PCODE_CDCLK_CONTROL, &old_level); + mutex_unlock(&dev_priv->rps.hw_lock); + return level != old_level; +} + static void cnl_set_cdclk(struct drm_i915_private *dev_priv, const struct intel_cdclk_state *cdclk_state) { diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.c b/drivers/gpu/drm/i915/intel_dpll_mgr.c index 0dddbd3a7a97..85c000891439 100644 --- a/drivers/gpu/drm/i915/intel_dpll_mgr.c +++ b/drivers/gpu/drm/i915/intel_dpll_mgr.c @@ -1970,9 +1970,10 @@ static void cnl_ddi_pll_enable(struct drm_i915_private *dev_priv, struct intel_shared_dpll *pll) { uint32_t val; - int ret; + int ret = 0; int level; int cdclk, portclk; + bool change_level; /* 1. Enable DPLL power in DPLL_ENABLE. */ val = I915_READ(CNL_DPLL_ENABLE(pll->id)); @@ -2011,7 +2012,12 @@ static void cnl_ddi_pll_enable(struct drm_i915_private *dev_priv, * requirement, follow the Display Voltage Frequency Switching * (DVFS) Sequence Before Frequency Change */ - ret = cnl_dvfs_pre_change(dev_priv); + cdclk = dev_priv->cdclk.hw.cdclk; + portclk = intel_ddi_port_clock(dev_priv, pll->id); + level = cnl_dvfs_new_level(cdclk, portclk); + change_level = cnl_dvfs_needs_change(dev_priv, level); + if (change_level) + ret = cnl_dvfs_pre_change(dev_priv); /* 6. Enable DPLL in DPLL_ENABLE. */ val = I915_READ(CNL_DPLL_ENABLE(pll->id)); @@ -2031,12 +2037,8 @@ static void cnl_ddi_pll_enable(struct drm_i915_private *dev_priv, * requirement, follow the Display Voltage Frequency Switching * (DVFS) Sequence After Frequency Change */ - if (ret == 0) { - cdclk = dev_priv->cdclk.hw.cdclk; - portclk = intel_ddi_port_clock(dev_priv, pll->id); - level = cnl_dvfs_new_level(cdclk, portclk); + if (change_level && ret == 0) cnl_dvfs_post_change(dev_priv, level); - } /* * 9. turn on the clock for the DDI and map the DPLL to the DDI diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index dec11d7b15ab..8621110401e3 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1326,6 +1326,7 @@ void cnl_uninit_cdclk(struct drm_i915_private *dev_priv); int cnl_dvfs_pre_change(struct drm_i915_private *dev_priv); void cnl_dvfs_post_change(struct drm_i915_private *dev_priv, int level); int cnl_dvfs_new_level(int cdclk, int portclk); +bool cnl_dvfs_needs_change(struct drm_i915_private *dev_priv, int level); void bxt_init_cdclk(struct drm_i915_private *dev_priv); void bxt_uninit_cdclk(struct drm_i915_private *dev_priv); void intel_init_cdclk_hooks(struct drm_i915_private *dev_priv);