All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: [PATCH v2 5/5] drm/i915/crt: Use intel_hpd_suspend/resume() instead of intel_hpd_disable/enable()
Date: Tue, 25 Feb 2025 14:15:36 +0200	[thread overview]
Message-ID: <20250225121536.2152940-2-imre.deak@intel.com> (raw)
In-Reply-To: <20250224193115.2058512-6-imre.deak@intel.com>

intel_hpd_disable/enable() have the same purpose as
intel_hpd_suspend/resume(), except that disable/enable will drop any HPD
IRQs which were triggered while the HPD was disabled, while
suspend/resume will handle such IRQs after the IRQ handling is resumed.
Use intel_hpd_suspend/resume() for crt as well, by adding a helper to
explicitly clear any pending IRQs before resuming.

v2:
- Handle encoders without a port assigned to them.
- Rebase on change in intel_hpd_suspend() documentation.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/display/intel_crt.c     |  7 +--
 drivers/gpu/drm/i915/display/intel_hotplug.c | 63 +++++++++++---------
 drivers/gpu/drm/i915/display/intel_hotplug.h |  3 +-
 3 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_crt.c b/drivers/gpu/drm/i915/display/intel_crt.c
index 321580b095e7d..67b6731d7cdd2 100644
--- a/drivers/gpu/drm/i915/display/intel_crt.c
+++ b/drivers/gpu/drm/i915/display/intel_crt.c
@@ -531,8 +531,6 @@ static bool valleyview_crt_detect_hotplug(struct drm_connector *connector)
 {
 	struct intel_display *display = to_intel_display(connector->dev);
 	struct intel_crt *crt = intel_attached_crt(to_intel_connector(connector));
-	struct drm_i915_private *dev_priv = to_i915(connector->dev);
-	bool reenable_hpd;
 	u32 adpa;
 	bool ret;
 	u32 save_adpa;
@@ -549,7 +547,7 @@ static bool valleyview_crt_detect_hotplug(struct drm_connector *connector)
 	 *
 	 * Just disable HPD interrupts here to prevent this
 	 */
-	reenable_hpd = intel_hpd_disable(dev_priv, crt->base.hpd_pin);
+	intel_hpd_suspend(&crt->base);
 
 	save_adpa = adpa = intel_de_read(display, crt->adpa_reg);
 	drm_dbg_kms(display->drm,
@@ -576,8 +574,7 @@ static bool valleyview_crt_detect_hotplug(struct drm_connector *connector)
 	drm_dbg_kms(display->drm,
 		    "valleyview hotplug adpa=0x%x, result %d\n", adpa, ret);
 
-	if (reenable_hpd)
-		intel_hpd_enable(dev_priv, crt->base.hpd_pin);
+	intel_hpd_clear_and_resume(&crt->base);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
index 85c56b8add8b0..4428a4dec5e20 100644
--- a/drivers/gpu/drm/i915/display/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
@@ -1006,33 +1006,6 @@ void intel_hpd_cancel_work(struct drm_i915_private *dev_priv)
 		drm_dbg_kms(&dev_priv->drm, "Hotplug detection work still active\n");
 }
 
-bool intel_hpd_disable(struct drm_i915_private *dev_priv, enum hpd_pin pin)
-{
-	bool ret = false;
-
-	if (pin == HPD_NONE)
-		return false;
-
-	spin_lock_irq(&dev_priv->irq_lock);
-	if (dev_priv->display.hotplug.stats[pin].state == HPD_ENABLED) {
-		dev_priv->display.hotplug.stats[pin].state = HPD_DISABLED;
-		ret = true;
-	}
-	spin_unlock_irq(&dev_priv->irq_lock);
-
-	return ret;
-}
-
-void intel_hpd_enable(struct drm_i915_private *dev_priv, enum hpd_pin pin)
-{
-	if (pin == HPD_NONE)
-		return;
-
-	spin_lock_irq(&dev_priv->irq_lock);
-	dev_priv->display.hotplug.stats[pin].state = HPD_ENABLED;
-	spin_unlock_irq(&dev_priv->irq_lock);
-}
-
 static void queue_work_for_missed_irqs(struct drm_i915_private *i915)
 {
 	struct intel_display *display = to_intel_display(&i915->drm);
@@ -1085,7 +1058,8 @@ static void queue_work_for_missed_irqs(struct drm_i915_private *i915)
  *   drm_connector_funcs::detect()) remains allowed, for instance as part of
  *   userspace connector probing, or DRM core's connector polling.
  *
- * The call must be followed by calling intel_hpd_resume().
+ * The call must be followed by calling intel_hpd_resume(), or
+ * intel_hpd_clear_and_resume().
  *
  * Note that the handling of HPD IRQs for another encoder using the same HPD
  * pin as that of @encoder will be also suspended.
@@ -1151,6 +1125,39 @@ void intel_hpd_resume(struct intel_encoder *encoder)
 	spin_unlock_irq(&i915->irq_lock);
 }
 
