Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] Acquiring multiple modeset locks sequentially without an acquire 
context causes AB-BA deadlocks with concurrent atomic commits and triggers 
lockdep splats.
--

commit 5bf4951cc945bdc22bbaea8b5337320cd5b7047d
Author: Thomas Zimmermann <[email protected]>

drm/fb-helper: Only consider active CRTCs for vblank sync

This commit synchronizes fbdev output only to the vblank of an active
CRTC to prevent vblank wait timeouts. It implements separate atomic and
non-atomic code paths to select the correct active CRTC at runtime.

> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 7b11a582f8ec4..67b187f5c6bfc 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c

[ ... ]

> +static int find_crtc_index_atomic(struct drm_fb_helper *helper)
> +{
> +     struct drm_device *dev = helper->dev;
> +     struct drm_plane *plane;
> +     int crtc_index = -EINVAL;
> +
> +     drm_for_each_plane(plane, dev) {
> +             const struct drm_plane_state *plane_state;
> +
> +             if (plane->type != DRM_PLANE_TYPE_PRIMARY)
> +                     continue;
> +
> +             drm_modeset_lock(&plane->mutex, NULL);
> +             plane_state = plane->state;
> +
> +             if (plane_state->fb == helper->fb && plane_state->crtc) {
> +                     struct drm_crtc *crtc = plane_state->crtc;
> +
> +                     drm_modeset_lock(&crtc->mutex, NULL);

[Severity: High]
Can this sequence cause an AB-BA deadlock with concurrent atomic commits?

Because drm_modeset_lock() is called here on both plane->mutex and
crtc->mutex with a NULL acquire context, it falls back to standard blocking
mutex acquisition without the wait/wound deadlock avoidance mechanism.

If a concurrent atomic commit thread from a userspace compositor acquires
crtc->mutex and then attempts to acquire plane->mutex, could this permanently
hang both threads since the fbdev worker cannot be wound or back off?

> +                     if (crtc->state->active)
> +                             crtc_index = crtc->index;
> +                     drm_modeset_unlock(&crtc->mutex);
> +             }
> +             drm_modeset_unlock(&plane->mutex);
> +
> +             if (crtc_index >= 0)
> +                     break;
> +     }
> +
> +     return crtc_index;
> +}

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to