Skip to content

Commit 4059818

Browse files
ideakgregkh
authored andcommitted
drm/i915/lnl+/tc: Fix handling of an enabled/disconnected dp-alt sink
commit f52d6aa upstream. The TypeC PHY HW readout during driver loading and system resume determines which TypeC mode the PHY is in (legacy/DP-alt/TBT-alt) and whether the PHY is connected, based on the PHY's Owned and Ready flags. For the PHY to be in DP-alt or legacy mode and for the PHY to be in the connected state in these modes, both the Owned (set by the BIOS/driver) and the Ready (set by the HW) flags should be set. On ICL-MTL the HW kept the PHY's Ready flag set after the driver connected the PHY by acquiring the PHY ownership (by setting the Owned flag), until the driver disconnected the PHY by releasing the PHY ownership (by clearing the Owned flag). On LNL+ this has changed, in that the HW clears the Ready flag as soon as the sink gets disconnected, even if the PHY ownership was acquired already and hence the PHY is being used by the display. When inheriting the HW state from BIOS for a PHY connected in DP-alt mode on which the sink got disconnected - i.e. in a case where the sink was connected while BIOS/GOP was running and so the sink got enabled connecting the PHY, but the user disconnected the sink by the time the driver loaded - the PHY Owned but not Ready state must be accounted for on LNL+ according to the above. Do that by assuming on LNL+ that the PHY is connected in DP-alt mode whenever the PHY Owned flag is set, regardless of the PHY Ready flag. This fixes a problem on LNL+, where the PHY TypeC mode / connected state was detected incorrectly for a DP-alt sink, which got connected and then disconnected by the user in the above way. v2: Rename tc_phy_in_legacy_or_dp_alt_mode() to tc_phy_owned_by_display(). (Luca, Jani) Cc: Jani Nikula <jani.nikula@intel.com> Cc: stable@vger.kernel.org # v6.8+ Reported-by: Charlton Lin <charlton.lin@intel.com> Tested-by: Khaled Almahallawy <khaled.almahallawy@intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> Reviewed-by: Luca Coelho <luciano.coelho@intel.com> [Imre: Add one-liner function documentation for tc_phy_owned_by_display()] Signed-off-by: Imre Deak <imre.deak@intel.com> Link: https://lore.kernel.org/r/20250811080152.906216-2-imre.deak@intel.com (cherry picked from commit 89f4b19) Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e1eff52 commit 4059818

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/gpu/drm/i915/display/intel_tc.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,14 +1225,19 @@ static void tc_phy_get_hw_state(struct intel_tc_port *tc)
12251225
tc->phy_ops->get_hw_state(tc);
12261226
}
12271227

1228-
static bool tc_phy_is_ready_and_owned(struct intel_tc_port *tc,
1229-
bool phy_is_ready, bool phy_is_owned)
1228+
/* Is the PHY owned by display i.e. is it in legacy or DP-alt mode? */
1229+
static bool tc_phy_owned_by_display(struct intel_tc_port *tc,
1230+
bool phy_is_ready, bool phy_is_owned)
12301231
{
12311232
struct intel_display *display = to_intel_display(tc->dig_port);
12321233

1233-
drm_WARN_ON(display->drm, phy_is_owned && !phy_is_ready);
1234+
if (DISPLAY_VER(display) < 20) {
1235+
drm_WARN_ON(display->drm, phy_is_owned && !phy_is_ready);
12341236

1235-
return phy_is_ready && phy_is_owned;
1237+
return phy_is_ready && phy_is_owned;
1238+
} else {
1239+
return phy_is_owned;
1240+
}
12361241
}
12371242

12381243
static bool tc_phy_is_connected(struct intel_tc_port *tc,
@@ -1243,7 +1248,7 @@ static bool tc_phy_is_connected(struct intel_tc_port *tc,
12431248
bool phy_is_owned = tc_phy_is_owned(tc);
12441249
bool is_connected;
12451250

1246-
if (tc_phy_is_ready_and_owned(tc, phy_is_ready, phy_is_owned))
1251+
if (tc_phy_owned_by_display(tc, phy_is_ready, phy_is_owned))
12471252
is_connected = port_pll_type == ICL_PORT_DPLL_MG_PHY;
12481253
else
12491254
is_connected = port_pll_type == ICL_PORT_DPLL_DEFAULT;
@@ -1351,7 +1356,7 @@ tc_phy_get_current_mode(struct intel_tc_port *tc)
13511356
phy_is_ready = tc_phy_is_ready(tc);
13521357
phy_is_owned = tc_phy_is_owned(tc);
13531358

1354-
if (!tc_phy_is_ready_and_owned(tc, phy_is_ready, phy_is_owned)) {
1359+
if (!tc_phy_owned_by_display(tc, phy_is_ready, phy_is_owned)) {
13551360
mode = get_tc_mode_in_phy_not_owned_state(tc, live_mode);
13561361
} else {
13571362
drm_WARN_ON(display->drm, live_mode == TC_PORT_TBT_ALT);

0 commit comments

Comments
 (0)