The patch below does not apply to the 4.19-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <stable@xxxxxxxxxxxxxxx>. To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.19.y git checkout FETCH_HEAD git cherry-pick -x 33cd6ea9c0673517cdb06ad5c915c6f22e9615fc # <resolve conflicts, build, test, etc.> git commit -s git send-email --to '<stable@xxxxxxxxxxxxxxx>' --in-reply-to '2024012252-definite-jaywalker-4a8f@gregkh' --subject-prefix 'PATCH 4.19.y' HEAD^.. Possible dependencies: 33cd6ea9c067 ("fbdev: flush deferred IO before closing") fe9ae05cfbe5 ("fbdev: Fix incorrect page mapping clearance at fb_deferred_io_release()") 3efc61d95259 ("fbdev: Fix invalid page access after closing deferred I/O devices") e80eec1b871a ("fbdev: Rename pagelist to pagereflist for deferred I/O") 56c134f7f1b5 ("fbdev: Track deferred-I/O pages in pageref struct") 856082f021a2 ("fbdev: defio: fix the pagelist corruption") 8c30e2d81bfd ("fbdev: Don't sort deferred-I/O pages by default") 105a940416fc ("fbdev/defio: Early-out if page is already enlisted") 67b723f5b742 ("drm/fb-helper: Calculate damaged area in separate helper") aa15c677cc34 ("drm/fb-helper: Fix vertical damage clipping") a3c286dcef7f ("drm/fb-helper: Fix clip rectangle height") 0b78f8bcf495 ("Revert "fb_defio: Remove custom address_space_operations"") ccf953d8f3d6 ("fb_defio: Remove custom address_space_operations") 9622349ea1b6 ("drm/fb-helper: Rename dirty worker to damage worker") a102172c7f81 ("drm/fb-helper: Call dirty helper after writing to fbdev") 222ec45f4c69 ("drm/fb_helper: Support framebuffers in I/O memory") a85955568939 ("drm/gem: Store client buffer mappings as struct dma_buf_map") a745fb1c26d3 ("drm/gem: Update internal GEM vmap/vunmap interfaces to use struct dma_buf_map") 49a3f51dfeee ("drm/gem: Use struct dma_buf_map in GEM vmap ops and convert GEM backends") 1fc90559fdd5 ("drm/etnaviv: Remove empty etnaviv_gem_prime_vunmap()") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 33cd6ea9c0673517cdb06ad5c915c6f22e9615fc Mon Sep 17 00:00:00 2001 From: Nam Cao <namcao@xxxxxxxxxxxxx> Date: Mon, 18 Dec 2023 10:57:31 +0100 Subject: [PATCH] fbdev: flush deferred IO before closing When framebuffer gets closed, the queued deferred IO gets cancelled. This can cause some last display data to vanish. This is problematic for users who send a still image to the framebuffer, then close the file: the image may never appear. To ensure none of display data get lost, flush the queued deferred IO first before closing. Another possible solution is to delete the cancel_delayed_work_sync() instead. The difference is that the display may appear some time after closing. However, the clearing of page mapping after this needs to be removed too, because the page mapping is used by the deferred work. It is not completely obvious whether it is okay to not clear the page mapping. For a patch intended for stable trees, go with the simple and obvious solution. Fixes: 60b59beafba8 ("fbdev: mm: Deferred IO support") Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Nam Cao <namcao@xxxxxxxxxxxxx> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> Signed-off-by: Helge Deller <deller@xxxxxx> diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index 6c8b81c452f0..1ae1d35a5942 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c @@ -313,7 +313,7 @@ static void fb_deferred_io_lastclose(struct fb_info *info) struct page *page; int i; - cancel_delayed_work_sync(&info->deferred_work); + flush_delayed_work(&info->deferred_work); /* clear out the mapping that we setup */ for (i = 0 ; i < info->fix.smem_len; i += PAGE_SIZE) {