All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH v2 14/14] drm/i915/tc: Check the PLL type used by an enabled TC port
Date: Wed, 22 Mar 2023 00:01:01 +0200	[thread overview]
Message-ID: <20230321220101.983366-3-imre.deak@intel.com> (raw)
In-Reply-To: <20230316131724.359612-15-imre.deak@intel.com>

The current way to determine during HW state sanitization if a PHY is
connected in the expected way doesn't work in all cases. The check for
this considers only the PHY ready/owned state and the initial TC mode
which was determined earlier by the TC port HW readout - using the
sink's HPD and the same PHY ready/owned states.

For instance for an enabled DP-alt/TBT port without the PHY ready/owned
flags set the initial mode will be TBT, and this will be regarded as a
valid PHY state. However it's possible that the port is actually enabled
in DP-alt mode, but for some reason the PHY ownership was not acquired.

Make sure the driver can detect invalid PHY states as in the above
example by checking the PHY ready/owned state wrt. the PLL type used.
This should be the TBT PLL if the PHY is not owned and the MG (non-TBT)
PLL if the PHY is owned.

v2: Rebased on change passing crtc_state in the previous patch.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/display/intel_tc.c | 44 ++++++++++++++-----------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_tc.c b/drivers/gpu/drm/i915/display/intel_tc.c
index c5bfd9f11d7de..bd8c9df5f98fe 100644
--- a/drivers/gpu/drm/i915/display/intel_tc.c
+++ b/drivers/gpu/drm/i915/display/intel_tc.c
@@ -5,6 +5,7 @@
 
 #include "i915_drv.h"
 #include "i915_reg.h"
+#include "intel_ddi.h"
 #include "intel_de.h"
 #include "intel_display.h"
 #include "intel_display_power_map.h"
@@ -568,29 +569,29 @@ static bool tc_phy_is_ready_and_owned(struct intel_digital_port *dig_port,
 	return phy_is_ready && phy_is_owned;
 }
 
-static bool icl_tc_phy_is_connected(struct intel_digital_port *dig_port)
+static bool tc_phy_is_connected(struct intel_digital_port *dig_port,
+				enum icl_port_dpll_id port_pll_type)
 {
-	struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev);
-
-	if (!tc_phy_status_complete(dig_port)) {
-		drm_dbg_kms(&i915->drm, "Port %s: PHY status not complete\n",
-			    dig_port->tc_port_name);
-		return dig_port->tc_mode == TC_PORT_TBT_ALT;
-	}
-
-	/* On ADL-P the PHY complete flag is set in TBT mode as well. */
-	if (IS_ALDERLAKE_P(i915) && dig_port->tc_mode == TC_PORT_TBT_ALT)
-		return true;
+	struct intel_encoder *encoder = &dig_port->base;
+	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+	bool phy_is_ready = tc_phy_status_complete(dig_port);
+	bool phy_is_owned = tc_phy_is_owned(dig_port);
+	bool is_connected;
 
-	if (!tc_phy_is_owned(dig_port)) {
-		drm_dbg_kms(&i915->drm, "Port %s: PHY not owned\n",
-			    dig_port->tc_port_name);
+	if (tc_phy_is_ready_and_owned(dig_port, phy_is_ready, phy_is_owned))
+		is_connected = port_pll_type == ICL_PORT_DPLL_MG_PHY;
+	else
+		is_connected = port_pll_type == ICL_PORT_DPLL_DEFAULT;
 
-		return false;
-	}
+	drm_dbg_kms(&i915->drm,
+		    "Port %s: PHY connected: %s (ready: %s, owned: %s, pll_type: %s)\n",
+		    dig_port->tc_port_name,
+		    str_yes_no(is_connected),
+		    str_yes_no(phy_is_ready),
+		    str_yes_no(phy_is_owned),
+		    port_pll_type == ICL_PORT_DPLL_DEFAULT ? "tbt" : "non-tbt");
 
-	return dig_port->tc_mode == TC_PORT_DP_ALT ||
-	       dig_port->tc_mode == TC_PORT_LEGACY;
+	return is_connected;
 }
 
 static void tc_phy_wait_for_ready(struct intel_digital_port *dig_port)
@@ -876,15 +877,18 @@ static bool tc_port_has_active_links(struct intel_digital_port *dig_port,
 				     const struct intel_crtc_state *crtc_state)
 {
 	struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev);
