dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/msm/dsi: skip dsi_wait4video_eng_busy() when BLOCK_DMA_WITHIN_FRAME is set
@ 2026-11-29  0:05 Vladimir Bely
  2026-11-29  0:19 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Bely @ 2026-11-29  0:05 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	David Airlie, Simona Vetter, linux-arm-msm, dri-devel, freedreno,
	linux-kernel, Vladimir Bely

Since DSI 6G v1.2, dsi_ctrl_config() sets
DSI_TRIG_CTRL_BLOCK_DMA_WITHIN_FRAME so the hardware itself defers
SW-triggered command DMA until the blanking period.

Software still runs dsi_wait4video_eng_busy() before every command in
video mode, which waits for VIDEO_DONE and then sleeps 2-4 ms to skip
BLLP. On panels with short vertical blanking (e.g. 24 lines / ~0.41 ms
at 60 Hz on Samsung AMS452EF01), that sleep always misses the blanking
window and pushes the command to the next frame, costing ~2 frames per
DCS transfer (~275 ms for a 7-command backlight update).

Return early from dsi_wait4video_eng_busy() on DSI 6G >= v1.2 where
BLOCK_DMA_WITHIN_FRAME is enabled, matching the existing comment in
msm_dsi_host_xfer_prepare(). Tested on MSM8916 (Samsung Galaxy A3,
SM-A300F), reducing a 7-command backlight update from ~275 ms to ~36 ms.

Signed-off-by: Vladimir Bely <vlwwwwww@gmail.com>
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index d92659d80..1f13e64a9 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1222,6 +1222,16 @@ static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host)
 	if (!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO))
 		return;
 
+	/*
+	 * With BLOCK_DMA_WITHIN_FRAME enabled in dsi_ctrl_config(), the
+	 * hardware holds the DMA until the blanking period itself. Sleeping
+	 * past VIDEO_DONE misses short blankings and costs a whole frame per
+	 * command.
+	 */
+	if (msm_dsi_host_version_geq(msm_host, MSM_DSI_VER_MAJOR_6G,
+				     MSM_DSI_6G_VER_MINOR_V1_2))
+		return;
+
 	data = dsi_read(msm_host, REG_DSI_STATUS0);
 
 	/* if video mode engine is not busy, its because

base-commit: dca2f1b25860f8caa0406f858e76a3a21671a012
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/msm/dsi: skip dsi_wait4video_eng_busy() when BLOCK_DMA_WITHIN_FRAME is set
  2026-11-29  0:05 [PATCH] drm/msm/dsi: skip dsi_wait4video_eng_busy() when BLOCK_DMA_WITHIN_FRAME is set Vladimir Bely
@ 2026-11-29  0:19 ` sashiko-bot
  2026-11-29  1:14   ` Vladimir Bely
  0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-11-29  0:19 UTC (permalink / raw)
  To: Vladimir Bely; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/msm/dsi: dsi_wait4video_eng_busy() skips video sync on
  cmd_mdp flag
--

commit ecab5b36663485746972b4242e09b891775ae38a
Author: Vladimir Bely <vlwwwwww@gmail.com>

drm/msm/dsi: skip dsi_wait4video_eng_busy() when BLOCK_DMA_WITHIN_FRAME is set

This commit skips waiting for VIDEO_DONE and the subsequent 2-4 ms sleep
in dsi_wait4video_eng_busy() on DSI 6G v1.2 and newer controllers.

> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index d92659d80f172..1f13e64a98268 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1222,6 +1222,16 @@ static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host)
>  	if (!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO))
>  		return;
>  
> +	/*
> +	 * With BLOCK_DMA_WITHIN_FRAME enabled in dsi_ctrl_config(), the
> +	 * hardware holds the DMA until the blanking period itself. Sleeping
> +	 * past VIDEO_DONE misses short blankings and costs a whole frame per
> +	 * command.
> +	 */
> +	if (msm_dsi_host_version_geq(msm_host, MSM_DSI_VER_MAJOR_6G,
> +				     MSM_DSI_6G_VER_MINOR_V1_2))
> +		return;
> +
>  	data = dsi_read(msm_host, REG_DSI_STATUS0);
>  
>  	/* if video mode engine is not busy, its because

[Severity: Medium]
Does DSI_TRIG_CTRL_BLOCK_DMA_WITHIN_FRAME actually defer command DMA to
the video-mode blanking period?

The comment in msm_dsi_host_xfer_prepare() describes
BLOCK_DMA_WITHIN_FRAME as gating command DMA until the command-mode MDP
engine (dsi_cmd_mdp) is idle:

drivers/gpu/drm/msm/dsi/dsi_host.c:msm_dsi_host_xfer_prepare() {
	/* TODO: make sure dsi_cmd_mdp is idle.
	 * Since DSI6G v1.2.0, we can set DSI_TRIG_CTRL.BLOCK_DMA_WITHIN_FRAME
	 * to ask H/W to wait until cmd mdp is idle. S/W wait is not needed.
	 * How to handle the old versions? Wait for mdp cmd done?
	 */
}

In video mode, dsi_ctrl_enable() (which replaced dsi_ctrl_config()) sets
DSI_VID_CFG0_EOF_BLLP_POWER_STOP and DSI_VID_CFG0_BLLP_POWER_STOP on all
controller versions so the command engine transmits during BLLP, with
DSI_TRIG_CTRL_DMA_TRIGGER(TRIGGER_SW).  When VIDEO_MODE_ENGINE_BUSY is
set, waiting for VIDEO_DONE and sleeping 2-4 ms ("to skip BLLP") was
written to advance past the current BLLP into the next active video frame
before writing REG_DSI_TRIG_DMA, so the transfer is queued for the start
of the following BLLP rather than triggered mid-BLLP.

Gating this early return on DSI 6G >= v1.2 conflates the command-mode
MDP idle gate with video-mode BLLP arbitration, removes the wait without
accounting for triggering TRIGGER_SW mid-BLLP, leaves DSI v2 and
DSI 6G < v1.2 with the two-frame wait, and references the removed
dsi_ctrl_config() function in the comment.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261129000502.983904-1-vlwwwwww@gmail.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/msm/dsi: skip dsi_wait4video_eng_busy() when BLOCK_DMA_WITHIN_FRAME is set
  2026-11-29  0:19 ` sashiko-bot
@ 2026-11-29  1:14   ` Vladimir Bely
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Bely @ 2026-11-29  1:14 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	David Airlie, Simona Vetter, linux-arm-msm, dri-devel, freedreno,
	linux-kernel, Vladimir Bely

Thanks for the review. Indeed, BLOCK_DMA_WITHIN_FRAME arbitrates
command-mode MDP vs DMA rather than video-mode BLLP, so gating the
video-mode wait on it is wrong and skipping dsi_wait4video_eng_busy()
unconditionally would risk triggering DMA near the end of BLLP on
other video-mode panels (and dsi_ctrl_config() was renamed to
dsi_ctrl_enable()).

Please drop this patch.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30 15:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  0:05 [PATCH] drm/msm/dsi: skip dsi_wait4video_eng_busy() when BLOCK_DMA_WITHIN_FRAME is set Vladimir Bely
2026-11-29  0:19 ` sashiko-bot
2026-11-29  1:14   ` Vladimir Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox