[PATCH] drm/i915: Fix the HDMI hot plug disconnection failure (v6-test)

Guang Bai guang.bai at intel.com
Tue Nov 27 10:37:29 UTC 2018


On some platforms, slowly unplugging (wiggling) the HDMI cable makes
the kernel to believe the HDMI display still connected. This is because
the HDMI DDC lines are disconnected sometimes later after the hot-plug
interrupt triggered. Use the hot plug live states to honor HDMI hot plug
status in addtion to access the DDC channels.

v2: Fix the formatting issue
v3: Use connector type to apply changes to HDMI port only (James & Matt)
v4: Added debug info for testing
v5: Try local hot-plug call for debugging purpose
v6-test: fail edid fetch when hdmi disconnected in the midst of hot-plug
to make sure connector state engine updated accordingly

Cc: Jani Nikula <jani.nikula at intel.com>
Cc: Chris Chiu <chiu at endlessm.com>
Signed-off-by: Guang Bai <guang.bai at intel.com>
---
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 drivers/gpu/drm/i915/intel_hdmi.c    | 17 ++++++++++--
 drivers/gpu/drm/i915/intel_hotplug.c | 53 +++++++++++++++++++++++++++++++++++-
 3 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index a62d77b..4f01ff2 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1874,6 +1874,7 @@ void intel_dvo_init(struct drm_i915_private *dev_priv);
 void intel_hpd_poll_init(struct drm_i915_private *dev_priv);
 bool intel_encoder_hotplug(struct intel_encoder *encoder,
 			   struct intel_connector *connector);
+bool intel_hpd_hdmi_connect(struct drm_connector *connector);
 
 /* legacy fbdev emulation in intel_fbdev.c */
 #ifdef CONFIG_DRM_FBDEV_EMULATION
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index e2c6a2b..1c7ec4a 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1882,14 +1882,25 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 	struct edid *edid;
 	bool connected = false;
 	struct i2c_adapter *i2c;
+	bool hdmi_hpd_connect = true;
 
 	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
 
 	i2c = intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
+	/*
+	 * There is a phantom successful edid read even after hdmi cable
+	 * unplugged in the midst of hmdi hot-plug process which leads to
+	 * incorrect hdmi connection status. Bypass the edid fetch when
+	 * hdmi cable confirmed unplugged.
+	 */
+	if (intel_hpd_hdmi_connect(connector)) {
+		edid = drm_get_edid(connector, i2c);
+	} else {
+		edid = NULL;
+		hdmi_hpd_connect = false;
+	}
 
-	edid = drm_get_edid(connector, i2c);
-
-	if (!edid && !intel_gmbus_is_forced_bit(i2c)) {
+	if (!edid && hdmi_hpd_connect && !intel_gmbus_is_forced_bit(i2c)) {
 		DRM_DEBUG_KMS("HDMI GMBUS EDID read failed, retry using GPIO bit-banging\n");
 		intel_gmbus_force_bit(i2c, true);
 		edid = drm_get_edid(connector, i2c);
diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c
index e24174d..e611a45 100644
--- a/drivers/gpu/drm/i915/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/intel_hotplug.c
@@ -265,6 +265,58 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work)
 	intel_runtime_pm_put(dev_priv);
 }
 
+#define MAX_SHORT_PULSE_MS	100
+#define PORT_CHECK_LOOP_COUNT	3
+
+bool intel_hpd_encoder_state(struct intel_encoder *encoder,
+			     struct intel_connector *connector)
+{
+	struct drm_device *dev = connector->base.dev;
+	enum drm_connector_status old_status, new_status;
+	int connector_type = connector->base.connector_type;
+	u32 count = 0;
+
+	WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
+	old_status = connector->base.status;
+	/*
+	 * Set HDMI connection status based on hot-plug live states and
+	 * display probe results.
+	 */
+	if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+	    connector_type == DRM_MODE_CONNECTOR_HDMIB) {
+		do {
+			new_status = connector_status_disconnected;
+			msleep(MAX_SHORT_PULSE_MS);
+
+			if (intel_digital_port_connected(encoder))
+				new_status = drm_helper_probe_detect(&connector->base,
+								     NULL, false);
+			if (new_status == connector_status_connected)
+				break;
+		} while (++count <= PORT_CHECK_LOOP_COUNT);
+		connector->base.status = new_status;
+	} else {
+		connector->base.status =
+			drm_helper_probe_detect(&connector->base, NULL, false);
+	}
+
+	if (old_status == connector->base.status)
+		return false;
+
+	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n",
+		      connector->base.base.id,
+		      connector->base.name,
+		      drm_get_connector_status_name(old_status),
+		      drm_get_connector_status_name(connector->base.status));
+
+	return true;
+}
+
+bool intel_hpd_hdmi_connect(struct drm_connector *connector)
+{
+	return true;
+}
+
 bool intel_encoder_hotplug(struct intel_encoder *encoder,
 			   struct intel_connector *connector)
 {
@@ -379,7 +431,6 @@ static void i915_hotplug_work_func(struct work_struct *work)
 		if (hpd_event_bits & (1 << intel_encoder->hpd_pin)) {
 			DRM_DEBUG_KMS("Connector %s (pin %i) received hotplug event.\n",
 				      connector->name, intel_encoder->hpd_pin);
-
 			changed |= intel_encoder->hotplug(intel_encoder,
 							  intel_connector);
 		}
-- 
2.7.4



More information about the Intel-gfx-trybot mailing list