From patchwork Tue Oct 2 17:50:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 10623935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C63FE1515 for ; Tue, 2 Oct 2018 17:52:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6E5727D4A for ; Tue, 2 Oct 2018 17:52:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB67427F10; Tue, 2 Oct 2018 17:52:01 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 565C627D4A for ; Tue, 2 Oct 2018 17:52:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E67096E371; Tue, 2 Oct 2018 17:51:57 +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 0344E6E36D for ; Tue, 2 Oct 2018 17:51:56 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Oct 2018 10:51:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,332,1534834800"; d="scan'208";a="77907654" Received: from josouza-mobl.jf.intel.com ([10.24.11.2]) by orsmga007.jf.intel.com with ESMTP; 02 Oct 2018 10:51:06 -0700 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Date: Tue, 2 Oct 2018 10:50:46 -0700 Message-Id: <20181002175054.15010-2-jose.souza@intel.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002175054.15010-1-jose.souza@intel.com> References: <20181002175054.15010-1-jose.souza@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 02/10] drm/i915: Make intel_dp_detect() more clear to read X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dhinakaran Pandiyan Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Moving all the error handling to the end of the function and ealier returning for connected MST ports make this function way more easy to read. No functional changed is intended here. Cc: Jani Nikula Cc: Ville Syrjälä Cc: Dhinakaran Pandiyan Signed-off-by: José Roberto de Souza --- drivers/gpu/drm/i915/intel_dp.c | 55 +++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 15a981ef5966..5a84a929bc7d 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -5077,28 +5077,20 @@ intel_dp_detect(struct drm_connector *connector, intel_display_power_get(dev_priv, intel_dp->aux_power_domain); - /* Can't disconnect eDP */ + /* Is port connected? eDP can't be disconnected */ + if (!intel_dp_is_edp(intel_dp) && + !intel_digital_port_connected(encoder)) { + status = connector_status_disconnected; + goto port_disconnected; + } + if (intel_dp_is_edp(intel_dp)) status = edp_detect(intel_dp); - else if (intel_digital_port_connected(encoder)) - status = intel_dp_detect_dpcd(intel_dp); else - status = connector_status_disconnected; - - if (status == connector_status_disconnected) { - memset(&intel_dp->compliance, 0, sizeof(intel_dp->compliance)); - - if (intel_dp->is_mst) { - DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n", - intel_dp->is_mst, - intel_dp->mst_mgr.mst_state); - intel_dp->is_mst = false; - drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, - intel_dp->is_mst); - } + status = intel_dp_detect_dpcd(intel_dp); - goto out; - } + if (status == connector_status_disconnected) + goto port_not_detected; if (intel_dp->reset_link_params) { /* Initial max link lane count */ @@ -5123,8 +5115,8 @@ intel_dp_detect(struct drm_connector *connector, * won't appear connected or have anything * with EDID on it */ - status = connector_status_disconnected; - goto out; + intel_display_power_put(dev_priv, intel_dp->aux_power_domain); + return connector_status_disconnected; } /* @@ -5151,14 +5143,29 @@ intel_dp_detect(struct drm_connector *connector, intel_dp->aux.i2c_defer_count = 0; intel_dp_set_edid(intel_dp); - if (intel_dp_is_edp(intel_dp) || - to_intel_connector(connector)->detect_edid) + /* + * intel_dp_detect_dpcd() will return connector_status_unknown for some + * type of DP devices, if edid can be read set status as connected + */ + if (to_intel_connector(connector)->detect_edid) status = connector_status_connected; intel_dp_check_service_irq(intel_dp); -out: - if (status != connector_status_connected && !intel_dp->is_mst) + intel_display_power_put(dev_priv, intel_dp->aux_power_domain); + return status; + +port_not_detected: +port_disconnected: + memset(&intel_dp->compliance, 0, sizeof(intel_dp->compliance)); + + if (intel_dp->is_mst) { + DRM_DEBUG_KMS("MST device may have disappeared %d vs %d\n", + intel_dp->is_mst, intel_dp->mst_mgr.mst_state); + intel_dp->is_mst = false; + drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, + intel_dp->is_mst); + } else intel_dp_unset_edid(intel_dp); intel_display_power_put(dev_priv, intel_dp->aux_power_domain);