950-0670-fbdev-Don-t-cancel-deferred-work-if-pagelist-empty.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From cf40d2d8c44a659d09d5c20189aab02f20263e81 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <[email protected]>
  3. Date: Wed, 29 Mar 2023 09:49:36 +0100
  4. Subject: [PATCH] fbdev: Don't cancel deferred work if pagelist empty
  5. Since [1], the fbdev deferred IO framework is careful to cancel
  6. pending updates on close to prevent dirty pages being accessed after
  7. they may have been reused. However, this is not necessary in the case
  8. that the pagelist is empty, and drivers that don't make use of the
  9. pagelist may have wanted updates cancelled for no good reason.
  10. Avoid penalising fbdev drivers that don't make use of the pagelist by
  11. making the cancelling of deferred IO on close conditional on there
  12. being a non-empty pagelist.
  13. See: https://github.com/raspberrypi/linux/issues/5398
  14. Signed-off-by: Phil Elwell <[email protected]>
  15. [1] 3efc61d95259 ("fbdev: Fix invalid page access after closing deferred I/O devices")
  16. ---
  17. drivers/video/fbdev/core/fb_defio.c | 3 ++-
  18. 1 file changed, 2 insertions(+), 1 deletion(-)
  19. --- a/drivers/video/fbdev/core/fb_defio.c
  20. +++ b/drivers/video/fbdev/core/fb_defio.c
  21. @@ -317,7 +317,8 @@ static void fb_deferred_io_lastclose(str
  22. struct page *page;
  23. int i;
  24. - flush_delayed_work(&info->deferred_work);
  25. + if (!list_empty(&info->fbdefio->pagereflist))
  26. + flush_delayed_work(&info->deferred_work);
  27. /* clear out the mapping that we setup */
  28. for (i = 0 ; i < info->fix.smem_len; i += PAGE_SIZE) {