From: Jean Delvare Subject: Re: [Intel-gfx] [PATCH 1/2] Give up on edid retries when i2c tells us that bus is not there Date: Tue, 18 Oct 2011 15:14:51 +0200 Message-ID: <20111018151451.280f8f18@endymion.delvare> References: <1318857150-2117-1-git-send-email-eugeni.dodonov@intel.com> <1318857150-2117-2-git-send-email-eugeni.dodonov@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from services.gcu-squad.org (zone0.gcu-squad.org [212.85.147.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 41D499E82F for ; Tue, 18 Oct 2011 06:34:36 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Dave Airlie Cc: dri-devel , Eugeni Dodonov List-Id: dri-devel@lists.freedesktop.org Hi Dave, Eugeni, Alex, On Tue, 18 Oct 2011 11:02:00 +0100, Dave Airlie wrote: > > This allows to avoid talking to a non-existent bus repeatedly until we > > finally timeout. The non-existent bus is signalled by -ENXIO error, > > provided by i2c_algo_bit:bit_doAddress call. > > > > As the advantage of such change, all the other routines which use > > drm_get_edid would benefit for this timeout. > > > > This change should fix > > https://bugs.freedesktop.org/show_bug.cgi?id=3D41059 and improve overall > > edid detection timing by 10-30% in most cases, and by a much larger mar= gin > > in case of phantom outputs. > = > Jean, Alex, > = > I'm thinking of thowing this into -next, any objections? This seems to be the wrong place for the test. The code below is really testing for non-responsive (possibly not present) EDID, NOT "non-existent adapter". Non-existent adapter should be checked in the firmware if possible, or failing that, by testing the bus lines at bus creation time, as i2c_algo_bit.bit_test=3D1 is doing. While this setting has been known to cause trouble recently (not per se but because it was triggering a bug somewhere else in the radeon driver), it might still have value, and could be changed to a per-adapter setting by exporting the test function (I have a patch ready doing exactly this) and letting video drivers test their I2C buses and discard the non-working ones if they want. I am worried that the patch below will cause regressions on other machines. There's a comment right before the loop which reads: /* The core i2c driver will automatically retry the transfer if the * adapter reports EAGAIN. However, we find that bit-banging transfers * are susceptible to errors under a heavily loaded machine and * generate spurious NAKs and timeouts. Retrying the transfer * of the individual block a few times seems to overcome this. */ So the retries are there for a reason, and -ENXIO is exactly what you get on spurious NAKs. One thing which may make sense would be to make the retry count a module parameter, instead of a hard-coded value, so that users can lower the value if they care more about boot time than reliability. But again, ideally problematic buses would not have been created in the first place. > > > > Signed-off-by: Eugeni Dodonov > > --- > > =A0drivers/gpu/drm/drm_edid.c | =A0 =A05 +++++ > > =A01 files changed, 5 insertions(+), 0 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > > index 7425e5c..1bca6d7 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, > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D i2c_transfer(adapter, msgs, 2); > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ret =3D=3D -ENXIO) { > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_DEBUG_KMS("drm: skipp= ing non-existent adapter %s\n", > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 adapter->name); > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > > =A0 =A0 =A0 =A0} while (ret !=3D 2 && --retries); > > > > =A0 =A0 =A0 =A0return ret =3D=3D 2 ? 0 : -1; -- = Jean Delvare