From: sashiko-bot@kernel.org
To: "Oarora Etimis" <oaroraetimis@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 1/2] drm/vkms: count the composer users
Date: Thu, 19 Nov 2026 13:51:10 +0000 [thread overview]
Message-ID: <sashiko-outbox-223213@kernel.org> (raw)
In-Reply-To: <20261119-composer-v3-1-dd470a820303@gmail.com>
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 <oaroraetimis@gmail.com>
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/20261119-composer-v3-0-dd470a820303@gmail.com?part=1
next prev parent reply other threads:[~2026-11-19 13:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 13:36 [PATCH v3 0/2] drm/vkms: give every composer user its own switch Oarora Etimis
2026-11-19 13:36 ` [PATCH v3 1/2] drm/vkms: count the composer users Oarora Etimis
2026-11-19 13:51 ` sashiko-bot [this message]
2026-11-19 13:36 ` [PATCH v3 2/2] drm/vkms: queue the composer work under the output lock Oarora Etimis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-223213@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=oaroraetimis@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox