linux-brain/drivers/gpu/drm/nouveau/nvkm/subdev/i2c
Lyude Paul c358ebf596 drm/nouveau: Don't retry infinitely when receiving no data on i2c over AUX
While I had thought I had fixed this issue in:

commit 342406e4fb ("drm/nouveau/i2c: Disable i2c bus access after
->fini()")

It turns out that while I did fix the error messages I was seeing on my
P50 when trying to access i2c busses with the GPU in runtime suspend, I
accidentally had missed one important detail that was mentioned on the
bug report this commit was supposed to fix: that the CPU would only lock
up when trying to access i2c busses _on connected devices_ _while the
GPU is not in runtime suspend_. Whoops. That definitely explains why I
was not able to get my machine to hang with i2c bus interactions until
now, as plugging my P50 into it's dock with an HDMI monitor connected
allowed me to finally reproduce this locally.

Now that I have managed to reproduce this issue properly, it looks like
the problem is much simpler then it looks. It turns out that some
connected devices, such as MST laptop docks, will actually ACK i2c reads
even if no data was actually read:

[  275.063043] nouveau 0000:01:00.0: i2c: aux 000a: 1: 0000004c 1
[  275.063447] nouveau 0000:01:00.0: i2c: aux 000a: 00 01101000 10040000
[  275.063759] nouveau 0000:01:00.0: i2c: aux 000a: rd 00000001
[  275.064024] nouveau 0000:01:00.0: i2c: aux 000a: rd 00000000
[  275.064285] nouveau 0000:01:00.0: i2c: aux 000a: rd 00000000
[  275.064594] nouveau 0000:01:00.0: i2c: aux 000a: rd 00000000

Because we don't handle the situation of i2c ack without any data, we
end up entering an infinite loop in nvkm_i2c_aux_i2c_xfer() since the
value of cnt always remains at 0. This finally properly explains how
this could result in a CPU hang like the ones observed in the
aforementioned commit.

So, fix this by retrying transactions if no data is written or received,
and give up and fail the transaction if we continue to not write or
receive any data after 32 retries.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2019-08-23 12:42:43 +10:00
..
anx9805.c drm/nouveau/i2c: modify aux interface to return length actually transferred 2017-03-07 17:05:16 +10:00
aux.c drm/nouveau: Don't retry infinitely when receiving no data on i2c over AUX 2019-08-23 12:42:43 +10:00
aux.h drm/nouveau: fix bogus GPL-2 license header 2019-07-19 16:26:50 +10:00
auxg94.c drm/nouveau/i2c/gf119-: add support for address-only transactions 2017-07-24 12:15:24 +10:00
auxgf119.c drm/nouveau/i2c/gf119-: add support for address-only transactions 2017-07-24 12:15:24 +10:00
auxgm200.c drm/nouveau/i2c/gf119-: add support for address-only transactions 2017-07-24 12:15:24 +10:00
base.c drm/nouveau/i2c: Enable i2c pads & busses during preinit 2019-07-19 16:26:50 +10:00
bit.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
bus.c drm/nouveau/i2c: Disable i2c bus access after ->fini() 2019-05-01 11:08:39 +10:00
bus.h drm/nouveau: fix bogus GPL-2 license header 2019-07-19 16:26:50 +10:00
busgf119.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
busnv04.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
busnv4e.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
busnv50.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
g94.c drm/nouveau/i2c: convert to new-style nvkm_subdev 2015-08-28 12:40:43 +10:00
gf117.c drm/nouveau/i2c: convert to new-style nvkm_subdev 2015-08-28 12:40:43 +10:00
gf119.c drm/nouveau/i2c: convert to new-style nvkm_subdev 2015-08-28 12:40:43 +10:00
gk104.c drm/nouveau/i2c: convert to new-style nvkm_subdev 2015-08-28 12:40:43 +10:00
gm200.c drm/nouveau: s/gm204/gm200/ in a number of places 2016-03-14 10:13:12 +10:00
Kbuild drm/nouveau: fix bogus GPL-2 license header 2019-07-19 16:26:51 +10:00
nv04.c drm/nouveau/i2c: convert to new-style nvkm_subdev 2015-08-28 12:40:43 +10:00
nv4e.c drm/nouveau/i2c: convert to new-style nvkm_subdev 2015-08-28 12:40:43 +10:00
nv50.c drm/nouveau/i2c: convert to new-style nvkm_subdev 2015-08-28 12:40:43 +10:00
pad.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
pad.h drm/nouveau: fix bogus GPL-2 license header 2019-07-19 16:26:50 +10:00
padg94.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
padgf119.c drm/nouveau/i2c/gf119-: add support for address-only transactions 2017-07-24 12:15:24 +10:00
padgm200.c drm/nouveau: s/gm204/gm200/ in a number of places 2016-03-14 10:13:12 +10:00
padnv04.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
padnv4e.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
padnv50.c drm/nouveau/i2c: transition pad/ports away from being based on nvkm_object 2015-08-28 12:40:29 +10:00
priv.h drm/nouveau: fix bogus GPL-2 license header 2019-07-19 16:26:50 +10:00