All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ze Huang" <ze.huang@oss.qualcomm.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 2/2] drm/imx: replace struct drm_simple_display_pipe with regular atomic helpers
Date: Sun, 26 Jul 2026 19:55:05 +0000	[thread overview]
Message-ID: <20260726195505.7A7B21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727-drm-simple-kms-removal-v3-2-de36e534f7a1@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Critical] NULL pointer dereference in `imx_lcdc_crtc_helper_atomic_enable` and `imx_lcdc_update_hw_registers` when the primary plane has no framebuffer.

Pre-existing issues:
- [High] Sleeping in atomic context by calling clock manipulation functions from the plane `atomic_update` callback.
--

--- Patch [2]: [PATCH v3 2/2] drm/imx: replace struct drm_simple_display_pipe with regular atomic helpers ---
commit e5bb94188c05e612166e809c2f562025fecbb70c
Author: Ze Huang <ze.huang@oss.qualcomm.com>

drm/imx: replace struct drm_simple_display_pipe with regular atomic helpers

Convert i.MX LCDC to explicit primary plane, CRTC and encoder objects. Keep
no-scaling plane check and GEM framebuffer prepare callback from simple-KMS
path.

> diff --git a/drivers/gpu/drm/imx/lcdc/imx-lcdc.c b/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
> index e00e52c1c46ec..e0784ce0125b7 100644
> --- a/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
> +++ b/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
[ ... ]
> @@ -206,7 +211,7 @@ static void imx_lcdc_pipe_enable(struct drm_simple_display_pipe *pipe,
>  
>  	clk_div = DIV_ROUND_CLOSEST_ULL(clk_get_rate(lcdc->clk_per),
>  					mode->clock * 1000);
> -	bpp = imx_lcdc_get_format(plane_state->fb->format->format);
> +	bpp = imx_lcdc_get_format(pstate->fb->format->format);

[Severity: Critical]
Can this dereference a NULL pointer if the primary plane has no framebuffer?

If a userspace process issues an atomic modeset commit that enables the CRTC
but leaves the primary plane with no framebuffer, pstate->fb would be NULL.
The drm_atomic_helper_check_crtc_primary_plane() helper checks if the
primary plane is attached, but doesn't guarantee a visible framebuffer.

Could this lead to a crash when querying the format here, or when passing
the fb to drm_fb_dma_get_gem_addr() inside imx_lcdc_update_hw_registers()
just below?

[ ... ]
> @@ -272,66 +283,151 @@ static void imx_lcdc_pipe_disable(struct drm_simple_display_pipe *pipe)
[ ... ]
> +	if (old_fb && old_fb->format != fb->format)
> +		mode_changed = true;
> +	else if (old_crtc != crtc)
> +		mode_changed = true;
> +
> -	if (!drm_atomic_crtc_needs_modeset(crtc->state))
> -		imx_lcdc_update_hw_registers(pipe, old_state, mode_changed);
> +	if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
> +		imx_lcdc_update_hw_registers(crtc, old_crtc_state, new_crtc_state,
> +					     new_state, mode_changed);

[Severity: High]
This is a pre-existing issue, but does this sleep in an atomic context?

When userspace requests a plane update that changes the pixel format but
does not alter the display resolution, drm_atomic_crtc_needs_modeset()
evaluates to false, but mode_changed is set to true. 

This causes imx_lcdc_update_hw_registers() to be called with mode_set=true:

imx_lcdc_plane_helper_atomic_update()
  imx_lcdc_update_hw_registers(..., mode_changed);
    clk_disable_unprepare(lcdc->clk_per);

Since clk_disable_unprepare() acquires a mutex and sleeps, is it safe to
call this from the plane's atomic_update callback, which executes in
atomic context where sleeping is forbidden?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-drm-simple-kms-removal-v3-0-de36e534f7a1@oss.qualcomm.com?part=2

  reply	other threads:[~2026-07-26 19:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-26 19:42 [PATCH v3 0/2] drm: replace simple display pipe users with atomic helpers Ze Huang
2026-07-26 19:42 ` [PATCH v3 1/2] drm/imx/lcdc: avoid duplicate clk_per enable Ze Huang
2026-07-26 19:59   ` sashiko-bot
2026-07-27  1:38     ` Ze Huang
2026-09-16  6:24   ` Thomas Zimmermann
2026-09-18 16:58     ` Ze Huang
2026-07-26 19:42 ` [PATCH v3 2/2] drm/imx: replace struct drm_simple_display_pipe with regular atomic helpers Ze Huang
2026-07-26 19:55   ` sashiko-bot [this message]
2026-07-27  1:53     ` Ze Huang
2026-09-16  6:50   ` Thomas Zimmermann
2026-09-16  7:46     ` Maxime Ripard
2026-09-16  7:51       ` Thomas Zimmermann
2026-09-18 17:05       ` Ze Huang
2026-09-18 15:14     ` Ze Huang

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=20260726195505.7A7B21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=ze.huang@oss.qualcomm.com \
    /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.