From patchwork Tue Apr 22 22:55:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 4036901 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 9E3D8BFF02 for ; Tue, 22 Apr 2014 22:56:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C950420211 for ; Tue, 22 Apr 2014 22:56:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1A28D201EF for ; Tue, 22 Apr 2014 22:56:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 127D66E5C1; Tue, 22 Apr 2014 15:56:03 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yk0-f182.google.com (mail-yk0-f182.google.com [209.85.160.182]) by gabe.freedesktop.org (Postfix) with ESMTP id 1194C6E5C1 for ; Tue, 22 Apr 2014 15:56:02 -0700 (PDT) Received: by mail-yk0-f182.google.com with SMTP id 142so143462ykq.13 for ; Tue, 22 Apr 2014 15:56:01 -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=OJPXHH7FYi4ZrreBR8xX5IJ1ZSmvNQRSAvd27odt89E=; b=OqmjRsTc50FPVh9mfHMHMn2W1az8dEpCPF3s2mEeI4Km9T9IQ2TI/dXck472/XGMAx /86zsfyNaTQihxiDDiTuyiRELf8msx/wviLnOpkD4Lw4tGetRIm4Apd0lWRwvTx3cx+W BemHPNx2q3aaQOevDLVEmZqf3ZE/T9j7I9/YcChqlGN+5/vMlyen/+jcQyqdH4IyEUSA uXhPmnnQoYXPpvVQZJFVSwYyH+07Fk1moWBkJlWHphTPz9fOyHK0vueI11iyM9RjohkG +++vCLKeLP4Ds125Rd4FXECFHb3iehaykpINA1mTLmV/vf3OvPADWA6T6JS1Bj44bGiQ RweA== X-Received: by 10.236.149.38 with SMTP id w26mr64914143yhj.51.1398207361417; Tue, 22 Apr 2014 15:56:01 -0700 (PDT) Received: from localhost.localdomain ([177.156.79.173]) by mx.google.com with ESMTPSA id 63sm81337973yhi.13.2014.04.22.15.56.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Apr 2014 15:56:00 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 22 Apr 2014 19:55:42 -0300 Message-Id: <1398207345-1865-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <20140411132123.GH9262@phenom.ffwll.local> References: <20140411132123.GH9262@phenom.ffwll.local> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 1/4] 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.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 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. v2: - Rebase Tested-by: Chris Wilson (v1) Signed-off-by: Paulo Zanoni Reviewed-by: Daniel Vetter --- 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 80e5598..44df493 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -3785,7 +3785,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; struct drm_display_mode *downclock_mode = NULL; @@ -3798,6 +3799,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);