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