bcm27xx: add kernel 5.10 support
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.10 / 950-0713-drm-gud-Free-buffers-on-device-removal.patch
1 From 888d867aa6f8fe384b37c0915eed07bb3a970fc4 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
3 Date: Thu, 1 Jul 2021 19:07:47 +0200
4 Subject: [PATCH] drm/gud: Free buffers on device removal
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 [ drm-misc commit f8ac863b6a93863334cefb94285daaa6617381b5 ]
10
11 Free transfer and compression buffers on device removal instead of at
12 DRM device removal time. This ensures that the usual 2x8MB buffers are
13 released when the device is unplugged and not kept around should
14 userspace keep the DRM device fd open.
15
16 At least Ubuntu 20.04 doesn't release the DRM device on unplug.
17
18 The damage_lock mutex is not destroyed because it is used outside the
19 drm_dev_enter/exit block in gud_pipe_update(). AFAICT it's possible for
20 an open fbdev descriptor to trigger a commit after the USB device is gone.
21
22 v2: Don't destroy damage_lock
23
24 Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
25 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
26 Link: https://patchwork.freedesktop.org/patch/msgid/20210701170748.58009-1-noralf@tronnes.org
27 ---
28 drivers/gpu/drm/gud/gud_drv.c | 9 +++++----
29 1 file changed, 5 insertions(+), 4 deletions(-)
30
31 --- a/drivers/gpu/drm/gud/gud_drv.c
32 +++ b/drivers/gpu/drm/gud/gud_drv.c
33 @@ -407,14 +407,15 @@ static struct drm_driver gud_drm_driver
34 .minor = 0,
35 };
36
37 -static void gud_free_buffers_and_mutex(struct drm_device *drm, void *unused)
38 +static void gud_free_buffers_and_mutex(void *data)
39 {
40 - struct gud_device *gdrm = to_gud_device(drm);
41 + struct gud_device *gdrm = data;
42
43 vfree(gdrm->compress_buf);
44 + gdrm->compress_buf = NULL;
45 kfree(gdrm->bulk_buf);
46 + gdrm->bulk_buf = NULL;
47 mutex_destroy(&gdrm->ctrl_lock);
48 - mutex_destroy(&gdrm->damage_lock);
49 }
50
51 static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id)
52 @@ -468,7 +469,7 @@ static int gud_probe(struct usb_interfac
53 INIT_WORK(&gdrm->work, gud_flush_work);
54 gud_clear_damage(gdrm);
55
56 - ret = drmm_add_action_or_reset(drm, gud_free_buffers_and_mutex, NULL);
57 + ret = devm_add_action(dev, gud_free_buffers_and_mutex, gdrm);
58 if (ret)
59 return ret;
60