dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/fb-helper: flush damage before unblanking
@ 2026-11-12  9:16 Angelo Compagnucci
  2026-11-13  9:03 ` Thomas Zimmermann
  2026-11-13 11:07 ` [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank Angelo Compagnucci
  0 siblings, 2 replies; 7+ messages in thread
From: Angelo Compagnucci @ 2026-11-12  9:16 UTC (permalink / raw)
  To: Thomas Zimmermann, Maarten Lankhorst, Maxime Ripard, dri-devel
  Cc: David Airlie, Simona Vetter, Javier Martinez Canillas,
	Angelo Compagnucci

With a shadow buffer and deferred I/O, what userspace draws in fbdev
reaches the DRM framebuffer only once the deferred I/O work and then the
damage work have run. Unblanking turns the display on with the
framebuffer as it is: a program drawing its first picture and then
unblanking, such as a boot splash taking over the picture a bootloader
left on a panel, shows the previous framebuffer contents for a moment.

Seen on an Arietta G25 with an ILI9341 panel (tinydrm ili9341): enabling
the pipe sends the whole framebuffer to the panel, still black, and the
splash only replaces it once the damage work runs, a visible flicker.

On unblank, flush the deferred I/O and the damage work first.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
 drivers/gpu/drm/clients/drm_fbdev_helper.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/clients/drm_fbdev_helper.c b/drivers/gpu/drm/clients/drm_fbdev_helper.c
index 415764ee086a..5c584dee3e55 100644
--- a/drivers/gpu/drm/clients/drm_fbdev_helper.c
+++ b/drivers/gpu/drm/clients/drm_fbdev_helper.c
@@ -150,6 +150,22 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
 	mutex_unlock(&fb_helper->lock);
 }
 
+/*
+ * Turning a display on sends it the framebuffer: first get there what was
+ * drawn in fbdev, still pending in deferred I/O or damage handling, else the
+ * display shows the framebuffer as it was before for a moment.
+ */
+static void drm_fb_helper_flush_damage(struct fb_info *info)
+{
+	struct drm_fb_helper *helper = info->par;
+
+#ifdef CONFIG_FB_DEFERRED_IO
+	if (info->fbdefio)
+		flush_delayed_work(&info->deferred_work);
+#endif
+	flush_work(&helper->damage_work);
+}
+
 /**
  * drm_fb_helper_blank - implementation for &fb_ops.fb_blank
  * @blank: desired blanking state
@@ -163,6 +179,7 @@ int drm_fb_helper_blank(int blank, struct fb_info *info)
 	switch (blank) {
 	/* Display: On; HSync: On, VSync: On */
 	case FB_BLANK_UNBLANK:
+		drm_fb_helper_flush_damage(info);
 		drm_fb_helper_dpms(info, DRM_MODE_DPMS_ON);
 		break;
 	/* Display: Off; HSync: On, VSync: On */
-- 
2.53.0


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

* Re: [PATCH] drm/fb-helper: flush damage before unblanking
  2026-11-12  9:16 [PATCH] drm/fb-helper: flush damage before unblanking Angelo Compagnucci
