From patchwork Wed Apr 9 21:47:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 3957751 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 713EA9F371 for ; Wed, 9 Apr 2014 21:47:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B52020592 for ; Wed, 9 Apr 2014 21:47:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7B90F20142 for ; Wed, 9 Apr 2014 21:47:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E94A46EBD1; Wed, 9 Apr 2014 14:47:42 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yk0-f169.google.com (mail-yk0-f169.google.com [209.85.160.169]) by gabe.freedesktop.org (Postfix) with ESMTP id 003786EBD1 for ; Wed, 9 Apr 2014 14:47:41 -0700 (PDT) Received: by mail-yk0-f169.google.com with SMTP id 142so2797154ykq.28 for ; Wed, 09 Apr 2014 14:47:40 -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; bh=z5/A1lg3E0JjubgT1TFf0ApD9dA7vGzdiE24V/dMSqs=; b=eywW8ev+9DK69oHvtGwChau+39VfNql5VvvdjIzLnXZyWlCtslU/BohBGt/IaNMi++ CHReqno3vHMmC+OyOTcExozezNx8qpJp8UFt+YmNtUiyFHaKAx+BIqrzh68YyJlvI/Ua pvk5uOcyTG+AXJVZ5oG1qe6Xg9/SMJeRJ33T2JJnbveX156qZxjmLzf8MFbREXmH/2Mn JLzb0FYQocmL4jCmZlo8ADLQwBZRn4tfFkZQw9cqKGJAWSir7aVLTX4m1m/j92tjzfKB rLyLcgG3wa8IpQ5kI+pqv2xunOTd2o6gqdvfwqjQYGlYxBP2owEuKCt8bsvwfa/bmsQl 9bNQ== X-Received: by 10.236.35.201 with SMTP id u49mr17066768yha.98.1397080060407; Wed, 09 Apr 2014 14:47:40 -0700 (PDT) Received: from localhost.localdomain ([177.40.102.110]) by mx.google.com with ESMTPSA id c24sm3932784yhc.2.2014.04.09.14.47.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Apr 2014 14:47:40 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Wed, 9 Apr 2014 18:47:33 -0300 Message-Id: <1397080053-22171-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.9.0 Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH] drm/i915: get power domain in case the BIOS enabled eDP VDD 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.4 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 If I unplug the eDP monitor, the BIOS of my machine will enable the VDD bit, then when the driver loads it will think VDD is enabled. It will detect that the eDP is not enabled and return false from intel_edp_init_connector. This will trigger a call to edp_panel_vdd_off_sync(), which trigger a WARN saying that the refcount of the power domain is less than zero. The problem happens because the driver gets a refcount whenever it enables the VDD bit, and puts the refcount whenever it disables the VDD bit. But on this case, the BIOS enabled VDD, so all we do is to call put() without calling get() first, so the code added is there to make sure we always have the get() in case the BIOS enabled the bit. Signed-off-by: Paulo Zanoni Tested-by: Chris Wilson --- drivers/gpu/drm/i915/intel_dp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index e48d47c..a432904 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -3638,7 +3638,8 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, { struct drm_connector *connector = &intel_connector->base; struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); - struct drm_device *dev = intel_dig_port->base.base.dev; + struct intel_encoder *intel_encoder = &intel_dig_port->base; + struct drm_device *dev = intel_encoder->base.dev; struct drm_i915_private *dev_priv = dev->dev_private; struct drm_display_mode *fixed_mode = NULL; bool has_dpcd; @@ -3648,6 +3649,14 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, if (!is_edp(intel_dp)) return true; + /* 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); + } + /* Cache DPCD and EDID for edp. */ intel_edp_panel_vdd_on(intel_dp); has_dpcd = intel_dp_get_dpcd(intel_dp);