+/**
+ * intel_hpd_clear_and_resume - Resume handling of new HPD IRQs on an HPD pin
+ * @encoder: Encoder to resume the HPD handling for
+ *
+ * Resume the handling of HPD IRQs on the HPD pin of @encoder, which was
+ * previously suspended by intel_hpd_suspend(). Any HPD IRQ raised on the
+ * HPD pin while it was suspended will be cleared, handling only new IRQs.
+ */
+void intel_hpd_clear_and_resume(struct intel_encoder *encoder)
+{
+	struct intel_display *display = to_intel_display(encoder);
+	struct drm_i915_private *i915 = to_i915(display->drm);
+	struct intel_hotplug *hotplug = &display->hotplug;
+
+	if (encoder->hpd_pin == HPD_NONE)
+		return;
+
+	spin_lock_irq(&i915->irq_lock);
+
+	hotplug->event_bits &= ~BIT(encoder->hpd_pin);
+	hotplug->retry_bits &= ~BIT(encoder->hpd_pin);
+
+	if (intel_encoder_has_hpd_pulse(encoder)) {
+		drm_WARN_ON(display->drm, encoder->port == PORT_NONE);
+		hotplug->short_port_mask &= ~BIT(encoder->port);
+		hotplug->long_port_mask &= ~BIT(encoder->port);
+	}
+
+	resume_hpd(encoder);
+
+	spin_unlock_irq(&i915->irq_lock);
+}
+
 void intel_hpd_enable_detection_work(struct drm_i915_private *i915)
 {
 	spin_lock_irq(&i915->irq_lock);
diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.h b/drivers/gpu/drm/i915/display/intel_hotplug.h
index 5180731def7cc..0a4d1af0e42f1 100644
--- a/drivers/gpu/drm/i915/display/intel_hotplug.h
+++ b/drivers/gpu/drm/i915/display/intel_hotplug.h
@@ -26,10 +26,9 @@ void intel_hpd_init(struct drm_i915_private *dev_priv);
 void intel_hpd_init_early(struct drm_i915_private *i915);
 void intel_hpd_cancel_work(struct drm_i915_private *dev_priv);
 enum hpd_pin intel_hpd_pin_default(enum port port);
-bool intel_hpd_disable(struct drm_i915_private *dev_priv, enum hpd_pin pin);
-void intel_hpd_enable(struct drm_i915_private *dev_priv, enum hpd_pin pin);
 void intel_hpd_suspend(struct intel_encoder *encoder);
 void intel_hpd_resume(struct intel_encoder *encoder);
+void intel_hpd_clear_and_resume(struct intel_encoder *encoder);
 void intel_hpd_debugfs_register(struct drm_i915_private *i915);
 
 void intel_hpd_enable_detection_work(struct drm_i915_private *i915);
-- 
2.44.2


  reply	other threads:[~2025-02-25 12:14 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 19:31 [PATCH 0/5] drm/dp: Fix link training interrupted by HPD pulse Imre Deak
2025-02-24 19:31 ` [PATCH 1/5] drm/i915/hpd: Let an HPD pin be in the disabled state when handling missed IRQs Imre Deak
2025-02-24 19:31 ` [PATCH 2/5] drm/i915/hpd: Add support for suspending the IRQ handling on an HPD pin Imre Deak
2025-02-25 12:15   ` [PATCH v2 " Imre Deak
2025-02-25 16:25     ` Jani Nikula
2025-02-25 17:15       ` Imre Deak
2025-02-24 19:31 ` [PATCH 3/5] drm/i915/dp: Fix link training interrupted by a short HPD pulse Imre Deak
2025-02-24 19:31 ` [PATCH 4/5] drm/i915/dp: Queue a link check after link training is complete Imre Deak
2025-02-24 19:31 ` [PATCH 5/5] drm/i915/crt: Use intel_hpd_suspend/resume() instead of intel_hpd_disable/enable() Imre Deak
2025-02-25 12:15   ` Imre Deak [this message]
2025-02-25  1:32 ` ✗ Fi.CI.SPARSE: warning for drm/dp: Fix link training interrupted by HPD pulse Patchwork
2025-02-25  1:54 ` ✓ CI.Patch_applied: success " Patchwork
2025-02-25  1:54 ` ✓ CI.checkpatch: " Patchwork
2025-02-25  1:56 ` ✓ CI.KUnit: " Patchwork
2025-02-25  2:00 ` ✗ i915.CI.BAT: failure " Patchwork
2025-02-25  2:12 ` ✓ CI.Build: success " Patchwork
2025-02-25  2:14 ` ✓ CI.Hooks: " Patchwork
2025-02-25  2:16 ` ✗ CI.checksparse: warning " Patchwork
2025-02-25  2:35 ` ✓ Xe.CI.BAT: success " Patchwork
2025-02-25  6:13 ` ✗ Xe.CI.Full: failure " Patchwork
2025-02-25 12:20 ` ✓ CI.Patch_applied: success for drm/dp: Fix link training interrupted by HPD pulse (rev3) Patchwork
2025-02-25 12:20 ` ✓ CI.checkpatch: " Patchwork
2025-02-25 12:21 ` ✓ CI.KUnit: " Patchwork
2025-02-25 12:38 ` ✓ CI.Build: " Patchwork
2025-02-25 12:40 ` ✓ CI.Hooks: " Patchwork
2025-02-25 12:42 ` ✗ CI.checksparse: warning " Patchwork
2025-02-25 12:59 ` ✓ Xe.CI.BAT: success " Patchwork
2025-02-25 13:23 ` ✗ Fi.CI.SPARSE: warning " Patchwork
2025-02-25 13:41 ` ✗ i915.CI.BAT: failure " Patchwork
2025-02-25 14:25   ` Imre Deak
2025-02-26  4:09     ` Ravali, JupallyX
2025-02-25 19:15 ` ✗ Xe.CI.Full: " Patchwork
2025-02-26  3:51 ` ✓ i915.CI.BAT: success " Patchwork
2025-02-26  5:33 ` ✗ i915.CI.Full: failure " Patchwork
2025-02-26 12:55 ` [PATCH 0/5] drm/dp: Fix link training interrupted by HPD pulse Jani Nikula
2025-02-26 13:17   ` 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=20250225121536.2152940-2-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@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.