From patchwork Thu Aug 11 22:23:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Navare, Manasi" X-Patchwork-Id: 9276091 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 5ECD160231 for ; Thu, 11 Aug 2016 22:10:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C511287B2 for ; Thu, 11 Aug 2016 22:10:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C86A287B5; Thu, 11 Aug 2016 22:10:36 +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 B5768287B2 for ; Thu, 11 Aug 2016 22:10:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 55FCB6E2CE; Thu, 11 Aug 2016 22:10:33 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 599156E2CE for ; Thu, 11 Aug 2016 22:10:32 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 11 Aug 2016 15:10:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,507,1464678000"; d="scan'208"; a="1034103879" Received: from manasi-otcmedia.jf.intel.com ([10.7.199.175]) by orsmga002.jf.intel.com with ESMTP; 11 Aug 2016 15:10:31 -0700 From: Manasi Navare To: intel-gfx@lists.freedesktop.org Date: Thu, 11 Aug 2016 15:23:41 -0700 Message-Id: <1470954221-6474-1-git-send-email-manasi.d.navare@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH v2] drm/i915: intel_dp_link_is_valid() should only return status of link 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 Intel_dp_link_is_valid() function reads the Link status registers and returns a boolean to indicate link is valid or not. If the link has lost lock and is not valid any more, link training is performed outside the function else previously trained link is retained. This gives us flexibility of checking whether link is valid and training it independently. v2: * Changed the function name from intel_dp_check_link_status() to intel_dp_link_is_valid() (Lukas Wunner) * Checks for CRTC and active CRTC are moved outside the intel_dp_link_is_valid() function (Rodrigo Vivi) Signed-off-by: Manasi Navare --- drivers/gpu/drm/i915/intel_dp.c | 56 +++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 364db90..891147d 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -3881,36 +3881,33 @@ go_again: return -EINVAL; } -static void -intel_dp_check_link_status(struct intel_dp *intel_dp) +static bool +intel_dp_link_is_valid(struct intel_dp *intel_dp) { - struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base; struct drm_device *dev = intel_dp_to_dev(intel_dp); u8 link_status[DP_LINK_STATUS_SIZE]; WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); if (!intel_dp_get_link_status(intel_dp, link_status)) { - DRM_ERROR("Failed to get link status\n"); - return; + DRM_DEBUG_KMS("Failed to get link status\n"); + return false; } - if (!intel_encoder->base.crtc) - return; + /* Check if the link is valid by reading the bits of Link status + * registers + */ + if (!drm_dp_channel_eq_ok(link_status, intel_dp->lane_count)) { + DRM_DEBUG_KMS("Channel EQ or CR not ok, need to retrain\n"); + return false; + } - if (!to_intel_crtc(intel_encoder->base.crtc)->active) - return; + DRM_DEBUG_KMS("Link is good, no need to retrain\n"); + return true; - /* if link training is requested we should perform it always */ - if ((intel_dp->compliance_test_type == DP_TEST_LINK_TRAINING) || - (!drm_dp_channel_eq_ok(link_status, intel_dp->lane_count))) { - DRM_DEBUG_KMS("%s: channel EQ not ok, retraining\n", - intel_encoder->base.name); - intel_dp_start_link_train(intel_dp); - intel_dp_stop_link_train(intel_dp); - } } + /* * According to DP spec * 5.1.2: @@ -3928,6 +3925,8 @@ static bool intel_dp_short_pulse(struct intel_dp *intel_dp) { struct drm_device *dev = intel_dp_to_dev(intel_dp); + struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); + struct intel_encoder *intel_encoder = &intel_dig_port->base; u8 sink_irq_vector = 0; u8 old_sink_count = intel_dp->sink_count; bool ret; @@ -3968,8 +3967,18 @@ intel_dp_short_pulse(struct intel_dp *intel_dp) DRM_DEBUG_DRIVER("CP or sink specific irq unhandled\n"); } + /* Do not train the link if there is no crtc */ + if (!intel_encoder->base.crtc) + return true; + if (!to_intel_crtc(intel_encoder->base.crtc)->active) + return true; + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); - intel_dp_check_link_status(intel_dp); + if (!intel_dp_link_is_valid(intel_dp) || + intel_dp->compliance_test_type == DP_TEST_LINK_TRAINING) { + intel_dp_start_link_train(intel_dp); + intel_dp_stop_link_train(intel_dp); + } drm_modeset_unlock(&dev->mode_config.connection_mutex); return true; @@ -4298,8 +4307,17 @@ intel_dp_long_pulse(struct intel_connector *intel_connector) * check links status, there has been known issues of * link loss triggerring long pulse!!!! */ + /* Do not train the link if there is no crtc */ + if (!intel_encoder->base.crtc) + goto out; + if (!to_intel_crtc(intel_encoder->base.crtc)->active) + goto out; + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); - intel_dp_check_link_status(intel_dp); + if (!intel_dp_link_is_valid(intel_dp)) { + intel_dp_start_link_train(intel_dp); + intel_dp_stop_link_train(intel_dp); + } drm_modeset_unlock(&dev->mode_config.connection_mutex); goto out; }