dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Liu Ying" <victor.liu@nxp.com>
Cc: dri-devel@lists.freedesktop.org, conor+dt@kernel.org,
	Frank.Li@kernel.org, robh@kernel.org, devicetree@vger.kernel.org,
	imx@lists.linux.dev
Subject: Re: [PATCH v6 07/13] drm/imx: dc: Use TCON operation mode
Date: Fri, 04 Sep 2026 08:05:43 +0000	[thread overview]
Message-ID: <20260904080544.482851F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904-imx8-dc-prefetch-v6-7-26643e3f6cb7@nxp.com>

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

New issues:
- [High] Regmap accesses inside the IRQ-disabled section use a non-raw spinlock, triggering a sleep-in-atomic bug on PREEMPT_RT.
- [High] TCON hardware is programmed using logical mode timings instead of the required adjusted CRTC physical timings.

Pre-existing issues:
- [High] Polling jiffies in a busy loop with local interrupts disabled leads to a hard lockup.
--

commit 1e5ba5ba9464ec8a1530f337a9b8808253bcb887
Author: Liu Ying <victor.liu@nxp.com>
drm/imx: dc: Use TCON operation mode

This commit introduces TCON operation mode to generate customized output
timings by ignoring FrameGen sync signals. It switches TCON to operation
mode during CRTC enable to allow the prefetch engine to evade the first
dumb frame.

> diff --git a/drivers/gpu/drm/imx/dc/dc-crtc.c b/drivers/gpu/drm/imx/dc/dc-crtc.c
> index 71694f1244e17..eae9bd164b230 100644
> --- a/drivers/gpu/drm/imx/dc/dc-crtc.c
> +++ b/drivers/gpu/drm/imx/dc/dc-crtc.c
[ ... ]
> @@ -273,7 +285,22 @@ dc_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_commit *state)
[ ... ]
> +	/* Don't relinquish CPU until TCON is set to operation mode. */
> +	local_irq_save(flags);
> +	preempt_disable();
>  
>  	dc_fg_enable(dc_crtc->fg);
> +	/*
> +	 * Turn TCON into operation mode as soon as the first dumb
> +	 * frame is generated by DC(we don't relinquish CPU to ensure
> +	 * this).  This makes DPR/PRG be able to evade the frame.
> +	 */
> +	DC_CRTC_WAIT_FOR_FRAMEGEN_FRAME_INDEX_MOVING(dc_crtc->fg);

[Severity: High]
This is a pre-existing issue, but duplicating this pattern here might lead
to a hard lockup.

The DC_CRTC_WAIT_FOR_FRAMEGEN_FRAME_INDEX_MOVING macro eventually calls
dc_fg_wait_for_frame_index_moving(), which polls the hardware state in a
do-while loop bounded by time_before(jiffies, timeout).

Because local interrupts are disabled here via local_irq_save(), the timer
tick cannot run. If this CPU is responsible for updating jiffies (or on a
UP system), jiffies will never increment. If the hardware frame index
fails to move, will this loop spin infinitely and trigger a watchdog or
CPU stall?

(This flawed pattern already existed in dc_crtc_atomic_flush(), but this
patch duplicates it into dc_crtc_atomic_enable()).

> +	dc_tc_set_operation_mode(dc_crtc->tc);

[Severity: High]
Does this regmap write trigger a sleep-in-atomic bug on PREEMPT_RT?

Calling dc_tc_set_operation_mode() here triggers a regmap write. Since we
are inside a local_irq_save() block, and the TCON regmap (configured in
dc_tc_regmap_config) lacks .use_raw_spinlock = true, it will attempt to
acquire a sleepable rt_mutex on PREEMPT_RT, violating lock nesting rules.

> +
> +	local_irq_restore(flags);
> +	preempt_enable();
[ ... ]
> diff --git a/drivers/gpu/drm/imx/dc/dc-tc.c b/drivers/gpu/drm/imx/dc/dc-tc.c
> index d0d4faba790e5..746fcaaf97f56 100644
> --- a/drivers/gpu/drm/imx/dc/dc-tc.c
> +++ b/drivers/gpu/drm/imx/dc/dc-tc.c
[ ... ]
> @@ -46,7 +77,7 @@ static const struct regmap_config dc_tc_regmap_config = {
>  	.fast_io = true,
>  	.wr_table = &dc_tc_regmap_access_table,
>  	.rd_table = &dc_tc_regmap_access_table,
> -	.max_register = MAPBIT31_28,
> +	.max_register = SMXFCTTABLE(3),
>  };

