nv50_dp_mode_valid() keeps modes that are too fast for the DP link out of the connector's mode list, but a user-supplied mode only goes through atomic check, where nv50_outp_atomic_fix_depth() lowers bpc to 6 and then accepts the mode even if it still does not fit. Link training then fails, the display stays dark and, before the previous fix, the kernel crashed.
This happens with Xorg's modesetting driver, which builds modes from the EDID itself: on a Quadro 600 (DP 1.1, 4 lanes at 2.7 Gbit/s) with a 4K monitor it sets 3840x2160@60 (533 MHz), which needs 1200 MB/s even at 18 bpp against 1080 MB/s for the link. Return -EINVAL from atomic check in that case, so userspace can fall back to another mode. Only check when the link capabilities are known, so that a sink that is asleep or still resuming does not make every commit fail. Written with help from Claude (Anthropic); reviewed and tested on hardware. Signed-off-by: Frédéric Mahé <[email protected]> --- drivers/gpu/drm/nouveau/dispnv50/disp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index e91130f..fbe8528 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -423,6 +423,21 @@ nv50_outp_atomic_check(struct drm_encoder *encoder, /* We might have to reduce the bpc */ nv50_outp_atomic_fix_depth(encoder, crtc_state); + /* Reject a mode that does not fit the DP link even at the lowest bpc: + * link training would fail and the display would stay dark. Only + * when the link capabilities are known, so that a sink that is + * asleep or still resuming does not make every commit fail. + */ + if (crtc_state->mode_changed && crtc_state->active) { + struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); + + if (nv_encoder->dcb->type == DCB_OUTPUT_DP && + nv_encoder->dp.link_nr && nv_encoder->dp.link_bw && + nv50_dp_mode_valid(nv_encoder, &crtc_state->adjusted_mode, + NULL) != MODE_OK) + return -EINVAL; + } + return 0; } -- 2.53.0
