dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Eugeni Dodonov <eugeni.dodonov@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, alexdeucher@gmail.com,
	mb@bu3sch.de, khali@linux-fr.org,
	Eugeni Dodonov <eugeni.dodonov@intel.com>
Subject: [PATCH] Give up on edid retries when i2c bus is not responding
Date: Wed, 26 Oct 2011 15:06:24 -0200	[thread overview]
Message-ID: <1319648784-2402-1-git-send-email-eugeni.dodonov@intel.com> (raw)
In-Reply-To: <1319547788-8812-1-git-send-email-eugeni.dodonov@intel.com>

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.

Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Tested-By: Sean Finney <seanius@seanius.net>
Tested-By: Soren Hansen <soren@linux2go.dk>
Tested-By: Hernando Torque <sirius@sonnenkinder.org>
---
 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..b1013fe 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. */
 EXPORT_SYMBOL(drm_timestamp_precision);
 
+unsigned int drm_ignore_unresponsive_edid = 1;  /* Ignore non-responding edid by default */
+EXPORT_SYMBOL(drm_ignore_unresponsive_edid);
+
 MODULE_AUTHOR(CORE_AUTHOR);
 MODULE_DESCRIPTION(CORE_DESC);
 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");
 
 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, int, 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;
-- 
1.7.7.1

  reply	other threads:[~2011-10-26 17:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17 13:12 [PATCH] Improvements in edid detection timings (final) Eugeni Dodonov
2011-10-17 13:12 ` [PATCH 1/2] Give up on edid retries when i2c tells us that bus is not there Eugeni Dodonov
2011-10-17 20:41   ` Keith Packard
2011-10-17 21:07     ` Eugeni Dodonov
2011-10-17 22:41       ` Keith Packard
2011-10-18  0:06         ` Eugeni Dodonov
2011-10-18 10:02   ` [Intel-gfx] " Dave Airlie
2011-10-18 13:14     ` Jean Delvare
2011-10-18 13:37       ` Eugeni Dodonov
2011-10-20 12:33         ` Jean Delvare
2011-10-20 12:40           ` Jean Delvare
2011-10-20 13:13           ` Jean Delvare
2011-10-20 13:18           ` Michael Büsch
2011-10-24 14:40           ` Eugeni Dodonov
2011-10-25 13:03             ` [PATCH] Give up on edid retries when i2c bus is not responding Eugeni Dodonov
2011-10-26 17:06               ` Eugeni Dodonov [this message]
2011-10-26 17:18                 ` Chris Wilson
2011-10-26 17:35                   ` Eugeni Dodonov
2011-10-30 15:53             ` [Intel-gfx] [PATCH 1/2] Give up on edid retries when i2c tells us that bus is not there Jean Delvare
2011-10-18 14:01     ` Alex Deucher
2011-11-01  0:31     ` [PATCH] edid candidate for -next Eugeni Dodonov
2011-11-01  0:31       ` [PATCH] Give up on edid retries when i2c bus is not responding Eugeni Dodonov
2011-10-31 19:45   ` [Intel-gfx] [PATCH 1/2] Give up on edid retries when i2c tells us that bus is not there Chris Wilson
2011-10-17 13:12 ` [PATCH 2/2] Check if the bus is valid prior to discovering edid Eugeni Dodonov

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=1319648784-2402-1-git-send-email-eugeni.dodonov@intel.com \
    --to=eugeni.dodonov@intel.com \
    --cc=alexdeucher@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=khali@linux-fr.org \
    --cc=mb@bu3sch.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox