Skip to contentSkip to conversation

drm/i915: Fix hpd handling for pins with two encoders

PATCH In review Ville Syrjala 3 participants 5 messages Nov 8, 2018 – Nov 9, 2018

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

PATCH 1/1 drm/i915: Fix hpd handling for pins with two encoders

From: Ville Syrjälä <[email protected]>

In my haste to remove irq_port[] I accidentally changed the way we deal with hpd pins that are shared by multiple encoders (DP and HDMI for pre-DDI platforms). Previously we would only handle such pins via ->hpd_pulse(), but now we queue up the hotplug work for the HDMI encoder directly. Worse yet, we now count each hpd twice and this increment the hpd storm count twice as fast. This can lead to spurious storms being detected.

Go back to the old way of doing things, ie. delegate to ->hpd_pulse() for any pin which has an encoder with that hook implemented. I don't really like the idea of adding irq_port[] back so let's loop through the encoders first to check if we have an encoder with ->hpd_pulse() for the pin, and then go through all the pins and decided on the correct course of action based on the earlier findings.

I have occasionally toyed with the idea of unifying the pre-DDI HDMI and DP encoders into a single encoder as well. Besides the hotplug processing it would have the other benefit of preventing userspace from trying to enable both encoders at the same time. That is simply illegal as they share the same clock/data pins. We have some testcases that will attempt that and thus fail on many older machines. But for now let's stick to fixing just the hotplug code.

Cc Lyude Paul <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes b6ca3eee18ba ("drm/i915: Nuke dev_priv->irq_port[]")
---
 drivers/gpu/drm/i915/intel_hotplug.c | 55 +++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_hotplug.c +42 -13
index 42e61e10f517..e24174d08fed 100644
@@ -414,33 +414,54 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
 	struct intel_encoder *encoder;
 	bool storm_detected = false;
 	bool queue_dig = false, queue_hp = false;
+	u32 long_hpd_pulse_mask = 0;
+	u32 short_hpd_pulse_mask = 0;
+	enum hpd_pin pin;
 
 	if (!pin_mask)
 		return;
 
 	spin_lock(&dev_priv->irq_lock);
+
+	/*
+	 * Determine whether ->hpd_pulse() exists for each pin, and
+	 * whether we have a short or a long pulse. This is needed
+	 * as each pin may have up to two encoders (HDMI and DP) and
+	 * only the one of them (DP) will have ->hpd_pulse().
+	 */
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
-		enum hpd_pin pin = encoder->hpd_pin;
 		bool has_hpd_pulse = intel_encoder_has_hpd_pulse(encoder);
-		bool long_hpd = true;
+		enum port port = encoder->port;
+		bool long_hpd;
 
+		pin = encoder->hpd_pin;
 		if (!(BIT(pin) & pin_mask))
 			continue;
 
