Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/nouveau: incomplete DP mode check condition in
  nv50_outp_atomic_check()
--

commit 943220be5958f2da589b892e0f39c0caa93bf128
Author: Frédéric Mahé <[email protected]>

drm/nouveau/dispnv50: reject DP modes that don't fit the link

This commit rejects DisplayPort modes in nv50_outp_atomic_check() when
nv50_dp_mode_valid() indicates that the mode exceeds the link capacity even
after reducing the bpc.

> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
> b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> index 98a5188f65234..d7582ed8026b1 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;
> +     }

[Severity: Medium]
Should this condition be (crtc_state->mode_changed ||
crtc_state->connectors_changed), matching the bpc check earlier in
nv50_outp_atomic_check()?

If connector routing or a connector property changes without changing the
CRTC mode, crtc_state->connectors_changed is set while
crtc_state->mode_changed remains false.  This check is then skipped, even
though nv50_disp_outp_atomic_check_set() tests
drm_atomic_crtc_needs_modeset() and still enables the DP output and runs
link training with the out-of-range mode.

Also, struct drm_crtc_state documents that atomic_check callbacks must not
consult crtc_state->active to reject a commit.  Gating on crtc_state->active
allows an out-of-range mode to be committed while active is false; a later
DPMS ON commit only sets active_changed (with mode_changed false), bypassing
this check as well.

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to