Since link training moved out of the supervisor, ior->dp.nr is copied
from the lane count chosen by the DRM side, and it stays 0 when training
fails: no lane/rate combination fits the mode, or the sink does not
answer on AUX. nouveau_dp_train()'s result is ignored by
nv50_sor_atomic_enable(), so the modeset goes on, and supervisor 2.2
divides by ior->dp.nr in nv50_disp_super_2_2_dp():
Oops: divide error: 0000 [#1] SMP PTI
Workqueue: nvkm-disp nv50_disp_super [nouveau]
RIP: 0010:nv50_disp_super_2_2_dp+0xa4/0x340 [nouveau]
nv50_disp_super_2_2+0xcc/0x140 [nouveau]
nv50_disp_super+0x137/0x250 [nouveau]
Seen on a Quadro 600 (GF108) when Xorg set 3840x2160@60 (533 MHz) on a
DP 1.1 output, and when setting 1024x768 on a forced-on DP connector
whose monitor was asleep.
Skip the transfer unit and watermark setup with a warning when the link
has no lanes. Before the change below, the training loop never left
ior->dp.nr at 0.
Written with help from Claude (Anthropic); reviewed and tested on hardware.
Fixes: 3147ce0d07aa ("drm/nouveau/disp: move link training out of supervisor")
Cc: [email protected]
Signed-off-by: Frédéric Mahé <[email protected]>
---
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
index 03a5f88..778559d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
@@ -1166,6 +1166,16 @@ nv50_disp_super_2_2_dp(struct nvkm_head *head, struct
nvkm_ior *ior)
u32 best_diff = 64 * symbol;
u64 h, v;
+ /* Link training failed or was never done (e.g. mode too fast for the
+ * link, or no sink answering): there is no link to configure, and
+ * the calculations below would divide by zero.
+ */
+ if (!ior->dp.nr || !ior->dp.bw) {
+ nvkm_warn(subdev, "head-%d: DP link not trained (nr %d bw
%d)\n",
+ head->id, ior->dp.nr, ior->dp.bw);
+ return;
+ }
+
/* symbols/hblank - algorithm taken from comments in tegra driver */
h = head->asy.hblanke + head->asy.htotal - head->asy.hblanks - 7;
h = h * linkKBps;
--
2.53.0