On Sat, May 22, 2021 at 01:11:07PM -0700, Greg Steuck wrote:
> Jonathan Gray <j...@jsg.id.au> writes:
> 
> > As with otto's earlier problem there is likely something wrong
> > with sys/dev/pci/drm/i915/display/intel_gmbus.c or the way linux style
> > i2c is handled in drm_linux.c.
> >
> > As kettenis previously suggested this may be a problem with falling back
> > to bit banging.
> >
> > https://marc.info/?l=openbsd-bugs&m=159178640810102&w=2
> 
> This does seem to be the case (full log at the end):
> 
> May 22 09:29:22 lenny /bsd: GMBUS [i915 gmbus dpb] timed out, falling back to 
> bit banging on pin 1
> May 22 09:29:22 lenny /bsd: GMBUS [i915 gmbus dpb] timed out after NAK
> May 22 09:29:22 lenny /bsd: GMBUS [i915 gmbus dpb] NAK for addr: 0050 w(1)
> May 22 09:29:22 lenny /bsd: GMBUS [i915 gmbus dpb] timed out after NAK
> May 22 09:29:22 lenny /bsd: GMBUS [i915 gmbus dpb] NAK for addr: 0050 w(1)
> May 22 09:29:22 lenny /bsd: GMBUS [i915 gmbus dpb] timed out, falling back to 
> bit banging on pin 1
> May 22 09:29:22 lenny /bsd: DP dual mode HDMI ID: 0xffff800021bfe110E (err -5)
> May 22 09:29:22 lenny /bsd: [CONNECTOR:110:HDMI-A-1] status updated from 
> connected to disconnected
> 
> > I would prefer if someone who sees this issue could find the cause
> > instead of continuing to add workarounds.
> 
> We can certainly try to fix the gmbus problem though I believe it is
> separable from the out-of-bounds access in the error reporting path
> https://marc.info/?l=openbsd-tech&m=162061987617667&w=2
> 
> If you have patches to try, I'm happy to give them a go...

intel_gmbus.c has

                /*
                 * We wish to retry with bit banging
                 * after a timed out GMBUS attempt.
                 */
                bus->adapter.retries = 1;

does this help?

Index: sys/dev/pci/drm/drm_linux.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/drm/drm_linux.c,v
retrieving revision 1.79
diff -u -p -r1.79 drm_linux.c
--- sys/dev/pci/drm/drm_linux.c 11 Apr 2021 15:30:51 -0000      1.79
+++ sys/dev/pci/drm/drm_linux.c 28 May 2021 09:51:58 -0000
@@ -955,15 +955,21 @@ fail:
 int
 i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 {
-       int ret;
+       int ret, retries;
 
        if (adap->lock_ops)
                adap->lock_ops->lock_bus(adap, 0);
 
+       retries = adap->retries;
+retry:
        if (adap->algo)
                ret = adap->algo->master_xfer(adap, msgs, num);
        else
                ret = i2c_master_xfer(adap, msgs, num);
+       if (ret == -EAGAIN && retries > 0) {
+               retries--;
+               goto retry;
+       }
 
        if (adap->lock_ops)
                adap->lock_ops->unlock_bus(adap, 0);

Reply via email to