@ 2026-11-13  9:03 ` Thomas Zimmermann
  2026-11-13 11:07 ` [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank Angelo Compagnucci
  1 sibling, 0 replies; 7+ messages in thread
From: Thomas Zimmermann @ 2026-11-13  9:03 UTC (permalink / raw)
  To: Angelo Compagnucci, Maarten Lankhorst, Maxime Ripard, dri-devel
  Cc: David Airlie, Simona Vetter, Javier Martinez Canillas

Hi

Am 12.11.26 um 10:16 schrieb Angelo Compagnucci:
> With a shadow buffer and deferred I/O, what userspace draws in fbdev
> reaches the DRM framebuffer only once the deferred I/O work and then the
> damage work have run. Unblanking turns the display on with the
> framebuffer as it is: a program drawing its first picture and then
> unblanking, such as a boot splash taking over the picture a bootloader
> left on a panel, shows the previous framebuffer contents for a moment.
>
> Seen on an Arietta G25 with an ILI9341 panel (tinydrm ili9341): enabling
> the pipe sends the whole framebuffer to the panel, still black, and the
> splash only replaces it once the damage work runs, a visible flicker.
>
> On unblank, flush the deferred I/O and the damage work first.
>
> Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
> ---
>   drivers/gpu/drm/clients/drm_fbdev_helper.c | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
>
> diff --git a/drivers/gpu/drm/clients/drm_fbdev_helper.c b/drivers/gpu/drm/clients/drm_fbdev_helper.c
> index 415764ee086a..5c584dee3e55 100644
> --- a/drivers/gpu/drm/clients/drm_fbdev_helper.c
> +++ b/drivers/gpu/drm/clients/drm_fbdev_helper.c
> @@ -150,6 +150,22 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
>   	mutex_unlock(&fb_helper->lock);
>   }
>   
> +/*
> + * Turning a display on sends it the framebuffer: first get there what was
> + * drawn in fbdev, still pending in deferred I/O or damage handling, else the
> + * display shows the framebuffer as it was before for a moment.
> + */
> +static void drm_fb_helper_flush_damage(struct fb_info *info)
> +{
> +	struct drm_fb_helper *helper = info->par;
> +
> +#ifdef CONFIG_FB_DEFERRED_IO
> +	if (info->fbdefio)
> +		flush_delayed_work(&info->deferred_work);
> +#endif
> +	flush_work(&helper->damage_work);
> +}
> +
>   /**
>    * drm_fb_helper_blank - implementation for &fb_ops.fb_blank
>    * @blank: desired blanking state
> @@ -163,6 +179,7 @@ int drm_fb_helper_blank(int blank, struct fb_info *info)
>   	switch (blank) {
>   	/* Display: On; HSync: On, VSync: On */
>   	case FB_BLANK_UNBLANK:
> +		drm_fb_helper_flush_damage(info);
>   		drm_fb_helper_dpms(info, DRM_MODE_DPMS_ON);

I think there's no guarantee that we can flush anything before 
unblanking the display.

Best regards
Thomas

>   		break;
>   	/* Display: Off; HSync: On, VSync: On */

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



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

* [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank
  2026-11-12  9:16 [PATCH] drm/fb-helper: flush damage before unblanking Angelo Compagnucci
  2026-11-13  9:03 ` Thomas Zimmermann
@ 2026-11-13 11:07 ` Angelo Compagnucci
  2026-11-14 16:38   ` sashiko-bot
                     ` (2 more replies)
  1 sibling, 3 replies; 7+ messages in thread
From: Angelo Compagnucci @ 2026-11-13 11:07 UTC (permalink / raw)
  To: Thomas Zimmermann, Maarten Lankhorst, Maxime Ripard, dri-devel
  Cc: David Airlie, Simona Vetter, Javier Martinez Canillas,
	Angelo Compagnucci

With a shadow buffer, what userspace draws in fbdev reaches the
framebuffer memory only when the damage worker runs. Turning the display
on shows the framebuffer memory as it is. So a program that draws its
first picture and then unblanks, such as a boot splash, shows an older
picture for a moment.

Seen on an ILI9341 panel (tinydrm ili9341): enabling the pipe sends the
whole framebuffer memory to the panel, still black, and the splash only
replaces it once the damage worker runs.

Nothing can be flushed to a display that is off. But the copy from the
shadow buffer into the framebuffer memory does not need the display. On
unblank, copy the whole shadow buffer into the framebuffer memory before
turning the display on. The damage worker still flushes the damage once
the display is on.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changes v1 -> v2:
  - Do not flush the damage before unblanking: nothing can reach a
    display that is off. Instead, in fbdev-dma, copy the whole shadow
    buffer into the framebuffer memory on unblank, which needs no
    display [Thomas Zimmermann]
  - The fbdev helpers are unchanged, so the title changed too; v1 was
    "drm/fb-helper: flush damage before unblanking"

 drivers/gpu/drm/drm_fbdev_dma.c | 44 ++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
index 452f84400350..cc8813538bd9 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -93,15 +93,6 @@ static void drm_fbdev_dma_shadowed_fb_destroy(struct fb_info *info)
 	drm_client_release(&fb_helper->client);
 }
 
-static const struct fb_ops drm_fbdev_dma_shadowed_fb_ops = {
-	.owner = THIS_MODULE,
-	.fb_open = drm_fbdev_dma_fb_open,
-	.fb_release = drm_fbdev_dma_fb_release,
-	FB_DEFAULT_DEFERRED_OPS(drm_fbdev_dma_shadowed),
-	DRM_FB_HELPER_DEFAULT_OPS,
-	.fb_destroy = drm_fbdev_dma_shadowed_fb_destroy,
-};
-
 /*
  * struct drm_fb_helper
  */
