[PATCH] Give up on edid retries when i2c bus is not responding

Eugeni Dodonov eugeni.dodonov at intel.com
Wed Oct 26 10:35:36 PDT 2011

This allows to avoid talking to a non-responding bus repeatedly until we
finally timeout after 15 attempts. We can do this by catching the -ENXIO
error, provided by i2c_algo_bit:bit_doAddress call.

Within the bit_doAddress we already try 3 times to get the edid data, so
if the routine tells us that bus is not responding, it is mostly pointless
to keep re-trying those attempts over and over again until we reach final
number of retries.

This change should fix
https://bugs.freedesktop.org/show_bug.cgi?id=41059 and improve overall
edid detection timing by 10-30% in most cases, and by a much larger margin
in case of phantom outputs.

Timing results for i915-powered machines for 'time xrandr' command:
Machine 1: from 0.840s to 0.290s
Machine 2: from 0.315s to 0.280s
Machine 3: from +/- 1s to 0.184s

Timing results for HD5770 with 'time xrandr' command:
Machine 4: from 3.210s to 1.060s

v2: added a module parameter to control this behavior. The idea came from
discussion with Jean Delvare.

v3: added external tested-by's and timing results.

v4: changed module parameter to bool, added default value description

Signed-off-by: Eugeni Dodonov <eugeni.dodonov at intel.com>
Reviewed-By: Chris Wilson <chris at chris-wilson.co.uk>
Tested-By: Sean Finney <seanius at seanius.net>
Tested-By: Soren Hansen <soren at linux2go.dk>
Tested-By: Hernando Torque <sirius at sonnenkinder.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41059
 drivers/gpu/drm/drm_edid.c |    5 +++++
 drivers/gpu/drm/drm_stub.c |    5 +++++
 include/drm/drmP.h         |    2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 7425e5c..c7426ab 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -265,6 +265,11 @@ drm_do_probe_ddc_edid(struct i2c_adapter *adapter, unsigned char *buf,
 		ret = i2c_transfer(adapter, msgs, 2);
+		if (drm_ignore_unresponsive_edid && ret == -ENXIO) {
+			DRM_DEBUG_KMS("drm: skipping non-existent adapter %s\n",
+					adapter->name);
+			break;
+		}
 	} while (ret != 2 && --retries);
 	return ret == 2 ? 0 : -1;
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 6d7b083..dea0fcd 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -46,16 +46,21 @@ EXPORT_SYMBOL(drm_vblank_offdelay);
 unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
+unsigned int drm_ignore_unresponsive_edid = 1;  /* Ignore non-responding edid by default */
 MODULE_LICENSE("GPL and additional rights");
 MODULE_PARM_DESC(debug, "Enable debug output");
 MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs]");
 MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]");
+MODULE_PARM_DESC(ignore_unresponsive_edid, "Automatically ignore outputs which do not provide EDID after 3 attempts (default: true)");
 module_param_named(debug, drm_debug, int, 0600);
 module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600);
 module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600);
+module_param_named(ignore_unresponsive_edid, drm_ignore_unresponsive_edid, bool, 0600);
 struct idr drm_minors_idr;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 9b7c2bb..d7b0286 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1465,6 +1465,8 @@ extern unsigned int drm_debug;
 extern unsigned int drm_vblank_offdelay;
 extern unsigned int drm_timestamp_precision;
+extern unsigned int drm_ignore_unresponsive_edid;
 extern struct class *drm_class;
 extern struct proc_dir_entry *drm_proc_root;
 extern struct dentry *drm_debugfs_root;

More information about the dri-devel mailing list