Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/vkms: composer_users underflow in vkms_set_crc_source() on error --
commit 22fc9fb8d10e80e408b96eee292c039a0d2a1b22 Author: Oarora Etimis <[email protected]> drm/vkms: count the composer users This commit replaces the boolean composer_enabled flag with a reference count so that concurrent CRC capture and writeback jobs do not disable the composer while the other is still active. > diff --git a/drivers/gpu/drm/vkms/vkms_composer.c > b/drivers/gpu/drm/vkms/vkms_composer.c > index 0fc915a954bad..96c40eeeb61ba 100644 > --- a/drivers/gpu/drm/vkms/vkms_composer.c > +++ b/drivers/gpu/drm/vkms/vkms_composer.c > @@ -711,19 +711,33 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const > char *src_name, > return 0; > } > > -void vkms_set_composer(struct vkms_output *out, bool enabled) > +bool vkms_composer_get(struct vkms_output *out) > { > - bool old_enabled; > + unsigned int users; > > - if (enabled) > - drm_crtc_vblank_get(&out->crtc); > + if (drm_crtc_vblank_get(&out->crtc)) > + return false; > + > + spin_lock_irq(&out->lock); > + users = out->composer_users++; > + spin_unlock_irq(&out->lock); > + > + /* All users share a single vblank reference. */ > + if (users) > + drm_crtc_vblank_put(&out->crtc); > + > + return true; > +} > + > +void vkms_composer_put(struct vkms_output *out) > +{ > + unsigned int users; > > spin_lock_irq(&out->lock); > - old_enabled = out->composer_enabled; > - out->composer_enabled = enabled; > + users = --out->composer_users; > spin_unlock_irq(&out->lock); > > - if (old_enabled) > + if (!users) > drm_crtc_vblank_put(&out->crtc); > } > > @@ -735,7 +749,10 @@ int vkms_set_crc_source(struct drm_crtc *crtc, const > char *src_name) > > ret = vkms_crc_parse_source(src_name, &enabled); > > - vkms_set_composer(out, enabled); > + if (enabled) > + vkms_composer_get(out); > + else > + vkms_composer_put(out); > > return ret; > } [Severity: Medium] Can this underflow out->composer_users when vkms_composer_get() or vkms_crc_parse_source() fails? crtc_crc_open() drops crtc->mutex after checking crtc->state->active and before calling set_crc_source(). If the CRTC is disabled in that window, drm_crtc_vblank_get() fails and vkms_composer_get() returns false without incrementing out->composer_users. Because vkms_set_crc_source() ignores that failure and returns 0, crtc_crc_open() succeeds and the matching crtc_crc_release() later calls vkms_set_crc_source(crtc, NULL) -> vkms_composer_put(), decrementing out->composer_users without a prior increment. This either wraps out->composer_users to UINT_MAX (leaving the composer permanently active and causing later vkms_composer_get() calls to drop their vblank reference immediately) or prematurely drops a concurrent writeback job's composer and vblank reference. Also, if vkms_crc_parse_source() returns -EINVAL, enabled is false and vkms_set_crc_source() still calls vkms_composer_put(). -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