+	enum icl_port_dpll_id pll_type = ICL_PORT_DPLL_DEFAULT;
 	int active_links = 0;
 
 	if (dig_port->dp.is_mst) {
+		/* TODO: get the PLL type for MST, once HW readout is done for it. */
 		active_links = intel_dp_mst_encoder_active_links(dig_port);
 	} else if (crtc_state && crtc_state->hw.active) {
+		pll_type = intel_ddi_port_pll_type(&dig_port->base, crtc_state);
 		active_links = 1;
 	}
 
-	if (active_links && !icl_tc_phy_is_connected(dig_port))
+	if (active_links && !tc_phy_is_connected(dig_port, pll_type))
 		drm_err(&i915->drm,
 			"Port %s: PHY disconnected with %d active link(s)\n",
 			dig_port->tc_port_name, active_links);
-- 
2.37.1


  reply	other threads:[~2023-03-21 22:01 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 13:17 [Intel-gfx] [PATCH 00/14] drm/i915/tc: Fix a few TypeC / MST issues Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 01/14] drm/i915/tc: Abort DP AUX transfer on a disconnected TC port Imre Deak
2023-03-21 11:09   ` Kahola, Mika
2023-03-21 13:45     ` Imre Deak
2023-03-22 11:19   ` Andrzej Hajda
2023-03-22 12:04     ` Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 02/14] drm/i915/tc: Fix TC port link ref init for DP MST during HW readout Imre Deak
2023-03-21 12:06   ` Kahola, Mika
2023-03-21 14:00     ` Imre Deak
2023-03-24  7:03       ` Kahola, Mika
2023-03-16 13:17 ` [Intel-gfx] [PATCH 03/14] drm/i915/tc: Fix the ICL PHY ownership check in TC-cold state Imre Deak
2023-03-16 13:51   ` Souza, Jose
2023-03-16 13:17 ` [Intel-gfx] [PATCH 04/14] drm/i915/tc: Fix system resume MST mode restore for DP-alt sinks Imre Deak
2023-03-20 20:16   ` Ville Syrjälä
2023-03-20 21:36     ` Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 05/14] drm/i915/tc: Wait for IOM/FW PHY initialization of legacy TC ports Imre Deak
2023-03-24  8:14   ` Kahola, Mika
2023-03-16 13:17 ` [Intel-gfx] [PATCH 06/14] drm/i915/tc: Factor out helpers converting HPD mask to TC mode Imre Deak
2023-03-24  8:16   ` Kahola, Mika
2023-03-16 13:17 ` [Intel-gfx] [PATCH 07/14] drm/i915/tc: Fix target TC mode for a disconnected legacy port Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 08/14] drm/i915/tc: Fix TC mode for a legacy port if the PHY is not ready Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 09/14] drm/i915/tc: Fix initial TC mode on disabled legacy ports Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 10/14] drm/i915/tc: Make the TC mode readout consistent in all PHY states Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 11/14] drm/i915/tc: Assume a TC port is legacy if VBT says the port has HDMI Imre Deak
2023-03-20 20:01   ` Ville Syrjälä
2023-03-20 21:33     ` Imre Deak
2023-03-21 22:00   ` [Intel-gfx] [PATCH v2 " Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 12/14] drm/i915: Add encoder hook to get the PLL type used by TC ports Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 13/14] drm/i915/tc: Factor out a function querying active links on a TC port Imre Deak
2023-03-20 20:05   ` Ville Syrjälä
2023-03-20 21:34     ` Imre Deak
2023-03-21 22:01   ` [Intel-gfx] [PATCH v2 " Imre Deak
2023-03-16 13:17 ` [Intel-gfx] [PATCH 14/14] drm/i915/tc: Check the PLL type used by an enabled " Imre Deak
2023-03-21 22:01   ` Imre Deak [this message]
2023-03-16 22:27 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/tc: Fix a few TypeC / MST issues Patchwork
2023-03-17  8:54   ` Imre Deak
2023-03-20 20:19 ` [Intel-gfx] [PATCH 00/14] " Ville Syrjälä
2023-03-20 21:48 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/tc: Fix a few TypeC / MST issues (rev2) Patchwork
2023-03-20 21:48 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-03-20 21:48 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2023-03-20 21:55 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-03-21  2:10 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-03-21 22:16 ` [Intel-gfx] ✗ Fi.CI.BUILD: warning for drm/i915/tc: Fix a few TypeC / MST issues (rev5) Patchwork
2023-03-21 22:16 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: " Patchwork
2023-03-21 22:16 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-03-21 22:37 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2023-03-21 23:43   ` Imre Deak
2023-03-22  9:45 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/tc: Fix a few TypeC / MST issues (rev6) Patchwork
2023-03-22  9:45 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-03-22  9:45 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2023-03-22 10:01 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-03-22 15:07 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-03-22 18:38   ` Imre Deak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230321220101.983366-3-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.