From patchwork Thu Apr 24 13:49:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 4051441 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6998ABFF02 for ; Thu, 24 Apr 2014 13:49:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76BF1201BA for ; Thu, 24 Apr 2014 13:49:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 504752018E for ; Thu, 24 Apr 2014 13:49:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D7C196E4B3; Thu, 24 Apr 2014 06:49:56 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yh0-f44.google.com (mail-yh0-f44.google.com [209.85.213.44]) by gabe.freedesktop.org (Postfix) with ESMTP id AAD456E4B3 for ; Thu, 24 Apr 2014 06:49:55 -0700 (PDT) Received: by mail-yh0-f44.google.com with SMTP id f10so2223098yha.3 for ; Thu, 24 Apr 2014 06:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9ZU76M+vl+mNPugQgzgmi/SI0Cb8quVnTUt/5yvSXdw=; b=QaBlyNvUOVbfLFjoP5OeYoFRqCwpbmibF1vSeDNKU+G91W1VRSOmUwwUr/Nvbyn+X6 /1HW6i3ShwyM+yArB2H/Mzizb2UEWl0NI44FhwVyVqfNpHAKd/HehnDFF126dfobjKm+ ay3qN7KUDJ9y3aLdv9kzc5RmsdkzuYwLsJjIUiKWaZ4zaWkIbmIYda7QZ8J8e+8zuWzw gAjm7Ui3zEooiejwZmsAaMTyJhTKky4EVWnvFUPKqdGuGlHb2ozqNbyItJTyL3eCePoG UknusrBfEHoCSDKhGpoSIzHzclf3tlonSFRO0We64fs5J4Pe1NijOMhJDsdtrfu5YQYb iNEQ== X-Received: by 10.236.130.178 with SMTP id k38mr2590515yhi.132.1398347395093; Thu, 24 Apr 2014 06:49:55 -0700 (PDT) Received: from localhost.localdomain ([177.156.79.173]) by mx.google.com with ESMTPSA id 46sm7636347yhg.36.2014.04.24.06.49.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Apr 2014 06:49:53 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Thu, 24 Apr 2014 10:49:28 -0300 Message-Id: <1398347368-2459-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <20140423094504.GF18465@intel.com> References: <20140423094504.GF18465@intel.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 2/4] drm/i915: add intel_encoder_power_get/put X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Paulo Zanoni This was suggested by Chris on his review to the first version of "drm/i915: get power domain in case the BIOS enabled eDP VDD". Well, at least that's what I understood from his comment :) v2: - Make it intel_encoder_power_get/put - Don't call the new functions on functions where we need both get() and put(), so we don't end up calling intel_display_port_power_domain() more than needed. Signed-off-by: Paulo Zanoni Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/i915/intel_dp.c | 19 +++++-------------- drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_pm.c | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 14 deletions(-) I am not really sure if this patch is worth it... I certainly won't be mad if we drop it. The diffstat is not good. diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index a421c81..8201b60 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -1069,7 +1069,6 @@ static bool _edp_panel_vdd_on(struct intel_dp *intel_dp) struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); struct intel_encoder *intel_encoder = &intel_dig_port->base; struct drm_i915_private *dev_priv = dev->dev_private; - enum intel_display_power_domain power_domain; u32 pp; u32 pp_stat_reg, pp_ctrl_reg; bool need_to_disable = !intel_dp->want_panel_vdd; @@ -1082,8 +1081,7 @@ static bool _edp_panel_vdd_on(struct intel_dp *intel_dp) if (edp_have_panel_vdd(intel_dp)) return need_to_disable; - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_get(dev_priv, power_domain); + intel_encoder_power_get(intel_encoder); DRM_DEBUG_KMS("Turning eDP VDD on\n"); @@ -1133,7 +1131,6 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); struct intel_encoder *intel_encoder = &intel_dig_port->base; - enum intel_display_power_domain power_domain; DRM_DEBUG_KMS("Turning eDP VDD off\n"); @@ -1153,8 +1150,7 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) if ((pp & POWER_TARGET_ON) == 0) intel_dp->last_power_cycle = jiffies; - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_put(dev_priv, power_domain); + intel_encoder_power_put(intel_encoder); } } @@ -1242,7 +1238,6 @@ void intel_edp_panel_off(struct intel_dp *intel_dp) struct intel_encoder *intel_encoder = &intel_dig_port->base; struct drm_device *dev = intel_dp_to_dev(intel_dp); struct drm_i915_private *dev_priv = dev->dev_private; - enum intel_display_power_domain power_domain; u32 pp; u32 pp_ctrl_reg; @@ -1272,8 +1267,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp) wait_panel_off(intel_dp); /* We got a reference when we enabled the VDD. */ - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_put(dev_priv, power_domain); + intel_encoder_power_put(intel_encoder); } void intel_edp_backlight_on(struct intel_dp *intel_dp) @@ -3798,11 +3792,8 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, /* The VDD bit needs a power domain reference, so if the bit is already * enabled when we boot, grab this reference. */ - if (edp_have_panel_vdd(intel_dp)) { - enum intel_display_power_domain power_domain; - power_domain = intel_display_port_power_domain(intel_encoder); - intel_display_power_get(dev_priv, power_domain); - } + if (edp_have_panel_vdd(intel_dp)) + intel_encoder_power_get(intel_encoder); /* Cache DPCD and EDID for edp. */ intel_edp_panel_vdd_on(intel_dp); diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index b885df1..5f27b51 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -920,6 +920,8 @@ void intel_display_power_get(struct drm_i915_private *dev_priv, enum intel_display_power_domain domain); void intel_display_power_put(struct drm_i915_private *dev_priv, enum intel_display_power_domain domain); +void intel_encoder_power_get(struct intel_encoder *encoder); +void intel_encoder_power_put(struct intel_encoder *encoder); void intel_power_domains_init_hw(struct drm_i915_private *dev_priv); void intel_init_gt_powersave(struct drm_device *dev); void intel_cleanup_gt_powersave(struct drm_device *dev); diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index 75c1c76..8ed8d53 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -5734,6 +5734,30 @@ void intel_display_power_put(struct drm_i915_private *dev_priv, intel_runtime_pm_put(dev_priv); } +/* + * Short version for when you don't need to use both get() and put() on the same + * function. If you need both, consider calling intel_display_power_get/put() + * directly so you will save a call to intel_display_port_power_domain(). + */ +void intel_encoder_power_get(struct intel_encoder *encoder) +{ + struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; + enum intel_display_power_domain power_domain; + + power_domain = intel_display_port_power_domain(encoder); + intel_display_power_get(dev_priv, power_domain); +} + +/* See the comment above intel_encoder_power_get(). */ +void intel_encoder_power_put(struct intel_encoder *encoder) +{ + struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; + enum intel_display_power_domain power_domain; + + power_domain = intel_display_port_power_domain(encoder); + intel_display_power_put(dev_priv, power_domain); +} + static struct i915_power_domains *hsw_pwr; /* Display audio driver power well request */