@@ -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;
}
@@ -1008,33 +1008,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);
@@ -1088,7 +1061,8 @@ static void queue_work_for_missed_irqs(struct drm_i915_private *i915)
* userspace connector probing, or DRM core's connector polling.
*
* A nested call of this function on the same encoder is not allowed. The call
- * must be followed by calling intel_hpd_resume().
+ * 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.
@@ -1148,6 +1122,35 @@ 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);
+ 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);
@@ -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);
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. 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 | 59 ++++++++++---------- drivers/gpu/drm/i915/display/intel_hotplug.h | 3 +- 3 files changed, 34 insertions(+), 35 deletions(-)