Skip to contentSkip to conversation

drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

PATCH Superseded Paulo Zanoni 5 participants 12 messages Jul 31, 2018 – Aug 23, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

Unlike the other ports, TC ports are not available to use as soon as we get a hotplug. The TC PHYs can be shared between multiple
controllers: display, USB, etc. As a result, handshaking through FIA is required around connect and disconnect to cleanly transfer ownership with the controller and set the type-C power state.

This patch implements the flow sequences described by our specification. We opt to grab ownership of the ports as soon as we get the hotplugs in order to simplify the interactions and avoid surprises in the user space side. We may consider changing this in the future, once we improve our testing capabilities on this area.

v2:
* This unifies the DP and HDMI patches so we can discuss everything at once so people looking at random single patches can actually understand the direction.
* I found out the spec was updated a while ago. There's a small difference in the connect flow and the patch was updated for that.
* Our spec also now gives a good explanation on what is really happening. As a result, comments were added.
* Add some more comments as requested by Rodrigo (Rodrigo).

BSpec: 21750, 4250.

Cc Animesh Manna <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_reg.h   |   6 +++
 drivers/gpu/drm/i915/intel_dp.c   | 110 +++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_hdmi.c |  11 ++--
 3 files changed, 123 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 079c89da8831..bcf6ef75cffe 100644