@@ -196,6 +187,41 @@ static const struct drm_fb_helper_funcs drm_fbdev_dma_helper_funcs = {
  * struct drm_fb_helper
  */
 
+static int drm_fbdev_dma_shadowed_fb_blank(int blank, struct fb_info *info)
+{
+	struct drm_fb_helper *fb_helper = info->par;
+	struct drm_clip_rect clip = {
+		.x2 = fb_helper->fb->width,
+		.y2 = fb_helper->fb->height,
+	};
+
+	/*
+	 * Turning the display on shows the framebuffer memory. Copy the
+	 * shadow buffer into it first, so it holds what was drawn. This
+	 * does not need the display; the damage worker still flushes the
+	 * damage once the display is on.
+	 */
+	if (blank == FB_BLANK_UNBLANK)
+		drm_fbdev_dma_damage_blit(fb_helper, &clip);
+
+	return drm_fb_helper_blank(blank, info);
+}
+
+static const struct fb_ops drm_fbdev_dma_shadowed_fb_ops = {
+	.owner = THIS_MODULE,
+	.fb_open = drm_fbdev_dma_fb_open,
+	.fb_release = drm_fbdev_dma_fb_release,
+	FB_DEFAULT_DEFERRED_OPS(drm_fbdev_dma_shadowed),
+	/* DRM_FB_HELPER_DEFAULT_OPS, with a blank that copies the shadow */
+	.fb_check_var = drm_fb_helper_check_var,
+	.fb_set_par = drm_fb_helper_set_par,
+	.fb_setcmap = drm_fb_helper_setcmap,
+	.fb_blank = drm_fbdev_dma_shadowed_fb_blank,
+	.fb_pan_display = drm_fb_helper_pan_display,
+	.fb_ioctl = drm_fb_helper_ioctl,
+	.fb_destroy = drm_fbdev_dma_shadowed_fb_destroy,
+};
+
 static int drm_fbdev_dma_driver_fbdev_probe_tail(struct drm_fb_helper *fb_helper,
 						 struct drm_fb_helper_surface_size *sizes)
 {
-- 
2.53.0


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

* Re: [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank
  2026-11-13 11:07 ` [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank Angelo Compagnucci
@ 2026-11-14 16:38   ` sashiko-bot
  2026-11-14 20:13   ` [PATCH v3] " Angelo Compagnucci
  2026-11-16  7:48   ` [PATCH v2] " Thomas Zimmermann
  2 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-14 16:38 UTC (permalink / raw)
  To: Angelo Compagnucci, dri-devel

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/fbdev-dma: sleeping lock in
  drm_fbdev_dma_shadowed_fb_blank() on oops
- [Low] drm/fbdev-dma: missing Fixes trailer for shadow buffer unblank
  fix
--

commit a63597b4af664e3cb6d1b39bfd1dd1e573a6fdb2
Author: Angelo Compagnucci <angelo.compagnucci@gmail.com>

> drm/fbdev-dma: Copy the shadow buffer on unblank
>
> With a shadow buffer, what userspace draws in fbdev reaches the
> framebuffer memory only when the damage worker runs. Turning the display
> on shows the framebuffer memory as it is. So a program that draws its
> first picture and then unblanks, such as a boot splash, shows an older
> picture for a moment.
>
> Seen on an ILI9341 panel (tinydrm ili9341): enabling the pipe sends the
> whole framebuffer memory to the panel, still black, and the splash only
> replaces it once the damage worker runs.
>
> Nothing can be flushed to a display that is off. But the copy from the
> shadow buffer into the framebuffer memory does not need the display. On
> unblank, copy the whole shadow buffer into the framebuffer memory before
> turning the display on. The damage worker still flushes the damage once
> the display is on.
>
> Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>

[Severity: Low]
This fixes a bug introduced with shadow buffering.  Should the commit
message include a Fixes tag?

  Fixes: 360399643299 ("drm/fbdev-dma: Add shadow buffering for deferred I/O")

> diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
> index 452f844003504..cc8813538bd90 100644
> --- a/drivers/gpu/drm/drm_fbdev_dma.c
> +++ b/drivers/gpu/drm/drm_fbdev_dma.c

[ ... ]

> @@ -196,6 +187,41 @@ static const struct drm_fb_helper_funcs drm_fbdev_dma_helper_funcs = {
>   * struct drm_fb_helper
>   */
>  
> +static int drm_fbdev_dma_shadowed_fb_blank(int blank, struct fb_info *info)
> +{
> +	struct drm_fb_helper *fb_helper = info->par;
> +	struct drm_clip_rect clip = {
> +		.x2 = fb_helper->fb->width,
> +		.y2 = fb_helper->fb->height,
> +	};
> +
> +	/*
> +	 * Turning the display on shows the framebuffer memory. Copy the
> +	 * shadow buffer into it first, so it holds what was drawn. This
> +	 * does not need the display; the damage worker still flushes the
> +	 * damage once the display is on.
> +	 */
> +	if (blank == FB_BLANK_UNBLANK)
> +		drm_fbdev_dma_damage_blit(fb_helper, &clip);
> +
> +	return drm_fb_helper_blank(blank, info);
> +}

[Severity: Medium]
Can calling drm_fbdev_dma_damage_blit() before checking oops_in_progress
sleep in atomic context or deadlock during an oops or panic?

When the VT console is blanked during an oops or panic, bust_spinlocks(0)
and panic() call console_unblank() -> ... -> fb_blank(info,
FB_BLANK_UNBLANK) with oops_in_progress set and interrupts disabled.
drm_fb_helper_blank() guards against this at entry:

drivers/gpu/drm/clients/drm_fbdev_helper.c:drm_fb_helper_blank() {
	if (oops_in_progress)
		return -EBUSY;
    ...
}

Calling drm_fbdev_dma_damage_blit() before reaching that check
unconditionally acquires the sleeping mutex fb_helper->lock, which sleeps in
atomic context and can deadlock if the crashing context or a stopped CPU
already holds fb_helper->lock.

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

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

* [PATCH v3] drm/fbdev-dma: Copy the shadow buffer on unblank
  2026-11-13 11:07 ` [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank Angelo Compagnucci
  2026-11-14 16:38   ` sashiko-bot
@ 2026-11-14 20:13   ` Angelo Compagnucci
  2026-11-16  9:11     ` sashiko-bot
  2026-11-16  7:48   ` [PATCH v2] " Thomas Zimmermann
  2 siblings, 1 reply; 7+ messages in thread
From: Angelo Compagnucci @ 2026-11-14 20:13 UTC (permalink / raw)
  To: Thomas Zimmermann, Maarten Lankhorst, Maxime Ripard, dri-devel
  Cc: David Airlie, Simona Vetter, Javier Martinez Canillas,
	Angelo Compagnucci

With a shadow buffer, what userspace draws in fbdev reaches the
framebuffer memory only when the damage worker runs. Turning the display
on shows the framebuffer memory as it is. So a program that draws its
first picture and then unblanks, such as a boot splash, shows an older
picture for a moment.

Seen on an ILI9341 panel (tinydrm ili9341): enabling the pipe sends the
whole framebuffer memory to the panel, still black, and the splash only
replaces it once the damage worker runs.

Nothing can be flushed to a display that is off. But the copy from the
shadow buffer into the framebuffer memory does not need the display. On
unblank, copy the whole shadow buffer into the framebuffer memory before
turning the display on. The damage worker still flushes the damage once
the display is on.

The copy takes a mutex. Skip it during an oops, when the console is
unblanked in atomic context: drm_fb_helper_blank() does nothing then.

Fixes: 360399643299 ("drm/fbdev-dma: Add shadow buffering for deferred I/O")
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changes v2 -> v3:
  - Skip the copy during an oops: it takes a mutex, and the console is
    then unblanked in atomic context [Sashiko AI review]
  - Add the Fixes tag [Sashiko AI review]

Changes v1 -> v2:
  - Do not flush the damage before unblanking: nothing can reach a
    display that is off. Instead, in fbdev-dma, copy the whole shadow
    buffer into the framebuffer memory on unblank, which needs no
    display [Thomas Zimmermann]
  - The fbdev helpers are unchanged, so the title changed too; v1 was
    "drm/fb-helper: flush damage before unblanking"

 drivers/gpu/drm/drm_fbdev_dma.c | 48 ++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
index 452f84400350..3effc5c05d9c 100644
--- a/drivers/gpu/drm/drm_fbdev_dma.c
+++ b/drivers/gpu/drm/drm_fbdev_dma.c
@@ -93,15 +93,6 @@ static void drm_fbdev_dma_shadowed_fb_destroy(struct fb_info *info)
 	drm_client_release(&fb_helper->client);
 }
 
-static const struct fb_ops drm_fbdev_dma_shadowed_fb_ops = {
-	.owner = THIS_MODULE,
-	.fb_open = drm_fbdev_dma_fb_open,
-	.fb_release = drm_fbdev_dma_fb_release,
-	FB_DEFAULT_DEFERRED_OPS(drm_fbdev_dma_shadowed),
-	DRM_FB_HELPER_DEFAULT_OPS,
-	.fb_destroy = drm_fbdev_dma_shadowed_fb_destroy,
-};
-
 /*
  * struct drm_fb_helper
  */
@@ -196,6 +187,45 @@ static const struct drm_fb_helper_funcs drm_fbdev_dma_helper_funcs = {
  * struct drm_fb_helper
  */
 
+static int drm_fbdev_dma_shadowed_fb_blank(int blank, struct fb_info *info)
+{
+	struct drm_fb_helper *fb_helper = info->par;
+	struct drm_clip_rect clip = {
+		.x2 = fb_helper->fb->width,
+		.y2 = fb_helper->fb->height,
+	};
+
+	/*
+	 * Turning the display on shows the framebuffer memory. Copy the
+	 * shadow buffer into it first, so it holds what was drawn. This
+	 * does not need the display; the damage worker still flushes the
+	 * damage once the display is on.
+	 *
+	 * The copy takes a mutex, so skip it during an oops, where the
+	 * console is unblanked in atomic context. drm_fb_helper_blank()
+	 * does nothing then.
+	 */
+	if (blank == FB_BLANK_UNBLANK && !oops_in_progress)
+		drm_fbdev_dma_damage_blit(fb_helper, &clip);
+
+	return drm_fb_helper_blank(blank, info);
+}
+
+static const struct fb_ops drm_fbdev_dma_shadowed_fb_ops = {
+	.owner = THIS_MODULE,
+	.fb_open = drm_fbdev_dma_fb_open,
+	.fb_release = drm_fbdev_dma_fb_release,
+	FB_DEFAULT_DEFERRED_OPS(drm_fbdev_dma_shadowed),
+	/* DRM_FB_HELPER_DEFAULT_OPS, with a blank that copies the shadow */
+	.fb_check_var = drm_fb_helper_check_var,
+	.fb_set_par = drm_fb_helper_set_par,
+	.fb_setcmap = drm_fb_helper_setcmap,
+	.fb_blank = drm_fbdev_dma_shadowed_fb_blank,
+	.fb_pan_display = drm_fb_helper_pan_display,
+	.fb_ioctl = drm_fb_helper_ioctl,
+	.fb_destroy = drm_fbdev_dma_shadowed_fb_destroy,
+};
+
 static int drm_fbdev_dma_driver_fbdev_probe_tail(struct drm_fb_helper *fb_helper,
 						 struct drm_fb_helper_surface_size *sizes)
 {
-- 
2.53.0


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

* Re: [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank
  2026-11-13 11:07 ` [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank Angelo Compagnucci
  2026-11-14 16:38   ` sashiko-bot
  2026-11-14 20:13   ` [PATCH v3] " Angelo Compagnucci
@ 2026-11-16  7:48   ` Thomas Zimmermann
  2 siblings, 0 replies; 7+ messages in thread
From: Thomas Zimmermann @ 2026-11-16  7:48 UTC (permalink / raw)
  To: Angelo Compagnucci, Maarten Lankhorst, Maxime Ripard, dri-devel
  Cc: David Airlie, Simona Vetter, Javier Martinez Canillas

Hi

Am 13.11.26 um 12:07 schrieb Angelo Compagnucci:
> With a shadow buffer, what userspace draws in fbdev reaches the
> framebuffer memory only when the damage worker runs. Turning the display
> on shows the framebuffer memory as it is. So a program that draws its
> first picture and then unblanks, such as a boot splash, shows an older
> picture for a moment.
>
> Seen on an ILI9341 panel (tinydrm ili9341): enabling the pipe sends the
> whole framebuffer memory to the panel, still black, and the splash only
> replaces it once the damage worker runs.
>
> Nothing can be flushed to a display that is off. But the copy from the
> shadow buffer into the framebuffer memory does not need the display. On
> unblank, copy the whole shadow buffer into the framebuffer memory before
> turning the display on. The damage worker still flushes the damage once
> the display is on.
>
> Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
> ---
> Changes v1 -> v2:
>    - Do not flush the damage before unblanking: nothing can reach a
>      display that is off. Instead, in fbdev-dma, copy the whole shadow
>      buffer into the framebuffer memory on unblank, which needs no
>      display [Thomas Zimmermann]

That's not really the issue. There's hardware/drivers where we need the 
CRTC to be switched on before we can transfer display data. Search 
drm_atomic_helper_commit_tail_rpm() [1] for that. IDK how much of a 
problem this is in practice. Flushing buffers on such a system might 
give actual errors instead of just some temporary display noise.

What exactly are you trying to achieve?

[1] 
https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/drm_atomic_helper.c#L2009

Best regards
Thomas


>    - The fbdev helpers are unchanged, so the title changed too; v1 was
>      "drm/fb-helper: flush damage before unblanking"
>
>   drivers/gpu/drm/drm_fbdev_dma.c | 44 ++++++++++++++++++++++++++-------
>   1 file changed, 35 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
> index 452f84400350..cc8813538bd9 100644
> --- a/drivers/gpu/drm/drm_fbdev_dma.c
> +++ b/drivers/gpu/drm/drm_fbdev_dma.c
> @@ -93,15 +93,6 @@ static void drm_fbdev_dma_shadowed_fb_destroy(struct fb_info *info)
>   	drm_client_release(&fb_helper->client);
>   }
>   
> -static const struct fb_ops drm_fbdev_dma_shadowed_fb_ops = {
> -	.owner = THIS_MODULE,
> -	.fb_open = drm_fbdev_dma_fb_open,
> -	.fb_release = drm_fbdev_dma_fb_release,
> -	FB_DEFAULT_DEFERRED_OPS(drm_fbdev_dma_shadowed),
> -	DRM_FB_HELPER_DEFAULT_OPS,
> -	.fb_destroy = drm_fbdev_dma_shadowed_fb_destroy,
> -};
> -
>   /*
>    * struct drm_fb_helper
>    */
> @@ -196,6 +187,41 @@ static const struct drm_fb_helper_funcs drm_fbdev_dma_helper_funcs = {
>    * struct drm_fb_helper
>    */
>   
> +static int drm_fbdev_dma_shadowed_fb_blank(int blank, struct fb_info *info)
> +{
> +	struct drm_fb_helper *fb_helper = info->par;
> +	struct drm_clip_rect clip = {
> +		.x2 = fb_helper->fb->width,
> +		.y2 = fb_helper->fb->height,
> +	};
> +
> +	/*
> +	 * Turning the display on shows the framebuffer memory. Copy the
> +	 * shadow buffer into it first, so it holds what was drawn. This
> +	 * does not need the display; the damage worker still flushes the
> +	 * damage once the display is on.
> +	 */
> +	if (blank == FB_BLANK_UNBLANK)
> +		drm_fbdev_dma_damage_blit(fb_helper, &clip);
> +
> +	return drm_fb_helper_blank(blank, info);
> +}
> +
> +static const struct fb_ops drm_fbdev_dma_shadowed_fb_ops = {
> +	.owner = THIS_MODULE,
> +	.fb_open = drm_fbdev_dma_fb_open,
> +	.fb_release = drm_fbdev_dma_fb_release,
> +	FB_DEFAULT_DEFERRED_OPS(drm_fbdev_dma_shadowed),
> +	/* DRM_FB_HELPER_DEFAULT_OPS, with a blank that copies the shadow */
> +	.fb_check_var = drm_fb_helper_check_var,
> +	.fb_set_par = drm_fb_helper_set_par,
> +	.fb_setcmap = drm_fb_helper_setcmap,
> +	.fb_blank = drm_fbdev_dma_shadowed_fb_blank,
> +	.fb_pan_display = drm_fb_helper_pan_display,
> +	.fb_ioctl = drm_fb_helper_ioctl,
> +	.fb_destroy = drm_fbdev_dma_shadowed_fb_destroy,
> +};
> +
>   static int drm_fbdev_dma_driver_fbdev_probe_tail(struct drm_fb_helper *fb_helper,
>   						 struct drm_fb_helper_surface_size *sizes)
>   {

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



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

* Re: [PATCH v3] drm/fbdev-dma: Copy the shadow buffer on unblank
  2026-11-14 20:13   ` [PATCH v3] " Angelo Compagnucci
@ 2026-11-16  9:11     ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-16  9:11 UTC (permalink / raw)
  To: Angelo Compagnucci, dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/fbdev-dma: unaddressed v2 review on
  drm_fbdev_dma_shadowed_fb_blank()
--

commit 7dc07a1feeaa7bfcabe7b06bf9f13b3b3f41fd0e
Author: Angelo Compagnucci <angelo.compagnucci@gmail.com>

drm/fbdev-dma: Copy the shadow buffer on unblank

This commit adds a custom .fb_blank callback for shadowed fbdev-dma
framebuffers that copies the shadow buffer into the GEM DMA buffer on
FB_BLANK_UNBLANK before calling drm_fb_helper_blank().

> diff --git a/drivers/gpu/drm/drm_fbdev_dma.c b/drivers/gpu/drm/drm_fbdev_dma.c
> index 452f844003504..3effc5c05d9ce 100644
> --- a/drivers/gpu/drm/drm_fbdev_dma.c
> +++ b/drivers/gpu/drm/drm_fbdev_dma.c

[ ... ]

> @@ -196,6 +187,45 @@ static const struct drm_fb_helper_funcs drm_fbdev_dma_helper_funcs = {
>   * struct drm_fb_helper
>   */
>  
> +static int drm_fbdev_dma_shadowed_fb_blank(int blank, struct fb_info *info)
> +{
> +	struct drm_fb_helper *fb_helper = info->par;
> +	struct drm_clip_rect clip = {
> +		.x2 = fb_helper->fb->width,
> +		.y2 = fb_helper->fb->height,
> +	};
> +
> +	/*
> +	 * Turning the display on shows the framebuffer memory. Copy the
> +	 * shadow buffer into it first, so it holds what was drawn. This
> +	 * does not need the display; the damage worker still flushes the
> +	 * damage once the display is on.
> +	 *
> +	 * The copy takes a mutex, so skip it during an oops, where the
> +	 * console is unblanked in atomic context. drm_fb_helper_blank()
> +	 * does nothing then.
> +	 */
> +	if (blank == FB_BLANK_UNBLANK && !oops_in_progress)
> +		drm_fbdev_dma_damage_blit(fb_helper, &clip);
> +
> +	return drm_fb_helper_blank(blank, info);
> +}

[Severity: Medium]
As reported by Thomas Zimmermann on v2 [1], does this comment and the
commit message accurately describe how unblanking and damage flushing
interact here?

In v2, Thomas Zimmermann noted in response to the v1 -> v2 changelog entry
that some hardware and drivers require the CRTC to be enabled before
display data can be transferred (as in drm_atomic_helper_commit_tail_rpm()),
and asked what problem this change is trying to solve.

In addition, on MIPI DBI drivers such as ili9341,
drm_fb_helper_blank(FB_BLANK_UNBLANK) -> drm_fb_helper_dpms() ->
drm_client_modeset_commit_atomic() enables the CRTC and immediately
commits the active planes with full-frame damage, which transfers the GEM
DMA buffer to the panel during drm_fb_helper_blank() itself rather than
waiting for the damage worker. If FB_BLANK_UNBLANK is called while
deferred I/O work is still pending, drm_fbdev_dma_shadowed_fb_blank()
copies the shadow buffer and the modeset flushes the full frame to the
panel, and then drm_fb_helper_damage_work() runs afterward and copies and
flushes the damaged area a second time.

[1] https://lore.kernel.org/r/556dd1ab-a1af-4c8b-be6e-04382ed0b958@suse.de

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

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

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

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12  9:16 [PATCH] drm/fb-helper: flush damage before unblanking Angelo Compagnucci
2026-11-13  9:03 ` Thomas Zimmermann
2026-11-13 11:07 ` [PATCH v2] drm/fbdev-dma: Copy the shadow buffer on unblank Angelo Compagnucci
2026-11-14 16:38   ` sashiko-bot
2026-11-14 20:13   ` [PATCH v3] " Angelo Compagnucci
2026-11-16  9:11     ` sashiko-bot
2026-11-16  7:48   ` [PATCH v2] " Thomas Zimmermann

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