-		if (has_hpd_pulse) {
-			enum port port = encoder->port;
+		if (!has_hpd_pulse)
+			continue;
 
-			long_hpd = long_mask & BIT(pin);
+		long_hpd = long_mask & BIT(pin);
 
-			DRM_DEBUG_DRIVER("digital hpd port %c - %s\n", port_name(port),
-					 long_hpd ? "long" : "short");
-			queue_dig = true;
-			if (long_hpd)
-				dev_priv->hotplug.long_port_mask |= (1 << port);
-			else
-				dev_priv->hotplug.short_port_mask |= (1 << port);
+		DRM_DEBUG_DRIVER("digital hpd port %c - %s\n", port_name(port),
+				 long_hpd ? "long" : "short");
+		queue_dig = true;
 
+		if (long_hpd) {
+			long_hpd_pulse_mask |= BIT(pin);
+			dev_priv->hotplug.long_port_mask |= BIT(port);
+		} else {
+			short_hpd_pulse_mask |= BIT(pin);
+			dev_priv->hotplug.short_port_mask |= BIT(port);
 		}
+	}
+
+	/* Now process each pin just once */
+	for_each_hpd_pin(pin) {
+		bool long_hpd;
+
+		if (!(BIT(pin) & pin_mask))
+			continue;
 
 		if (dev_priv->hotplug.stats[pin].state == HPD_DISABLED) {
 			/*
@@ -457,8 +478,16 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
 		if (dev_priv->hotplug.stats[pin].state != HPD_ENABLED)
 			continue;
 
-		if (!has_hpd_pulse) {
+		/*
+		 * Delegate to ->hpd_pulse() if one of the encoders for this
+		 * pin has it, otherwise let the hotplug_work deal with this
+		 * pin directly.
+		 */
+		if (((short_hpd_pulse_mask | long_hpd_pulse_mask) & BIT(pin))) {
+			long_hpd = long_hpd_pulse_mask & BIT(pin);
+		} else {
 			dev_priv->hotplug.event_bits |= BIT(pin);
+			long_hpd = true;
 			queue_hp = true;
 		}
 
Signature · 1 line
2.18.1
#1 lore raw

✓ Fi.CI.BAT: success for drm/i915: Fix hpd handling for pins with two encoders

== Series Details ==

== Series Details ==

Series: drm/i915: Fix hpd handling for pins with two encoders
URL : https://patchwork.freedesktop.org/series/52256/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_5106 -> Patchwork_10779 =

== Summary - SUCCESS ==

No regressions found.

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

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_ctx_create@basic-files:
      fi-icl-u2:          PASS -> DMESG-WARN (fdo#107724)

    igt@kms_chamelium@common-hpd-after-suspend:
      fi-skl-6700k2:      PASS -> WARN (fdo#108680)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-skl-guc:         PASS -> FAIL (fdo#103191, fdo#107362)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_coherency:
      fi-gdg-551:         DMESG-FAIL (fdo#107164) -> PASS

    igt@drv_selftest@live_contexts:
      fi-cfl-8109u:       DMESG-FAIL -> PASS

    igt@drv_selftest@live_hangcheck:
      fi-icl-u:           INCOMPLETE (fdo#108315) -> PASS

    igt@kms_flip@basic-flip-vs-modeset:
      fi-hsw-4770r:       DMESG-WARN (fdo#105602) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-byt-clapper:     FAIL (fdo#103191, fdo#107362) -> PASS

    
    ==== Warnings ====

    igt@drv_selftest@live_contexts:
      fi-icl-u:           INCOMPLETE (fdo#108315) -> DMESG-FAIL (fdo#108569)

fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#107164 https://bugs.freedesktop.org/show_bug.cgi?id=107164
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107724 https://bugs.freedesktop.org/show_bug.cgi?id=107724
fdo#108315 https://bugs.freedesktop.org/show_bug.cgi?id=108315
fdo#108569 https://bugs.freedesktop.org/show_bug.cgi?id=108569
fdo#108680 https://bugs.freedesktop.org/show_bug.cgi?id=108680

== Participating hosts (55 -> 47) ==

Missing (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-snb-2520m fi-ctg-p8600 fi-bdw-samus

== Build changes ==

* Linux: CI_DRM_5106 -> Patchwork_10779

CI_DRM_5106: 852b9329fbb6ea8bdbb3dac78328aae73d919305 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4713: 3acf5c5b74ebf89c8b389b19d59f12c409e1dc52 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10779: 82ce6dbb8ed8e7622c0657f0cc4eca35ef71cbbc @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

82ce6dbb8ed8 drm/i915: Fix hpd handling for pins with two encoders

== Logs ==

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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Ville Syrjala

lgtm

Quoted 133 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

In my haste to remove irq_port[] I accidentally changed the way we deal with hpd pins that are shared by multiple encoders (DP and HDMI for pre-DDI platforms). Previously we would only handle such pins via ->hpd_pulse(), but now we queue up the hotplug work for the HDMI encoder directly. Worse yet, we now count each hpd twice and this increment the hpd storm count twice as fast. This can lead to spurious storms being detected.

Go back to the old way of doing things, ie. delegate to ->hpd_pulse() for any pin which has an encoder with that hook implemented. I don't really like the idea of adding irq_port[] back so let's loop through the encoders first to check if we have an encoder with ->hpd_pulse() for the pin, and then go through all the pins and decided on the correct course of action based on the earlier findings.

I have occasionally toyed with the idea of unifying the pre-DDI HDMI and DP encoders into a single encoder as well. Besides the hotplug processing it would have the other benefit of preventing userspace from trying to enable both encoders at the same time. That is simply illegal as they share the same clock/data pins. We have some testcases that will attempt that and thus fail on many older machines. But for now let's stick to fixing just the hotplug code.

Cc Lyude Paul <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes b6ca3eee18ba ("drm/i915: Nuke dev_priv->irq_port[]")
---
 drivers/gpu/drm/i915/intel_hotplug.c | 55 +++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_hotplug.c +42 -13
index 42e61e10f517..e24174d08fed 100644
@@ -414,33 +414,54 @@ void intel_hpd_irq_handler(struct drm_i915_private
 *dev_priv,
 	struct intel_encoder *encoder;
 	bool storm_detected = false;
 	bool queue_dig = false, queue_hp = false;
+	u32 long_hpd_pulse_mask = 0;
+	u32 short_hpd_pulse_mask = 0;
+	enum hpd_pin pin;
 
 	if (!pin_mask)
 		return;
 
 	spin_lock(&dev_priv->irq_lock);
+
+	/*
+	 * Determine whether ->hpd_pulse() exists for each pin, and
+	 * whether we have a short or a long pulse. This is needed
+	 * as each pin may have up to two encoders (HDMI and DP) and
+	 * only the one of them (DP) will have ->hpd_pulse().
+	 */
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
-		enum hpd_pin pin = encoder->hpd_pin;
 		bool has_hpd_pulse = intel_encoder_has_hpd_pulse(encoder);
-		bool long_hpd = true;
+		enum port port = encoder->port;
+		bool long_hpd;
 
+		pin = encoder->hpd_pin;
 		if (!(BIT(pin) & pin_mask))
 			continue;
 
-		if (has_hpd_pulse) {
-			enum port port = encoder->port;
+		if (!has_hpd_pulse)
+			continue;
 
-			long_hpd = long_mask & BIT(pin);
+		long_hpd = long_mask & BIT(pin);
 
-			DRM_DEBUG_DRIVER("digital hpd port %c - %s\n",
 port_name(port),
-					 long_hpd ? "long" : "short");
-			queue_dig = true;
-			if (long_hpd)
-				dev_priv->hotplug.long_port_mask |= (1 <<
 port);
-			else
-				dev_priv->hotplug.short_port_mask |= (1 <<
 port);
+		DRM_DEBUG_DRIVER("digital hpd port %c - %s\n",
 port_name(port),
+				 long_hpd ? "long" : "short");
+		queue_dig = true;
 
+		if (long_hpd) {
+			long_hpd_pulse_mask |= BIT(pin);
+			dev_priv->hotplug.long_port_mask |= BIT(port);
+		} else {
+			short_hpd_pulse_mask |= BIT(pin);
+			dev_priv->hotplug.short_port_mask |= BIT(port);
 		}
+	}
+
+	/* Now process each pin just once */
+	for_each_hpd_pin(pin) {
+		bool long_hpd;
+
+		if (!(BIT(pin) & pin_mask))
+			continue;
 
 		if (dev_priv->hotplug.stats[pin].state == HPD_DISABLED) {
 			/*
@@ -457,8 +478,16 @@ void intel_hpd_irq_handler(struct drm_i915_private
 *dev_priv,
 		if (dev_priv->hotplug.stats[pin].state != HPD_ENABLED)
 			continue;
 
-		if (!has_hpd_pulse) {
+		/*
+		 * Delegate to ->hpd_pulse() if one of the encoders for this
+		 * pin has it, otherwise let the hotplug_work deal with this
+		 * pin directly.
+		 */
+		if (((short_hpd_pulse_mask | long_hpd_pulse_mask) & BIT(pin)))
 {
+			long_hpd = long_hpd_pulse_mask & BIT(pin);
+		} else {
 			dev_priv->hotplug.event_bits |= BIT(pin);
+			long_hpd = true;
 			queue_hp = true;

}

Signature · 7 lines
Cheers,
	Lyude Paul

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

✓ Fi.CI.IGT: success for drm/i915: Fix hpd handling for pins with two encoders

In reply to Ville Syrjala
== Series Details ==

== Series Details ==

Series: drm/i915: Fix hpd handling for pins with two encoders
URL : https://patchwork.freedesktop.org/series/52256/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_5106_full -> Patchwork_10779_full =

== Summary - WARNING ==

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

If you think the reported changes have nothing to do with the changes introduced in Patchwork_10779_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_10779_full:

=== IGT changes ===

    ==== Warnings ====

    igt@pm_rc6_residency@rc6-accuracy:
      shard-snb:          PASS -> SKIP

    igt@tools_test@sysfs_l3_parity:
      shard-hsw:          PASS -> SKIP

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@drm_import_export@import-close-race-flink:
      shard-skl:          NOTRUN -> TIMEOUT (fdo#108667)

    igt@gem_exec_schedule@pi-ringfull-render:
      shard-glk:          NOTRUN -> FAIL (fdo#103158)

    igt@gem_exec_schedule@preempt-other-bsd:
      shard-apl:          PASS -> DMESG-WARN (fdo#103558, fdo#105602) +1

    igt@gem_userptr_blits@readonly-unsync:
      shard-skl:          NOTRUN -> INCOMPLETE (fdo#108074)

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-glk:          NOTRUN -> FAIL (fdo#106641)

    igt@kms_busy@extended-modeset-hang-newfb-render-b:
      shard-skl:          NOTRUN -> DMESG-WARN (fdo#107956)

    igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-c:
      shard-glk:          NOTRUN -> DMESG-WARN (fdo#107956) +3

    igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
      shard-apl:          NOTRUN -> FAIL (fdo#105458, fdo#106510)

    igt@kms_cursor_crc@cursor-128x128-sliding:
      shard-glk:          PASS -> FAIL (fdo#103232)

    igt@kms_cursor_crc@cursor-128x128-suspend:
      shard-apl:          PASS -> FAIL (fdo#103232, fdo#103191) +1

    igt@kms_cursor_crc@cursor-128x42-random:
      shard-glk:          NOTRUN -> FAIL (fdo#103232)

    igt@kms_cursor_crc@cursor-64x21-random:
      shard-apl:          PASS -> FAIL (fdo#103232) +2

    igt@kms_cursor_crc@cursor-64x64-suspend:
      shard-skl:          NOTRUN -> INCOMPLETE (fdo#104108)

    igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
      shard-hsw:          PASS -> FAIL (fdo#105767)

    igt@kms_fbcon_fbt@psr-suspend:
      shard-skl:          NOTRUN -> FAIL (fdo#107882)

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

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite:
      shard-apl:          PASS -> FAIL (fdo#103167) +1
      shard-glk:          PASS -> FAIL (fdo#103167)

    igt@kms_frontbuffer_tracking@fbc-1p-rte:
      shard-glk:          PASS -> FAIL (fdo#105682, fdo#103167)
      shard-apl:          PASS -> FAIL (fdo#105682, fdo#103167)

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-wc:
      shard-glk:          NOTRUN -> FAIL (fdo#103167) +1

    igt@kms_frontbuffer_tracking@fbcpsr-stridechange:
      shard-skl:          NOTRUN -> FAIL (fdo#105683)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      shard-skl:          PASS -> FAIL (fdo#107362, fdo#103191)

    igt@kms_plane@pixel-format-pipe-c-planes:
      shard-apl:          PASS -> FAIL (fdo#103166) +1
      shard-skl:          NOTRUN -> DMESG-WARN (fdo#106885)

    igt@kms_plane@plane-position-covered-pipe-b-planes:
      shard-glk:          NOTRUN -> FAIL (fdo#103166) +1

    igt@kms_plane@plane-position-covered-pipe-c-planes:
      shard-glk:          PASS -> FAIL (fdo#103166)

    igt@kms_plane_alpha_blend@pipe-c-alpha-transparant-fb:
      shard-glk:          NOTRUN -> FAIL (fdo#108145) +2
      shard-kbl:          NOTRUN -> FAIL (fdo#108145)
      shard-skl:          NOTRUN -> FAIL (fdo#108145) +3

    igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
      shard-skl:          NOTRUN -> FAIL (fdo#103166, fdo#107815)
      shard-kbl:          NOTRUN -> FAIL (fdo#103166)

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

    igt@pm_rpm@gem-execbuf-stress-extra-wait:
      shard-skl:          PASS -> INCOMPLETE (fdo#107803, fdo#107807)

    igt@pm_rpm@gem-pread:
      shard-skl:          NOTRUN -> INCOMPLETE (fdo#107807)

    
    ==== Possible fixes ====

    igt@kms_color@pipe-a-legacy-gamma:
      shard-apl:          FAIL (fdo#104782, fdo#108145) -> PASS

    igt@kms_cursor_crc@cursor-128x128-random:
      shard-apl:          FAIL (fdo#103232) -> PASS +1

    igt@kms_cursor_crc@cursor-64x64-suspend:
      shard-glk:          FAIL (fdo#103232) -> PASS

    igt@kms_cursor_legacy@2x-long-nonblocking-modeset-vs-cursor-atomic:
      shard-glk:          FAIL (fdo#106509, fdo#107409) -> PASS

    igt@kms_plane@plane-position-covered-pipe-c-planes:
      shard-apl:          FAIL (fdo#103166) -> PASS +1

    igt@kms_plane_multiple@atomic-pipe-c-tiling-x:
      shard-glk:          FAIL (fdo#103166) -> PASS

fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#103232 https://bugs.freedesktop.org/show_bug.cgi?id=103232
fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
fdo#104782 https://bugs.freedesktop.org/show_bug.cgi?id=104782
fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#105458 https://bugs.freedesktop.org/show_bug.cgi?id=105458
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#105682 https://bugs.freedesktop.org/show_bug.cgi?id=105682
fdo#105683 https://bugs.freedesktop.org/show_bug.cgi?id=105683
fdo#105767 https://bugs.freedesktop.org/show_bug.cgi?id=105767
fdo#106509 https://bugs.freedesktop.org/show_bug.cgi?id=106509
fdo#106510 https://bugs.freedesktop.org/show_bug.cgi?id=106510
fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
fdo#106885 https://bugs.freedesktop.org/show_bug.cgi?id=106885
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107409 https://bugs.freedesktop.org/show_bug.cgi?id=107409
fdo#107803 https://bugs.freedesktop.org/show_bug.cgi?id=107803
fdo#107807 https://bugs.freedesktop.org/show_bug.cgi?id=107807
fdo#107815 https://bugs.freedesktop.org/show_bug.cgi?id=107815
fdo#107882 https://bugs.freedesktop.org/show_bug.cgi?id=107882
fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
fdo#108074 https://bugs.freedesktop.org/show_bug.cgi?id=108074
fdo#108145 https://bugs.freedesktop.org/show_bug.cgi?id=108145
fdo#108667 https://bugs.freedesktop.org/show_bug.cgi?id=108667
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912

== Participating hosts (6 -> 6) ==

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_5106 -> Patchwork_10779

CI_DRM_5106: 852b9329fbb6ea8bdbb3dac78328aae73d919305 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4713: 3acf5c5b74ebf89c8b389b19d59f12c409e1dc52 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10779: 82ce6dbb8ed8e7622c0657f0cc4eca35ef71cbbc @ 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_10779/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
In reply to Lyude Paul
Quoted 3 lines · Lyude Paul

lgtm

Thanks. Pushed to dinq.

Quoted 138 lines · Ville Syrjala
Quoted 133 lines

From: Ville Syrjälä <[email protected]>

In my haste to remove irq_port[] I accidentally changed the way we deal with hpd pins that are shared by multiple encoders (DP and HDMI for pre-DDI platforms). Previously we would only handle such pins via ->hpd_pulse(), but now we queue up the hotplug work for the HDMI encoder directly. Worse yet, we now count each hpd twice and this increment the hpd storm count twice as fast. This can lead to spurious storms being detected.

Go back to the old way of doing things, ie. delegate to ->hpd_pulse() for any pin which has an encoder with that hook implemented. I don't really like the idea of adding irq_port[] back so let's loop through the encoders first to check if we have an encoder with ->hpd_pulse() for the pin, and then go through all the pins and decided on the correct course of action based on the earlier findings.

I have occasionally toyed with the idea of unifying the pre-DDI HDMI and DP encoders into a single encoder as well. Besides the hotplug processing it would have the other benefit of preventing userspace from trying to enable both encoders at the same time. That is simply illegal as they share the same clock/data pins. We have some testcases that will attempt that and thus fail on many older machines. But for now let's stick to fixing just the hotplug code.

Cc Lyude Paul <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes b6ca3eee18ba ("drm/i915: Nuke dev_priv->irq_port[]")
---
 drivers/gpu/drm/i915/intel_hotplug.c | 55 +++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_hotplug.c +42 -13
index 42e61e10f517..e24174d08fed 100644
@@ -414,33 +414,54 @@ void intel_hpd_irq_handler(struct drm_i915_private
 *dev_priv,
 	struct intel_encoder *encoder;
 	bool storm_detected = false;
 	bool queue_dig = false, queue_hp = false;
+	u32 long_hpd_pulse_mask = 0;
+	u32 short_hpd_pulse_mask = 0;
+	enum hpd_pin pin;
 
 	if (!pin_mask)
 		return;
 
 	spin_lock(&dev_priv->irq_lock);
+
+	/*
+	 * Determine whether ->hpd_pulse() exists for each pin, and
+	 * whether we have a short or a long pulse. This is needed
+	 * as each pin may have up to two encoders (HDMI and DP) and
+	 * only the one of them (DP) will have ->hpd_pulse().
+	 */
 	for_each_intel_encoder(&dev_priv->drm, encoder) {
-		enum hpd_pin pin = encoder->hpd_pin;
 		bool has_hpd_pulse = intel_encoder_has_hpd_pulse(encoder);
-		bool long_hpd = true;
+		enum port port = encoder->port;
+		bool long_hpd;
 
+		pin = encoder->hpd_pin;
 		if (!(BIT(pin) & pin_mask))
 			continue;
 
-		if (has_hpd_pulse) {
-			enum port port = encoder->port;
+		if (!has_hpd_pulse)
+			continue;
 
-			long_hpd = long_mask & BIT(pin);
+		long_hpd = long_mask & BIT(pin);
 
-			DRM_DEBUG_DRIVER("digital hpd port %c - %s\n",
 port_name(port),
-					 long_hpd ? "long" : "short");
-			queue_dig = true;
-			if (long_hpd)
-				dev_priv->hotplug.long_port_mask |= (1 <<
 port);
-			else
-				dev_priv->hotplug.short_port_mask |= (1 <<
 port);
+		DRM_DEBUG_DRIVER("digital hpd port %c - %s\n",
 port_name(port),
+				 long_hpd ? "long" : "short");
+		queue_dig = true;
 
+		if (long_hpd) {
+			long_hpd_pulse_mask |= BIT(pin);
+			dev_priv->hotplug.long_port_mask |= BIT(port);
+		} else {
+			short_hpd_pulse_mask |= BIT(pin);
+			dev_priv->hotplug.short_port_mask |= BIT(port);
 		}
+	}
+
+	/* Now process each pin just once */
+	for_each_hpd_pin(pin) {
+		bool long_hpd;
+
+		if (!(BIT(pin) & pin_mask))
+			continue;
 
 		if (dev_priv->hotplug.stats[pin].state == HPD_DISABLED) {
 			/*
@@ -457,8 +478,16 @@ void intel_hpd_irq_handler(struct drm_i915_private
 *dev_priv,
 		if (dev_priv->hotplug.stats[pin].state != HPD_ENABLED)
 			continue;
 
-		if (!has_hpd_pulse) {
+		/*
+		 * Delegate to ->hpd_pulse() if one of the encoders for this
+		 * pin has it, otherwise let the hotplug_work deal with this
+		 * pin directly.
+		 */
+		if (((short_hpd_pulse_mask | long_hpd_pulse_mask) & BIT(pin)))
 {
+			long_hpd = long_hpd_pulse_mask & BIT(pin);
+		} else {
 			dev_priv->hotplug.event_bits |= BIT(pin);
+			long_hpd = true;
 			queue_hp = true;

}

Signature · 2 lines
Cheers,
	Lyude Paul
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx