Il giorno lun 16 nov 2026 alle ore 08:48 Thomas Zimmermann < [email protected]> ha scritto:
> 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 <[email protected]> > > --- > > 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? > Thanks, I misread your remark on v1. The changelog and the commit message of v2 are wrong on this, and I will fix them. v2 does not transfer display data, though. The damage worker does two things in drm_fbdev_dma_helper_fb_dirty(): 1. drm_fbdev_dma_damage_blit(): a memcpy from the shadow buffer into the GEM buffer; 2. fb->funcs->dirty(): the call into the driver. On unblank, v2 calls only the first one. It does not call fb->funcs->dirty(), it commits nothing, and it touches no hardware. The damage worker already does this same copy whatever the state of the display, when userspace draws while the display is blanked. So I think a device that needs the CRTC on is not affected. Do you agree, or do I miss a case? > What exactly are you trying to achieve? A boot splash on a small SPI panel (ILI9341, tinydrm), through fbdev. The splash maps the framebuffer, draws its first frame while the display is still blanked, and then unblanks with FBIOBLANK. What happens today: 1. The frame is in the shadow buffer. The deferred I/O work is scheduled 50 ms later (fbdefio.delay = HZ / 20). 2. FBIOBLANK turns the CRTC on. The driver sends the GEM buffer to the panel and turns the backlight on. The GEM buffer is still black. 3. The deferred I/O and the damage work run, and the frame replaces the black picture. So the panel shows a black picture for a moment before the splash, a visible flash at each boot. The aim is that the first picture the panel shows after an unblank is the one that userspace drew before it. If you think this is better fixed somewhere else, I am happy to rework it. Best regards, Angelo > > [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) > > > -- Profile: http://it.linkedin.com/in/compagnucciangelo