[Severity: High]
Does this regmap configuration need .use_raw_spinlock = true?

Since .fast_io = true is set without .use_raw_spinlock, the regmap protects
fast I/O with a standard spinlock_t. On PREEMPT_RT kernels, spinlock_t
becomes a preemptible rt_mutex which can sleep, causing crashes if accessed
while hardware interrupts are disabled.

[ ... ]
> @@ -59,10 +90,85 @@ static const u32 dc_tc_mapbit[] = {
[ ... ]
> +void dc_tc_cfg_videomode(struct dc_tc *tc, struct drm_display_mode *m)
> +{
> +	int hdisplay, hsync_start, hsync_end;
> +	int vdisplay, vsync_start, vsync_end;
> +	int y;
> +
> +	hdisplay = m->hdisplay;
> +	vdisplay = m->vdisplay;
> +	hsync_start = m->hsync_start;
> +	vsync_start = m->vsync_start;
> +	hsync_end = m->hsync_end;
> +	vsync_end = m->vsync_end;

[Severity: High]
Are these the correct timings to use for TCON hardware programming?

By extracting the logical mode timings (e.g., m->hdisplay) instead of the
physical adjusted timings (e.g., m->crtc_hdisplay), we might program the
TCON and FrameGen with mismatched timings.

FrameGen correctly uses the adjusted crtc_* variants. If a DRM bridge or
encoder adjusts the physical timings (like scaling or interleaving) while
leaving logical timings intact, will this mismatch cause sync loss, visual
corruption, or panel failure?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-imx8-dc-prefetch-v6-0-26643e3f6cb7@nxp.com?part=7

  reply	other threads:[~2026-09-04  8:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  7:54 [PATCH v6 00/13] drm/imx: dc: Use prefetch engine Liu Ying
2026-09-04  7:54 ` [PATCH v6 01/13] dt-bindings: display: imx: Add i.MX8qxp/qm PRG binding Liu Ying
2026-09-04  7:54 ` [PATCH v6 02/13] dt-bindings: display: imx: Add i.MX8qxp/qm DPR channel binding Liu Ying
2026-09-04  7:54 ` [PATCH v6 03/13] drm/imx: dc-fu: Fix dimensions Liu Ying
2026-09-04  8:07   ` sashiko-bot
2026-09-04  7:54 ` [PATCH v6 04/13] drm/imx: dc-crtc: Disable at boot Liu Ying
2026-09-04  8:10   ` sashiko-bot
2026-09-04  8:27   ` Maxime Ripard
2026-09-04  7:54 ` [PATCH v6 05/13] drm/imx: dc: Add PRG support Liu Ying
2026-09-04  8:08   ` sashiko-bot
2026-09-04  8:29   ` Maxime Ripard
2026-09-04  7:54 ` [PATCH v6 06/13] drm/imx: dc: Add DPR channel support Liu Ying
2026-09-04  8:07   ` sashiko-bot
2026-09-04  8:29   ` Maxime Ripard
2026-09-04  7:54 ` [PATCH v6 07/13] drm/imx: dc: Use TCON operation mode Liu Ying
2026-09-04  8:05   ` sashiko-bot [this message]
2026-09-04  8:32   ` Maxime Ripard
2026-09-04  7:54 ` [PATCH v6 08/13] drm/imx: dc-ed: Support getting source selection Liu Ying
2026-09-04  8:00   ` sashiko-bot
2026-09-04  8:32   ` Maxime Ripard
2026-09-04  7:54 ` [PATCH v6 09/13] drm/imx: dc-lb: Support getting secondary input selection Liu Ying
2026-09-04  8:33   ` Maxime Ripard
2026-09-04  7:55 ` [PATCH v6 10/13] drm/imx: dc-ed: Drop initial source selection Liu Ying
2026-09-04  8:03   ` sashiko-bot
2026-09-04  8:33   ` Maxime Ripard
2026-09-04  7:55 ` [PATCH v6 11/13] drm/imx: dc-lb: Drop initial primary and secondary input selections Liu Ying
2026-09-04  8:33   ` Maxime Ripard
2026-09-04  7:55 ` [PATCH v6 12/13] drm/imx: dc-fu: Get DPR channel Liu Ying
2026-09-04  8:13   ` sashiko-bot
2026-09-04  8:36   ` Maxime Ripard
2026-09-04  7:55 ` [PATCH v6 13/13] drm/imx: dc: Use prefetch engine Liu Ying
2026-09-04  8:13   ` 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=20260904080544.482851F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imx@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=victor.liu@nxp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox