From: sashiko-bot@kernel.org
To: "Alexandre MINETTE via B4 Relay"
<devnull+contact.alex-min.fr@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/msm/mdp4: keep the bus clock enabled while a CRTC is active
Date: Thu, 11 Jun 2026 06:18:21 +0000 [thread overview]
Message-ID: <20260611061821.698821F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611-mainline-fix-mdp4-blue-screen-sending-v1-v1-1-22925600e4f2@alex-min.fr>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Sleeping functions called from atomic context.
- [High] Unbalanced reference counting on AXI clock enable failure leads to premature clock disable for active CRTCs.
Pre-existing issues:
- [High] Failure to enforce IOMMU requirement by allowing a NULL VM fallback in drm_gpuvm conversion.
--
commit f1ffff35bea0debf56db480bb3da6443ad42c41a
Author: Alexandre MINETTE <contact@alex-min.fr>
Subject: drm/msm/mdp4: keep the bus clock enabled while a CRTC is active
This patch keeps the AXI/bus clock enabled for the lifetime of each active
CRTC to avoid temporary MDP4 disable paths gating the bus clock while
scanout is still running.
> diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
> index e8066f9fd5343..9e53c9d956ca8 100644
> --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
> @@ -271,6 +271,7 @@ static void mdp4_crtc_atomic_disable(struct drm_crtc *crtc,
>
> mdp_irq_unregister(&mdp4_kms->base, &mdp4_crtc->err);
> mdp4_disable(mdp4_kms);
> + mdp4_crtc_bus_put(mdp4_kms);
[Severity: High]
Does calling mdp4_crtc_bus_put() here introduce a sleeping lock into an atomic
context?
CRTC atomic disable callbacks execute in an atomic context where sleeping is
forbidden, but mdp4_crtc_bus_put() acquires a mutex lock.
[ ... ]
> @@ -295,6 +296,7 @@ static void mdp4_crtc_atomic_enable(struct drm_crtc *crtc,
> return;
>
> mdp4_enable(mdp4_kms);
> + mdp4_crtc_bus_get(mdp4_kms);
[Severity: High]
Similarly, does this introduce sleeping calls into the atomic enable path?
mdp4_crtc_bus_get() uses both mutex_lock() and clk_prepare_enable(), which
may sleep.
[ ... ]
> diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
> index 809ca191e9de7..4c60b49fb7842 100644
> --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
> +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
> @@ -118,6 +118,39 @@ static long mdp4_round_pixclk(struct msm_kms *kms, unsigned long rate,
[ ... ]
> +void mdp4_crtc_bus_get(struct mdp4_kms *mdp4_kms)
> +{
> + int ret = 0;
> +
> + mutex_lock(&mdp4_kms->clock_lock);
> +
> + if (!mdp4_kms->crtc_bus_count)
> + ret = clk_prepare_enable(mdp4_kms->axi_clk);
> +
> + if (!ret)
> + mdp4_kms->crtc_bus_count++;
> +
> + mutex_unlock(&mdp4_kms->clock_lock);
> +
> + WARN_ON(ret);
> +}
> +
> +void mdp4_crtc_bus_put(struct mdp4_kms *mdp4_kms)
> +{
> + mutex_lock(&mdp4_kms->clock_lock);
> + if (!mdp4_kms->crtc_bus_count)
> + goto unlock;
> +
> + mdp4_kms->crtc_bus_count--;
[Severity: High]
Could this result in unbalanced reference counting and premature clock disable?
If clk_prepare_enable() fails in mdp4_crtc_bus_get(), crtc_bus_count is not
incremented, but the error isn't propagated since the function returns void.
If a subsequent CRTC successfully enables the clock, the counter becomes 1.
Later, when the first (failed) CRTC is disabled, mdp4_crtc_bus_put() will
unconditionally decrement crtc_bus_count to 0 and disable the clock. This
steals the reference belonging to the second active CRTC, leaving it scanning
out with its bus clock disabled.
[ ... ]
While reviewing this file, I noticed a pre-existing issue in mdp4_kms_init():
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c:mdp4_kms_init() {
...
vm = msm_kms_init_vm(mdp4_kms->dev, NULL);
if (IS_ERR(vm)) {
ret = PTR_ERR(vm);
goto fail;
}
kms->vm = vm;
...
}
[Severity: High]
This is a pre-existing issue, but does this bypass the IOMMU requirement if
msm_kms_init_vm() returns NULL?
The DRM subsystem requires IOMMU support for drm_gpuvm and does not support
fallback modes. Since msm_kms_init_vm() might return NULL when IOMMU is
unavailable, checking only IS_ERR(vm) allows driver initialization to proceed
with a NULL VM instead of failing with an error.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260611-mainline-fix-mdp4-blue-screen-sending-v1-v1-0-22925600e4f2@alex-min.fr?part=1
next prev parent reply other threads:[~2026-06-11 6:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 6:07 [PATCH 0/2] drm/msm/mdp4: fix intermittent blue screen on Galaxy S4 Alexandre MINETTE via B4 Relay
2026-06-11 6:07 ` Alexandre MINETTE
2026-06-11 6:07 ` [PATCH 1/2] drm/msm/mdp4: keep the bus clock enabled while a CRTC is active Alexandre MINETTE via B4 Relay
2026-06-11 6:07 ` Alexandre MINETTE
2026-06-11 6:18 ` sashiko-bot [this message]
2026-06-11 7:51 ` Konrad Dybcio
2026-06-11 6:07 ` [PATCH 2/2] drm/msm/mdp4: keep inherited display clocks enabled until modeset Alexandre MINETTE via B4 Relay
2026-06-11 6:07 ` Alexandre MINETTE
2026-06-11 6:18 ` sashiko-bot
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=20260611061821.698821F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=devnull+contact.alex-min.fr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.