@@ -10753,4 +10753,10 @@ enum skl_power_gate {
 #define   DP_LANE_ASSIGNMENT_MASK(tc_port)	(0xf << ((tc_port) * 8))
 #define   DP_LANE_ASSIGNMENT(tc_port, x)	((x) << ((tc_port) * 8))
 
+#define PORT_TX_DFLEXDPPMS				_MMIO(0x163890)
+#define   DP_PHY_MODE_STATUS_COMPLETED(tc_port)		(1 << (tc_port))
+
+#define PORT_TX_DFLEXDPCSSS				_MMIO(0x163894)
+#define   DP_PHY_MODE_STATUS_NOT_SAFE(tc_port)		(1 << (tc_port))
+
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_dp.c +109 -1

133 lines not on this page · raw message

drivers/gpu/drm/i915/intel_hdmi.c +8 -3
index 8363fbd18ee8..548199e59b6c 100644
@@ -1905,21 +1905,26 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 static enum drm_connector_status
 intel_hdmi_detect(struct drm_connector *connector, bool force)
 {
-	enum drm_connector_status status;
+	enum drm_connector_status status = connector_status_disconnected;
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
+	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
+	struct intel_encoder *encoder = &hdmi_to_dig_port(intel_hdmi)->base;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
 		      connector->base.id, connector->name);
 
 	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
 
+	if (IS_ICELAKE(dev_priv) &&
+	    !intel_digital_port_connected(encoder))
+		goto out;
+
 	intel_hdmi_unset_edid(connector);
 
 	if (intel_hdmi_set_edid(connector))
 		status = connector_status_connected;
-	else
-		status = connector_status_disconnected;
 
+out:
 	intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
 
 	return status;
Signature · 6 lines
2.14.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✓ Fi.CI.BAT: success for drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

== Series Details ==

== Series Details ==

Series: drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows
URL : https://patchwork.freedesktop.org/series/47518/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4600 -> Patchwork_9826 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/47518/revisions/1/mbox/

== Known issues ==

Here are the changes found in Patchwork_9826 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_guc:
      fi-skl-guc:         NOTRUN -> DMESG-WARN (fdo#107175, fdo#107258)

    igt@drv_selftest@live_hangcheck:
      fi-skl-6600u:       PASS -> DMESG-FAIL (fdo#107174, fdo#106560)

    igt@drv_selftest@live_workarounds:
      fi-cnl-psr:         PASS -> DMESG-FAIL (fdo#107292)

    igt@gem_exec_suspend@basic-s3:
      fi-snb-2600:        PASS -> DMESG-WARN (fdo#102365)

    igt@gem_exec_suspend@basic-s4-devices:
      fi-kbl-7500u:       PASS -> DMESG-WARN (fdo#105128, fdo#107139)

    igt@kms_busy@basic-flip-b:
      fi-kbl-r:           PASS -> DMESG-WARN (fdo#105602)

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         PASS -> FAIL (fdo#104008)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_hangcheck:
      fi-kbl-guc:         DMESG-FAIL (fdo#106947) -> PASS
      fi-skl-6260u:       DMESG-FAIL (fdo#107174, fdo#106560) -> PASS

    igt@drv_selftest@live_workarounds:
      {fi-cfl-8109u}:     DMESG-FAIL (fdo#107292) -> PASS

    igt@kms_frontbuffer_tracking@basic:
      fi-hsw-peppy:       DMESG-FAIL (fdo#106103, fdo#102614) -> PASS

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a:
      fi-skl-6700k2:      FAIL (fdo#103191) -> PASS

    
    ==== Warnings ====

    {igt@kms_psr@primary_page_flip}:
      fi-cnl-psr:         DMESG-FAIL (fdo#107372) -> DMESG-WARN (fdo#107372)

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
fdo#105128 https://bugs.freedesktop.org/show_bug.cgi?id=105128
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#106103 https://bugs.freedesktop.org/show_bug.cgi?id=106103
fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
fdo#107139 https://bugs.freedesktop.org/show_bug.cgi?id=107139
fdo#107174 https://bugs.freedesktop.org/show_bug.cgi?id=107174
fdo#107175 https://bugs.freedesktop.org/show_bug.cgi?id=107175
fdo#107258 https://bugs.freedesktop.org/show_bug.cgi?id=107258
fdo#107292 https://bugs.freedesktop.org/show_bug.cgi?id=107292
fdo#107372 https://bugs.freedesktop.org/show_bug.cgi?id=107372

== Participating hosts (48 -> 45) ==

Additional (2): fi-skl-guc fi-glk-j4005
Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-byt-clapper fi-hsw-4200u

== Build changes ==

* Linux: CI_DRM_4600 -> Patchwork_9826

CI_DRM_4600: 308427119c70d0aaa90433b05969a0317165b122 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4581: f1c868dae24056ebc27e4f3c197724ce9b956a8a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9826: b12d368538105a81cc71815aeff6197064ae8a9c @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

b12d36853810 drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9826/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✓ Fi.CI.IGT: success for drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

In reply to Paulo Zanoni
== Series Details ==

== Series Details ==

Series: drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows
URL : https://patchwork.freedesktop.org/series/47518/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4600_full -> Patchwork_9826_full =

== Summary - WARNING ==

Minor unknown changes coming with Patchwork_9826_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_9826_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9826_full:

=== IGT changes ===

    ==== Warnings ====

    igt@kms_atomic_transition@plane-all-transition-nonblocking:
      shard-snb:          PASS -> SKIP +2

== Known issues ==

Here are the changes found in Patchwork_9826_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_ctx_isolation@vcs0-s3:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665)

    igt@kms_rotation_crc@sprite-rotation-90-pos-100-0:
      shard-kbl:          PASS -> FAIL (fdo#103925)

    igt@perf@polling:
      shard-hsw:          PASS -> FAIL (fdo#102252)

    
    ==== Possible fixes ====

    igt@gem_ppgtt@blt-vs-render-ctxn:
      shard-kbl:          INCOMPLETE (fdo#106023, fdo#103665) -> PASS

    igt@kms_flip@basic-flip-vs-wf_vblank:
      shard-glk:          FAIL (fdo#105312) -> PASS

    igt@kms_flip@dpms-vs-vblank-race:
      shard-glk:          FAIL (fdo#103060) -> PASS

    igt@kms_flip@wf_vblank-ts-check-interruptible:
      shard-glk:          FAIL (fdo#100368) -> PASS

    igt@kms_setmode@basic:
      shard-apl:          FAIL (fdo#99912) -> PASS
      shard-kbl:          FAIL (fdo#99912) -> PASS

    
    ==== Warnings ====

    igt@drv_suspend@shrink:
      shard-glk:          FAIL (fdo#106886) -> INCOMPLETE (fdo#103359, fdo#106886, k.org#198133)

fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#105312 https://bugs.freedesktop.org/show_bug.cgi?id=105312
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#106886 https://bugs.freedesktop.org/show_bug.cgi?id=106886
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133

== Participating hosts (5 -> 5) ==

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_4600 -> Patchwork_9826

CI_DRM_4600: 308427119c70d0aaa90433b05969a0317165b122 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4581: f1c868dae24056ebc27e4f3c197724ce9b956a8a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9826: b12d368538105a81cc71815aeff6197064ae8a9c @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9826/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
In reply to Paulo Zanoni

Quoting Paulo Zanoni (2018-08-01 00:45:04)

Quoted 4 lines
drivers/gpu/drm/i915/intel_dp.c +4 -0
+static bool icl_tc_phy_connect(struct drm_i915_private *dev_priv,
+                              struct intel_digital_port *dig_port)
+{
+       enum tc_port tc_port = intel_port_to_tc(dev_priv, dig_port->base.port);

drivers/gpu/drm/i915/intel_dp.c static void icl_update_tc_port_type(struct drm_i915_private *dev_priv, · line 4855

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +10 -0
+       u32 val;
+
+       if (dig_port->tc_type != TC_PORT_LEGACY &&
+           dig_port->tc_type != TC_PORT_TYPEC)
+               return true;
+
+       val = I915_READ(PORT_TX_DFLEXDPPMS);
+       if (!(val & DP_PHY_MODE_STATUS_COMPLETED(tc_port))) {
+               DRM_ERROR("DP PHY for TC port %d not ready\n", tc_port);
+               return false;

This is going to be hit as soon as someone manages to plug&unplug the cable rapidly enough, The callers all handle the bool return so why proclaim error on their behalf?
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Em Qua, 2018-08-01 às 09:22 +0100, Chris Wilson escreveu:

Quoted 6 lines

Quoting Paulo Zanoni (2018-08-01 00:45:04)

Quoted 5 lines
drivers/gpu/drm/i915/intel_dp.c +4 -0
+static bool icl_tc_phy_connect(struct drm_i915_private *dev_priv,
+                              struct intel_digital_port *dig_port)
+{
+       enum tc_port tc_port = intel_port_to_tc(dev_priv, dig_port-
Quoted 1 line

base.port);

Quoted 15 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_dp.c +9 -0
+       u32 val;
+
+       if (dig_port->tc_type != TC_PORT_LEGACY &&
+           dig_port->tc_type != TC_PORT_TYPEC)
+               return true;
+
+       val = I915_READ(PORT_TX_DFLEXDPPMS);
+       if (!(val & DP_PHY_MODE_STATUS_COMPLETED(tc_port))) {
+               DRM_ERROR("DP PHY for TC port %d not ready\n",

tc_port);
+ return false;

This is going to be hit as soon as someone manages to plug&unplug the cable rapidly enough, The callers all handle the bool return so why proclaim error on their behalf?

This error message is not supposed to happen since the spec says we only get the interrupt after the PHY is actually ready. So my plan was to have a way to find out in case the spec is wrong, which sometimes happen.

OTOH there's actually nothing we can do here, and the callers will indeed handle the return. I'll change it to DRM_DEBUG_KMS.

Thanks,
Paulo

Quoted 1 line

-Chris

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

PATCH v3 1/1 drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

In reply to Paulo Zanoni

Unlike the other ports, TC ports are not available to use as soon as we get a hotplug. The TC PHYs can be shared between multiple
controllers: display, USB, etc. As a result, handshaking through FIA is required around connect and disconnect to cleanly transfer ownership with the controller and set the type-C power state.

This patch implements the flow sequences described by our specification. We opt to grab ownership of the ports as soon as we get the hotplugs in order to simplify the interactions and avoid surprises in the user space side. We may consider changing this in the future, once we improve our testing capabilities on this area.

v2:
* This unifies the DP and HDMI patches so we can discuss everything at once so people looking at random single patches can actually understand the direction.
* I found out the spec was updated a while ago. There's a small difference in the connect flow and the patch was updated for that.
* Our spec also now gives a good explanation on what is really happening. As a result, comments were added.
* Add some more comments as requested by Rodrigo (Rodrigo).
v3:
* Downgrade a DRM_ERROR that shouldn't ever happen but we can't act on in case it does (Chris).

BSpec: 21750, 4250.

Cc Animesh Manna <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_reg.h   |   6 +++
 drivers/gpu/drm/i915/intel_dp.c   | 110 +++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_hdmi.c |  11 ++--
 3 files changed, 123 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 1da1c7743785..a5f4dfe9ebdf 100644
@@ -10750,4 +10750,10 @@ enum skl_power_gate {
 #define   DP_LANE_ASSIGNMENT_MASK(tc_port)	(0xf << ((tc_port) * 8))
 #define   DP_LANE_ASSIGNMENT(tc_port, x)	((x) << ((tc_port) * 8))
 
+#define PORT_TX_DFLEXDPPMS				_MMIO(0x163890)
+#define   DP_PHY_MODE_STATUS_COMPLETED(tc_port)		(1 << (tc_port))
+
+#define PORT_TX_DFLEXDPCSSS				_MMIO(0x163894)
+#define   DP_PHY_MODE_STATUS_NOT_SAFE(tc_port)		(1 << (tc_port))
+
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_dp.c +109 -1

133 lines not on this page · raw message

drivers/gpu/drm/i915/intel_hdmi.c +8 -3
index 8363fbd18ee8..548199e59b6c 100644
@@ -1905,21 +1905,26 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 static enum drm_connector_status
 intel_hdmi_detect(struct drm_connector *connector, bool force)
 {
-	enum drm_connector_status status;
+	enum drm_connector_status status = connector_status_disconnected;
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
+	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
+	struct intel_encoder *encoder = &hdmi_to_dig_port(intel_hdmi)->base;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
 		      connector->base.id, connector->name);
 
 	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
 
+	if (IS_ICELAKE(dev_priv) &&
+	    !intel_digital_port_connected(encoder))
+		goto out;
+
 	intel_hdmi_unset_edid(connector);
 
 	if (intel_hdmi_set_edid(connector))
 		status = connector_status_connected;
-	else
-		status = connector_status_disconnected;
 
+out:
 	intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
 
 	return status;
Signature · 6 lines
2.14.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
Quoted 151 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Paulo Zanoni
Sent: Wednesday, August 1, 2018 10:35 AM
To: [email protected]
Cc: Zanoni, Paulo R <[email protected]>; Vivi, Rodrigo <[email protected]>
Subject: [Intel-gfx] [PATCH v3] drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

Unlike the other ports, TC ports are not available to use as soon as we get a hotplug. The TC PHYs can be shared between multiple
controllers: display, USB, etc. As a result, handshaking through FIA is required around connect and disconnect to cleanly transfer ownership with the controller and set the type-C power state.

This patch implements the flow sequences described by our specification. We opt to grab ownership of the ports as soon as we get the hotplugs in order to simplify the interactions and avoid surprises in the user space side. We may consider changing this in the future, once we improve our testing capabilities on this area.

v2:
* This unifies the DP and HDMI patches so we can discuss everything at once so people looking at random single patches can actually understand the direction.
* I found out the spec was updated a while ago. There's a small difference in the connect flow and the patch was updated for that.
* Our spec also now gives a good explanation on what is really happening. As a result, comments were added.
* Add some more comments as requested by Rodrigo (Rodrigo). v3:
* Downgrade a DRM_ERROR that shouldn't ever happen but we can't act on in case it does (Chris).

BSpec: 21750, 4250.

Cc Animesh Manna <[email protected]>
Cc Rodrigo Vivi <[email protected]>

---
drivers/gpu/drm/i915/i915_reg.h | 6 +++
drivers/gpu/drm/i915/intel_dp.c | 110
+++++++++++++++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_hdmi.c | 11 ++--

3 files changed, 123 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 1da1c7743785..a5f4dfe9ebdf 100644
@@ -10750,4 +10750,10 @@ enum skl_power_gate {
 #define   DP_LANE_ASSIGNMENT_MASK(tc_port)	(0xf << ((tc_port) * 8))
 #define   DP_LANE_ASSIGNMENT(tc_port, x)	((x) << ((tc_port) * 8))
 
+#define PORT_TX_DFLEXDPPMS
 	_MMIO(0x163890)
+#define   DP_PHY_MODE_STATUS_COMPLETED(tc_port)		(1 <<

(tc_port))

drivers/gpu/drm/i915/i915_reg.h +2 -0
+
+#define PORT_TX_DFLEXDPCSSS
	_MMIO(0x163894)
drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define   DP_PHY_MODE_STATUS_NOT_SAFE(tc_port)		(1 << (tc_port))
+

#endif /* _I915_REG_H_ */

drivers/gpu/drm/i915/intel_dp.c +76 -0
index fec21aa3db93..86eded613456 100644
@@ -4818,6 +4818,104 @@ static void icl_update_tc_port_type(struct
 drm_i915_private *dev_priv,
 			      type_str);
 }
 
+/*
+ * This function implements the first part of the Connect Flow
+described by our
+ * specification, Gen11 TypeC Programming chapter. The rest of the flow
+(reading
+ * lanes, EDID, etc) is done as needed in the typical places.
+ *
+ * Unlike the other ports, type-C ports are not available to use as
+soon as we
+ * get a hotplug. The type-C PHYs can be shared between multiple controllers:
+ * display, USB, etc. As a result, handshaking through FIA is required
+around
+ * connect and disconnect to cleanly transfer ownership with the
+controller and
+ * set the type-C power state.
+ *
+ * We could opt to only do the connect flow when we actually try to use
+the AUX
+ * channels or do a modeset, then immediately run the disconnect flow
+after
+ * usage, but there are some implications on this for a dynamic environment:
+ * things may go away or change behind our backs. So for now our driver
+is
+ * always trying to acquire ownership of the controller as soon as it
+gets an
+ * interrupt (or polls state and sees a port is connected) and only
+gives it
+ * back when it sees a disconnect. Implementation of a more
+fine-grained model
+ * will require a lot of coordination with user space and thorough
+testing for
+ * the extra possible cases.
+ */
+static bool icl_tc_phy_connect(struct drm_i915_private *dev_priv,
+			       struct intel_digital_port *dig_port) {
+	enum tc_port tc_port = intel_port_to_tc(dev_priv, dig_port->base.port);
+	u32 val;
+
+	if (dig_port->tc_type != TC_PORT_LEGACY &&
+	    dig_port->tc_type != TC_PORT_TYPEC)
+		return true;
+
+	val = I915_READ(PORT_TX_DFLEXDPPMS);
+	if (!(val & DP_PHY_MODE_STATUS_COMPLETED(tc_port))) {
+		DRM_DEBUG_KMS("DP PHY for TC port %d not ready\n",
 tc_port);
+		return false;
+	}
+
+	/*
+	 * This function may be called many times in a row without an HPD event
+	 * in between, so try to avoid the write when we can.
+	 */
+	val = I915_READ(PORT_TX_DFLEXDPCSSS);
+	if (!(val & DP_PHY_MODE_STATUS_NOT_SAFE(tc_port))) {
+		val |= DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+	}
+
+	/*
+	 * Now we have to re-check the live state, in case the port recently
+	 * became disconnected. Not necessary for legacy mode.
+	 */
+	if (dig_port->tc_type == TC_PORT_TYPEC &&
+	    !(I915_READ(PORT_TX_DFLEXDPSP) & TC_LIVE_STATE_TC(tc_port))) {
+		DRM_DEBUG_KMS("TC PHY %d sudden disconnect.\n", tc_port);
+		val = I915_READ(PORT_TX_DFLEXDPCSSS);
+		val &= ~DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+		return false;
+	}
+
+	return true;
+}
+
+/*
+ * See the comment at the connect function. This implements the

drivers/gpu/drm/i915/intel_dp.c static void icl_update_tc_port_type(struct · line 4908

Quoted 10 lines
drivers/gpu/drm/i915/intel_dp.c +10 -0
+Disconnect
+ * Flow.
+ */
+static void icl_tc_phy_disconnect(struct drm_i915_private *dev_priv,
+				  struct intel_digital_port *dig_port) {
+	enum tc_port tc_port = intel_port_to_tc(dev_priv, dig_port->base.port);
+	u32 val;
+
+	if (dig_port->tc_type != TC_PORT_LEGACY &&
+	    dig_port->tc_type != TC_PORT_TYPEC)
	Don’t we also need to check for dig_port->tc_type != TC_PORT_TBT?
Quoted 36 lines
drivers/gpu/drm/i915/intel_dp.c +29 -0
+		return;
+
+	/*
+	 * This function may be called many times in a row without an HPD event
+	 * in between, so try to avoid the write when we can.
+	 */
+	val = I915_READ(PORT_TX_DFLEXDPCSSS);
+	if (val & DP_PHY_MODE_STATUS_NOT_SAFE(tc_port)) {
+		val &= ~DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+	}
+}
+
+/*
+ * The type-C ports are different because even when they are connected,
+they may
+ * not be available/usable by the graphics driver: see the comment on
+ * icl_tc_phy_connect(). So in our driver instead of adding the
+additional
+ * concept of "usable" and make everything check for "connected and
+usable" we
+ * define a port as "connected" when it is not only connected, but also
+when it
+ * is usable by the rest of the driver. That maintains the old
+assumption that
+ * connected ports are usable, and avoids exposing to the users objects
+they
+ * can't really use.
+ */

static bool icl_tc_port_connected(struct drm_i915_private *dev_priv,
struct intel_digital_port *intel_dig_port) { @@
-4836,12 +4934,17 @@ static bool icl_tc_port_connected(struct drm_i915_private *dev_priv,

	is_typec = dpsp & TC_LIVE_STATE_TC(tc_port);
	is_tbt = dpsp & TC_LIVE_STATE_TBT(tc_port);

drivers/gpu/drm/i915/intel_dp.c static bool icl_tc_port_connected(struct drm_i915_private *dev_priv, · line 4937

Quoted 2 lines
drivers/gpu/drm/i915/intel_dp.c +1 -1
-	if (!is_legacy && !is_typec && !is_tbt)
+	if (!is_legacy && !is_typec && !is_tbt) {

If it is none of the above, then why not just return false?

Anusha

Quoted 65 lines
drivers/gpu/drm/i915/intel_dp.c +1 -0
+		icl_tc_phy_disconnect(dev_priv, intel_dig_port);
		return false;
drivers/gpu/drm/i915/intel_dp.c +1 -0
+	}
	icl_update_tc_port_type(dev_priv, intel_dig_port, is_legacy, is_typec,
				is_tbt);
drivers/gpu/drm/i915/intel_dp.c +3 -0
+	if (!icl_tc_phy_connect(dev_priv, intel_dig_port))
+		return false;
+
	return true;
}
drivers/gpu/drm/i915/intel_dp.c +8 -0
@@ -4869,6 +4972,11 @@ static bool icl_digital_port_connected(struct
 intel_encoder *encoder)
 * intel_digital_port_connected - is the specified port connected?
 * @encoder: intel_encoder
 *
+ * In cases where there's a connector physically connected but it can't
+ be used
+ * by our hardware we also return false, since the rest of the driver
+ should
+ * pretty much treat the port as disconnected. This is relevant for
+ type-C
+ * (starting on ICL) where there's ownership involved.
+ *
 * Return %true if port is connected, %false otherwise.
 */

bool intel_digital_port_connected(struct intel_encoder *encoder) diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c index 8363fbd18ee8..548199e59b6c 100644

drivers/gpu/drm/i915/intel_hdmi.c +8 -4
@@ -1905,21 +1905,26 @@ intel_hdmi_set_edid(struct drm_connector
 *connector)  static enum drm_connector_status  intel_hdmi_detect(struct
 drm_connector *connector, bool force)  {
-	enum drm_connector_status status;
+	enum drm_connector_status status = connector_status_disconnected;
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
+	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
+	struct intel_encoder *encoder = &hdmi_to_dig_port(intel_hdmi)->base;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
 		      connector->base.id, connector->name);
 
 	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
 
+	if (IS_ICELAKE(dev_priv) &&
+	    !intel_digital_port_connected(encoder))
+		goto out;
+
 	intel_hdmi_unset_edid(connector);
 
 	if (intel_hdmi_set_edid(connector))
 		status = connector_status_connected;
-	else
-		status = connector_status_disconnected;
 
+out:
 	intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
 
 	return status;
--

2.14.4

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

Em Sex, 2018-08-17 às 09:25 -0700, Srivatsa, Anusha escreveu:

Quoted 196 lines
Quoted 190 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of
Paulo Zanoni
Sent: Wednesday, August 1, 2018 10:35 AM
To: [email protected]
Cc: Zanoni, Paulo R <[email protected]>; Vivi, Rodrigo <[email protected]>
Subject: [Intel-gfx] [PATCH v3] drm/i915/icl: implement the tc/legacy HPD {dis,
}connect flows

Unlike the other ports, TC ports are not available to use as soon as we get a
hotplug. The TC PHYs can be shared between multiple
controllers: display, USB, etc. As a result, handshaking through FIA is required
around connect and disconnect to cleanly transfer ownership with the controller
and set the type-C power state.

This patch implements the flow sequences described by our specification. We opt
to grab ownership of the ports as soon as we get the hotplugs in order to simplify
the interactions and avoid surprises in the user space side. We may consider
changing this in the future, once we improve our testing capabilities on this area.

v2:
* This unifies the DP and HDMI patches so we can discuss everything at once so people looking at random single patches can actually understand the direction.
* I found out the spec was updated a while ago. There's a small difference in the connect flow and the patch was updated for
that.
* Our spec also now gives a good explanation on what is really happening. As a result, comments were added.
* Add some more comments as requested by Rodrigo (Rodrigo). v3:
* Downgrade a DRM_ERROR that shouldn't ever happen but we can't act on in case it does (Chris).

BSpec: 21750, 4250.

Cc Animesh Manna <[email protected]>
Cc Rodrigo Vivi <[email protected]>

---
drivers/gpu/drm/i915/i915_reg.h | 6 +++
drivers/gpu/drm/i915/intel_dp.c | 110
+++++++++++++++++++++++++++++++++++++-
drivers/gpu/drm/i915/intel_hdmi.c | 11 ++--

3 files changed, 123 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 1da1c7743785..a5f4dfe9ebdf 100644
@@ -10750,4 +10750,10 @@ enum skl_power_gate {
 #define   DP_LANE_ASSIGNMENT_MASK(tc_port)	(0xf <<
 ((tc_port) * 8))
 #define   DP_LANE_ASSIGNMENT(tc_port, x)	((x) << ((tc_port)
 * 8))
 
+#define PORT_TX_DFLEXDPPMS
	_MMIO(0x163890)

+#define DP_PHY_MODE_STATUS_COMPLETED(tc_port) (1
<<
(tc_port))

drivers/gpu/drm/i915/i915_reg.h +2 -0
+
+#define PORT_TX_DFLEXDPCSSS
	_MMIO(0x163894)

+#define DP_PHY_MODE_STATUS_NOT_SAFE(tc_port) (1
<< (tc_port))
+
#endif /* _I915_REG_H_ */

drivers/gpu/drm/i915/intel_dp.c +4 -0
index fec21aa3db93..86eded613456 100644
@@ -4818,6 +4818,104 @@ static void icl_update_tc_port_type(struct
 drm_i915_private *dev_priv,
 			      type_str);
 }
 
+/*
+ * This function implements the first part of the Connect Flow
+described by our
+ * specification, Gen11 TypeC Programming chapter. The rest of the

flow
+(reading
+ * lanes, EDID, etc) is done as needed in the typical places.
+ *
+ * Unlike the other ports, type-C ports are not available to use as
+soon as we
+ * get a hotplug. The type-C PHYs can be shared between multiple controllers:
+ * display, USB, etc. As a result, handshaking through FIA is required

drivers/gpu/drm/i915/intel_dp.c +6 -0
+around
+ * connect and disconnect to cleanly transfer ownership with the
+controller and
+ * set the type-C power state.
+ *
+ * We could opt to only do the connect flow when we actually try

to use
+the AUX
+ * channels or do a modeset, then immediately run the disconnect flow
+after
+ * usage, but there are some implications on this for a dynamic environment:
+ * things may go away or change behind our backs. So for now our driver
+is
+ * always trying to acquire ownership of the controller as soon as it
+gets an
+ * interrupt (or polls state and sees a port is connected) and only

drivers/gpu/drm/i915/intel_dp.c +9 -0
+gives it
+ * back when it sees a disconnect. Implementation of a more
+fine-grained model
+ * will require a lot of coordination with user space and thorough
+testing for
+ * the extra possible cases.
+ */
+static bool icl_tc_phy_connect(struct drm_i915_private *dev_priv,
+			       struct intel_digital_port

*dig_port) {

drivers/gpu/drm/i915/intel_dp.c +1 -0
+	enum tc_port tc_port = intel_port_to_tc(dev_priv,

dig_port->base.port);

drivers/gpu/drm/i915/intel_dp.c +9 -0
+	u32 val;
+
+	if (dig_port->tc_type != TC_PORT_LEGACY &&
+	    dig_port->tc_type != TC_PORT_TYPEC)
+		return true;
+
+	val = I915_READ(PORT_TX_DFLEXDPPMS);
+	if (!(val & DP_PHY_MODE_STATUS_COMPLETED(tc_port))) {
+		DRM_DEBUG_KMS("DP PHY for TC port %d not ready\n",

tc_port);

drivers/gpu/drm/i915/intel_dp.c +5 -0
+		return false;
+	}
+
+	/*
+	 * This function may be called many times in a row without

an HPD event

drivers/gpu/drm/i915/intel_dp.c +10 -0
+	 * in between, so try to avoid the write when we can.
+	 */
+	val = I915_READ(PORT_TX_DFLEXDPCSSS);
+	if (!(val & DP_PHY_MODE_STATUS_NOT_SAFE(tc_port))) {
+		val |= DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+	}
+
+	/*
+	 * Now we have to re-check the live state, in case the

port recently

drivers/gpu/drm/i915/intel_dp.c +4 -0
+	 * became disconnected. Not necessary for legacy mode.
+	 */
+	if (dig_port->tc_type == TC_PORT_TYPEC &&
+	    !(I915_READ(PORT_TX_DFLEXDPSP) &

TC_LIVE_STATE_TC(tc_port))) {

drivers/gpu/drm/i915/intel_dp.c +1 -0
+		DRM_DEBUG_KMS("TC PHY %d sudden disconnect.\n",

tc_port);

drivers/gpu/drm/i915/intel_dp.c +15 -0
+		val = I915_READ(PORT_TX_DFLEXDPCSSS);
+		val &= ~DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+		return false;
+	}
+
+	return true;
+}
+
+/*
+ * See the comment at the connect function. This implements the
+Disconnect
+ * Flow.
+ */
+static void icl_tc_phy_disconnect(struct drm_i915_private

*dev_priv,

drivers/gpu/drm/i915/intel_dp.c +1 -0
+				  struct intel_digital_port

*dig_port) {

drivers/gpu/drm/i915/intel_dp.c +1 -0
+	enum tc_port tc_port = intel_port_to_tc(dev_priv,

dig_port->base.port);

drivers/gpu/drm/i915/intel_dp.c static void icl_update_tc_port_type(struct drm_i915_private *dev_priv, · line 4849

Quoted 4 lines
drivers/gpu/drm/i915/intel_dp.c +4 -0
+	u32 val;
+
+	if (dig_port->tc_type != TC_PORT_LEGACY &&
+	    dig_port->tc_type != TC_PORT_TYPEC)
	Don’t we also need to check for dig_port->tc_type !=
Quoted 1 line

TC_PORT_TBT?

We don't need to run these steps for TBT, the TBT sequence is simpler. See the spec.

Quoted 44 lines
Quoted 44 lines
drivers/gpu/drm/i915/intel_dp.c +4 -0
+		return;
+
+	/*
+	 * This function may be called many times in a row without

an HPD event

drivers/gpu/drm/i915/intel_dp.c +11 -0
+	 * in between, so try to avoid the write when we can.
+	 */
+	val = I915_READ(PORT_TX_DFLEXDPCSSS);
+	if (val & DP_PHY_MODE_STATUS_NOT_SAFE(tc_port)) {
+		val &= ~DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+	}
+}
+
+/*
+ * The type-C ports are different because even when they are

connected,
+they may
+ * not be available/usable by the graphics driver: see the comment on
+ * icl_tc_phy_connect(). So in our driver instead of adding the +additional
+ * concept of "usable" and make everything check for "connected and
+usable" we
+ * define a port as "connected" when it is not only connected, but also

drivers/gpu/drm/i915/intel_dp.c +4 -0
+when it
+ * is usable by the rest of the driver. That maintains the old
+assumption that
+ * connected ports are usable, and avoids exposing to the users

objects
+they
+ * can't really use.
+ */
static bool icl_tc_port_connected(struct drm_i915_private *dev_priv,
struct intel_digital_port
*intel_dig_port) { @@
-4836,12 +4934,17 @@ static bool icl_tc_port_connected(struct drm_i915_private *dev_priv,

	is_typec = dpsp & TC_LIVE_STATE_TC(tc_port);
	is_tbt = dpsp & TC_LIVE_STATE_TBT(tc_port);
Quoted 4 lines

drivers/gpu/drm/i915/intel_dp.c static bool icl_tc_port_connected(struct drm_i915_private *dev_priv, · line 4937

Quoted 2 lines
drivers/gpu/drm/i915/intel_dp.c +1 -1
-	if (!is_legacy && !is_typec && !is_tbt)
+	if (!is_legacy && !is_typec && !is_tbt) {

If it is none of the above, then why not just return false?

Because we need to run the disconnect sequence in case the port was previously connected so we release ownership of the lanes. That's the very goal of this patch.

Thanks,
Paulo

Quoted 74 lines

Anusha

Quoted 72 lines
drivers/gpu/drm/i915/intel_dp.c +1 -0
+		icl_tc_phy_disconnect(dev_priv, intel_dig_port);
		return false;
drivers/gpu/drm/i915/intel_dp.c +1 -0
+	}

icl_update_tc_port_type(dev_priv, intel_dig_port, is_legacy,
is_typec,

				is_tbt);
drivers/gpu/drm/i915/intel_dp.c +3 -0
+	if (!icl_tc_phy_connect(dev_priv, intel_dig_port))
+		return false;
+
	return true;
}
drivers/gpu/drm/i915/intel_dp.c +0 -0
@@ -4869,6 +4972,11 @@ static bool

icl_digital_port_connected(struct
intel_encoder *encoder)
* intel_digital_port_connected - is the specified port connected?
* @encoder: intel_encoder
*
+ * In cases where there's a connector physically connected but it can't
+ be used
+ * by our hardware we also return false, since the rest of the driver
+ should
+ * pretty much treat the port as disconnected. This is relevant for
+ type-C
+ * (starting on ICL) where there's ownership involved.
+ *
* Return %true if port is connected, %false otherwise. */
bool intel_digital_port_connected(struct intel_encoder *encoder) diff --git
a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 8363fbd18ee8..548199e59b6c 100644

drivers/gpu/drm/i915/intel_hdmi.c +0 -0
@@ -1905,21 +1905,26 @@ intel_hdmi_set_edid(struct drm_connector
 *connector)  static enum

drm_connector_status intel_hdmi_detect(struct
drm_connector *connector, bool force) {

drivers/gpu/drm/i915/intel_hdmi.c +1 -1
-	enum drm_connector_status status;
+	enum drm_connector_status status =
connector_status_disconnected;
	struct drm_i915_private *dev_priv = to_i915(connector->dev);
drivers/gpu/drm/i915/intel_hdmi.c +1 -0
+	struct intel_hdmi *intel_hdmi =

intel_attached_hdmi(connector);

drivers/gpu/drm/i915/intel_hdmi.c +1 -0
+	struct intel_encoder *encoder =

&hdmi_to_dig_port(intel_hdmi)->base;

	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
		      connector->base.id, connector->name);

	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
drivers/gpu/drm/i915/intel_hdmi.c +4 -0
+	if (IS_ICELAKE(dev_priv) &&
+	    !intel_digital_port_connected(encoder))
+		goto out;
+
	intel_hdmi_unset_edid(connector);

	if (intel_hdmi_set_edid(connector))
		status = connector_status_connected;
drivers/gpu/drm/i915/intel_hdmi.c +1 -2
-	else
-		status = connector_status_disconnected;
 
+out:
	intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
Quoted 8 lines
Quoted 8 lines
	return status;

--
2.14.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer Reviewed-by on v3 1/1
#8 lore raw
In reply to Paulo Zanoni
Quoted 25 lines · Paulo Zanoni

Unlike the other ports, TC ports are not available to use as soon as we get a hotplug. The TC PHYs can be shared between multiple
controllers: display, USB, etc. As a result, handshaking through FIA is required around connect and disconnect to cleanly transfer ownership with the controller and set the type-C power state.

This patch implements the flow sequences described by our specification. We opt to grab ownership of the ports as soon as we get the hotplugs in order to simplify the interactions and avoid surprises in the user space side. We may consider changing this in the future, once we improve our testing capabilities on this area.

v2:
* This unifies the DP and HDMI patches so we can discuss everything at once so people looking at random single patches can actually understand the direction.
* I found out the spec was updated a while ago. There's a small difference in the connect flow and the patch was updated for that.
* Our spec also now gives a good explanation on what is really happening. As a result, comments were added.
* Add some more comments as requested by Rodrigo (Rodrigo).
v3:
* Downgrade a DRM_ERROR that shouldn't ever happen but we can't act on in case it does (Chris).

Quoted 4 lines

BSpec: 21750, 4250.

Cc Animesh Manna <[email protected]>
Cc Rodrigo Vivi <[email protected]>

sorry for taking so long...

thanks for the doc and all other changes.

Quoted 202 lines
---
 drivers/gpu/drm/i915/i915_reg.h   |   6 +++
 drivers/gpu/drm/i915/intel_dp.c   | 110 +++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_hdmi.c |  11 ++--
 3 files changed, 123 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 1da1c7743785..a5f4dfe9ebdf 100644
@@ -10750,4 +10750,10 @@ enum skl_power_gate {
 #define   DP_LANE_ASSIGNMENT_MASK(tc_port)	(0xf << ((tc_port) * 8))
 #define   DP_LANE_ASSIGNMENT(tc_port, x)	((x) << ((tc_port) * 8))
 
+#define PORT_TX_DFLEXDPPMS				_MMIO(0x163890)
+#define   DP_PHY_MODE_STATUS_COMPLETED(tc_port)		(1 << (tc_port))
+
+#define PORT_TX_DFLEXDPCSSS				_MMIO(0x163894)
+#define   DP_PHY_MODE_STATUS_NOT_SAFE(tc_port)		(1 << (tc_port))
+
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_dp.c +109 -1
index fec21aa3db93..86eded613456 100644
@@ -4818,6 +4818,104 @@ static void icl_update_tc_port_type(struct drm_i915_private *dev_priv,
 			      type_str);
 }
 
+/*
+ * This function implements the first part of the Connect Flow described by our
+ * specification, Gen11 TypeC Programming chapter. The rest of the flow (reading
+ * lanes, EDID, etc) is done as needed in the typical places.
+ *
+ * Unlike the other ports, type-C ports are not available to use as soon as we
+ * get a hotplug. The type-C PHYs can be shared between multiple controllers:
+ * display, USB, etc. As a result, handshaking through FIA is required around
+ * connect and disconnect to cleanly transfer ownership with the controller and
+ * set the type-C power state.
+ *
+ * We could opt to only do the connect flow when we actually try to use the AUX
+ * channels or do a modeset, then immediately run the disconnect flow after
+ * usage, but there are some implications on this for a dynamic environment:
+ * things may go away or change behind our backs. So for now our driver is
+ * always trying to acquire ownership of the controller as soon as it gets an
+ * interrupt (or polls state and sees a port is connected) and only gives it
+ * back when it sees a disconnect. Implementation of a more fine-grained model
+ * will require a lot of coordination with user space and thorough testing for
+ * the extra possible cases.
+ */
+static bool icl_tc_phy_connect(struct drm_i915_private *dev_priv,
+			       struct intel_digital_port *dig_port)
+{
+	enum tc_port tc_port = intel_port_to_tc(dev_priv, dig_port->base.port);
+	u32 val;
+
+	if (dig_port->tc_type != TC_PORT_LEGACY &&
+	    dig_port->tc_type != TC_PORT_TYPEC)
+		return true;
+
+	val = I915_READ(PORT_TX_DFLEXDPPMS);
+	if (!(val & DP_PHY_MODE_STATUS_COMPLETED(tc_port))) {
+		DRM_DEBUG_KMS("DP PHY for TC port %d not ready\n", tc_port);
+		return false;
+	}
+
+	/*
+	 * This function may be called many times in a row without an HPD event
+	 * in between, so try to avoid the write when we can.
+	 */
+	val = I915_READ(PORT_TX_DFLEXDPCSSS);
+	if (!(val & DP_PHY_MODE_STATUS_NOT_SAFE(tc_port))) {
+		val |= DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+	}
+
+	/*
+	 * Now we have to re-check the live state, in case the port recently
+	 * became disconnected. Not necessary for legacy mode.
+	 */
+	if (dig_port->tc_type == TC_PORT_TYPEC &&
+	    !(I915_READ(PORT_TX_DFLEXDPSP) & TC_LIVE_STATE_TC(tc_port))) {
+		DRM_DEBUG_KMS("TC PHY %d sudden disconnect.\n", tc_port);
+		val = I915_READ(PORT_TX_DFLEXDPCSSS);
+		val &= ~DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+		return false;
+	}
+
+	return true;
+}
+
+/*
+ * See the comment at the connect function. This implements the Disconnect
+ * Flow.
+ */
+static void icl_tc_phy_disconnect(struct drm_i915_private *dev_priv,
+				  struct intel_digital_port *dig_port)
+{
+	enum tc_port tc_port = intel_port_to_tc(dev_priv, dig_port->base.port);
+	u32 val;
+
+	if (dig_port->tc_type != TC_PORT_LEGACY &&
+	    dig_port->tc_type != TC_PORT_TYPEC)
+		return;
+
+	/*
+	 * This function may be called many times in a row without an HPD event
+	 * in between, so try to avoid the write when we can.
+	 */
+	val = I915_READ(PORT_TX_DFLEXDPCSSS);
+	if (val & DP_PHY_MODE_STATUS_NOT_SAFE(tc_port)) {
+		val &= ~DP_PHY_MODE_STATUS_NOT_SAFE(tc_port);
+		I915_WRITE(PORT_TX_DFLEXDPCSSS, val);
+	}
+}
+
+/*
+ * The type-C ports are different because even when they are connected, they may
+ * not be available/usable by the graphics driver: see the comment on
+ * icl_tc_phy_connect(). So in our driver instead of adding the additional
+ * concept of "usable" and make everything check for "connected and usable" we
+ * define a port as "connected" when it is not only connected, but also when it
+ * is usable by the rest of the driver. That maintains the old assumption that
+ * connected ports are usable, and avoids exposing to the users objects they
+ * can't really use.
+ */
 static bool icl_tc_port_connected(struct drm_i915_private *dev_priv,
 				  struct intel_digital_port *intel_dig_port)
 {
@@ -4836,12 +4934,17 @@ static bool icl_tc_port_connected(struct drm_i915_private *dev_priv,
 	is_typec = dpsp & TC_LIVE_STATE_TC(tc_port);
 	is_tbt = dpsp & TC_LIVE_STATE_TBT(tc_port);
 
-	if (!is_legacy && !is_typec && !is_tbt)
+	if (!is_legacy && !is_typec && !is_tbt) {
+		icl_tc_phy_disconnect(dev_priv, intel_dig_port);
 		return false;
+	}
 
 	icl_update_tc_port_type(dev_priv, intel_dig_port, is_legacy, is_typec,
 				is_tbt);
 
+	if (!icl_tc_phy_connect(dev_priv, intel_dig_port))
+		return false;
+
 	return true;
 }
 
@@ -4869,6 +4972,11 @@ static bool icl_digital_port_connected(struct intel_encoder *encoder)
  * intel_digital_port_connected - is the specified port connected?
  * @encoder: intel_encoder
  *
+ * In cases where there's a connector physically connected but it can't be used
+ * by our hardware we also return false, since the rest of the driver should
+ * pretty much treat the port as disconnected. This is relevant for type-C
+ * (starting on ICL) where there's ownership involved.
+ *
  * Return %true if port is connected, %false otherwise.
  */
 bool intel_digital_port_connected(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_hdmi.c +8 -3
index 8363fbd18ee8..548199e59b6c 100644
@@ -1905,21 +1905,26 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 static enum drm_connector_status
 intel_hdmi_detect(struct drm_connector *connector, bool force)
 {
-	enum drm_connector_status status;
+	enum drm_connector_status status = connector_status_disconnected;
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
+	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
+	struct intel_encoder *encoder = &hdmi_to_dig_port(intel_hdmi)->base;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
 		      connector->base.id, connector->name);
 
 	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
 
+	if (IS_ICELAKE(dev_priv) &&
+	    !intel_digital_port_connected(encoder))
+		goto out;
+
 	intel_hdmi_unset_edid(connector);
 
 	if (intel_hdmi_set_edid(connector))
 		status = connector_status_connected;
-	else
-		status = connector_status_disconnected;
 
+out:
 	intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
 
 	return status;
Signature · 6 lines
2.14.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

✗ Fi.CI.BAT: failure for drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows (rev2)

In reply to Paulo Zanoni
== Series Details ==

== Series Details ==

Series: drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows (rev2)
URL : https://patchwork.freedesktop.org/series/47518/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4605 -> Patchwork_9836 =

== Summary - FAILURE ==

Serious unknown changes coming with Patchwork_9836 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_9836, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/47518/revisions/2/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9836:

=== IGT changes ===

    ==== Possible regressions ====

    igt@drv_selftest@live_sanitycheck:
      fi-bxt-j4205:       PASS -> DMESG-FAIL

    
    ==== Warnings ====

    igt@drv_selftest@live_requests:
      fi-bxt-j4205:       PASS -> SKIP +12

== Known issues ==

Here are the changes found in Patchwork_9836 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_guc:
      fi-skl-guc:         NOTRUN -> DMESG-WARN (fdo#107258, fdo#107175)

    igt@drv_selftest@live_workarounds:
      fi-cnl-psr:         PASS -> DMESG-FAIL (fdo#107292)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_workarounds:
      {fi-bdw-samus}:     DMESG-FAIL (fdo#107292) -> PASS

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         FAIL (fdo#104008) -> PASS

    
    ==== Warnings ====

    {igt@kms_psr@primary_page_flip}:
      fi-cnl-psr:         DMESG-FAIL (fdo#107372) -> DMESG-WARN (fdo#107372)

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
fdo#107175 https://bugs.freedesktop.org/show_bug.cgi?id=107175
fdo#107258 https://bugs.freedesktop.org/show_bug.cgi?id=107258
fdo#107292 https://bugs.freedesktop.org/show_bug.cgi?id=107292
fdo#107372 https://bugs.freedesktop.org/show_bug.cgi?id=107372

== Participating hosts (50 -> 44) ==

Additional (1): fi-skl-guc
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-glk-j4005 fi-byt-clapper

== Build changes ==

* Linux: CI_DRM_4605 -> Patchwork_9836

CI_DRM_4605: 50098198da758bdd54245d511f4f97236c296c72 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4582: 263ca16e4d8909f475d32a28fc0e5972bac214fb @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9836: 9fd77e93cebead1193a70e604e406a6ef1ea4fbc @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

9fd77e93cebe drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9836/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

✓ Fi.CI.BAT: success for drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows (rev2)

In reply to Paulo Zanoni
== Series Details ==

== Series Details ==

Series: drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows (rev2)
URL : https://patchwork.freedesktop.org/series/47518/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4702 -> Patchwork_10002 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/47518/revisions/2/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_10002:

=== IGT changes ===

    ==== Warnings ====

    {igt@pm_rpm@module-reload}:
      fi-byt-n2820:       DMESG-FAIL -> DMESG-WARN

== Known issues ==

Here are the changes found in Patchwork_10002 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@debugfs_test@read_all_entries:
      fi-kbl-r:           PASS -> DMESG-WARN (fdo#105602)

    igt@kms_frontbuffer_tracking@basic:
      {fi-byt-clapper}:   PASS -> FAIL (fdo#103167)

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b:
      {fi-byt-clapper}:   PASS -> FAIL (fdo#107362)

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362

== Participating hosts (53 -> 48) ==

Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u

== Build changes ==

* Linux: CI_DRM_4702 -> Patchwork_10002

CI_DRM_4702: 0349bfb08204a6b44f16551c2be3b58563ff73d2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4608: 94ebd21177feedf03e8f6dd1e73dca1a6ec7a0ac @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10002: 2b4ca525e11918638986e975d28f7f5a5e8b4de2 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

2b4ca525e119 drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10002/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#11 lore raw

✗ Fi.CI.IGT: failure for drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows (rev2)

In reply to Paulo Zanoni
== Series Details ==

== Series Details ==

Series: drm/i915/icl: implement the tc/legacy HPD {dis, }connect flows (rev2)
URL : https://patchwork.freedesktop.org/series/47518/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4702_full -> Patchwork_10002_full =

== Summary - FAILURE ==

Serious unknown changes coming with Patchwork_10002_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_10002_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_10002_full:

=== IGT changes ===

    ==== Possible regressions ====

    igt@gem_eio@banned:
      shard-glk:          PASS -> FAIL

    igt@gem_eio@reset-stress:
      shard-apl:          PASS -> FAIL

    
    ==== Warnings ====

    igt@kms_cursor_legacy@cursorb-vs-flipa-toggle:
      shard-hsw:          SKIP -> PASS

== Known issues ==

Here are the changes found in Patchwork_10002_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_suspend@shrink:
      shard-hsw:          PASS -> INCOMPLETE (fdo#103540, fdo#106886)

    igt@pm_rpm@system-suspend:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665, fdo#107556)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_hangcheck:
      shard-apl:          DMESG-FAIL (fdo#106947, fdo#106560) -> PASS

    igt@gem_ppgtt@blt-vs-render-ctx0:
      shard-kbl:          INCOMPLETE (fdo#106023, fdo#103665) -> PASS

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-glk:          FAIL (fdo#105363) -> PASS

fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
fdo#106886 https://bugs.freedesktop.org/show_bug.cgi?id=106886
fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
fdo#107556 https://bugs.freedesktop.org/show_bug.cgi?id=107556

== Participating hosts (5 -> 5) ==

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_4702 -> Patchwork_10002

CI_DRM_4702: 0349bfb08204a6b44f16551c2be3b58563ff73d2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4608: 94ebd21177feedf03e8f6dd1e73dca1a6ec7a0ac @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10002: 2b4ca525e11918638986e975d28f7f5a5e8b4de2 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10002/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx