All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 03/10] drm/msm: release scanout framebuffers only after a vblank
Date: Sat, 03 Oct 2026 01:34:29 +0000	[thread overview]
Message-ID: <20261003013429.DF7271F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261003-fd-kms-fix-smmu-v4-3-2a44d4d8ac77@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/msm: premature unpin of framebuffers causing IOMMU fault
--

commit 86394032733ab2293f0e387866c3cbd603bc3285
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Subject: drm/msm: release scanout framebuffers only after a vblank

This commit defers scanout framebuffer release until a vblank by handing them
to a drm_vblank_work per CRTC. On CRTC disable, pending works are flushed and
framebuffers are unpinned directly from msm_crtc_vblank_off().

> diff --git a/drivers/gpu/drm/msm/msm_kms.c b/drivers/gpu/drm/msm/msm_kms.c
> index 7e1df472592d3..cb497d419ab83 100644
> --- a/drivers/gpu/drm/msm/msm_kms.c
> +++ b/drivers/gpu/drm/msm/msm_kms.c
[ ... ]
> +/*
> + * The crtc stops fetching here, and with it the vblanks the pending works are
> + * waiting for, so release the framebuffers directly.
> + */
> +static void msm_kms_fb_unpin_release_all(struct msm_kms_fb_unpin *pending)
> +{
[ ... ]
> +		drm_vblank_work_cancel_sync(&unpin->base);
> +		msm_kms_fb_unpin_release(unpin);
> +	}
> +}
> +
> +void msm_crtc_vblank_off(struct drm_crtc *crtc)
> +{
> +	struct msm_drm_private *priv = crtc->dev->dev_private;
> +	struct msm_kms *kms = priv->kms;
> +	unsigned int idx = drm_crtc_index(crtc);
> +
> +	if (kms && idx < ARRAY_SIZE(kms->fb_unpin))
> +		msm_kms_fb_unpin_release_all(&kms->fb_unpin[idx]);
> +
> +	drm_crtc_vblank_off(crtc);
> +}
[ ... ]
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index 77a2d1f6700d0..35daf46fc4257 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -1213,7 +1213,7 @@ static void dpu_crtc_disable(struct drm_crtc *crtc,
>  	}
>  
>  	/* Disable/save vblank irq handling */
> -	drm_crtc_vblank_off(crtc);
> +	msm_crtc_vblank_off(crtc);

[Severity: High]
Can this lead to an IOMMU context fault if the display hardware is still 
fetching the frame?

When a userspace application issues an async plane update followed closely by 
a CRTC disable, the ongoing hardware fetch might hit an IOMMU fault because 
the memory is unmapped immediately during the disable sequence.

Because msm_crtc_vblank_off() now synchronously unpins and unmaps all pending 
framebuffers via msm_kms_fb_unpin_release_all(), executing this before the 
hardware is done fetching creates a race window.

Looking at dpu_crtc_disable(), we wait for the hardware to finish its current 
frame fetch much later in the function:

drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c:dpu_crtc_disable() {
    ...
    msm_crtc_vblank_off(crtc);
    ...
    if (_dpu_crtc_wait_for_frame_done(crtc))
        DPU_ERROR(...);
    ...
}

Does this sequence leave a race window where the display is left reading 
unmapped memory?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261003-fd-kms-fix-smmu-v4-0-2a44d4d8ac77@oss.qualcomm.com?part=3

  reply	other threads:[~2026-10-03  1:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03  0:30 [PATCH v4 00/10] drm/msm: fix SMMU fault dumps Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 01/10] drm/msm: serialise framebuffer pin state Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 02/10] drm/msm: fix framebuffer pin refcount leak on prepare failure Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 03/10] drm/msm: release scanout framebuffers only after a vblank Dmitry Baryshkov
2026-10-03  1:34   ` sashiko-bot [this message]
2026-10-08 13:52     ` Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 04/10] drm/msm/mdp5: flush the interface before starting the timing engine Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 05/10] drm/msm/dpu: clear the CWB blocks left by a previous reservation Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 06/10] drm/msm/dpu: clear the CDM block " Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 07/10] drm/msm/dpu: clear the DSPP pointer when no DSPP is assigned Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 08/10] drm/msm/dpu: clear the DSC blocks left by a previous reservation Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 09/10] drm/msm/dpu: only reassign resources when the encoder is reprogrammed Dmitry Baryshkov
2026-10-03  0:30 ` [PATCH v4 10/10] drm/ci: mark pixel-format tests as passing on SC7180 Dmitry Baryshkov

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=20261003013429.DF7271F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --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.