meta-agl-core: add Upstream-Status tag to patches
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston / 0001-backend-drm-make-sure-all-buffers-are-released-when-.patch
1 From 6d9e9dfa0479abc0ed7921a4ebf42228c0da7533 Mon Sep 17 00:00:00 2001
2 From: Michael Olbrich <m.olbrich@pengutronix.de>
3 Date: Wed, 22 Jun 2022 08:58:21 +0200
4 Subject: [PATCH] backend-drm: make sure all buffers are released when an
5  output is removed
6
7 When an output is destroyed then the output state is freed immediately. In this
8 case, the plane state is only partially destroyed because it is the currently
9 active state. This includes the buffer reference.
10
11 Without the output, the plane will not be updated any more until it is used by a
12 different output (if possible) or the output returns and the plane is used
13 again.
14 As a result, the buffer reference is kept for a long time. This will cause some
15 applications to stall because weston now keeps two buffers (the one here and
16 another one for a different output where the application is now displayed).
17
18 To avoid this, do a synchronous commit that disables the output. The output
19 needs to be disabled anyways and this way the current state contains no
20 buffers that would remain.
21
22 `device->state_invalid = true` in drm_output_detach_crtc() is no longer
23 needed, because drm_output_detach_crtc() is called only when initialization
24 failed and the crtc was not yet used or in drm_output_deinit() when the
25 crtc was already disabled with the new synchronous commit.
26
27 Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
28 (cherry picked from commit f5a4fb5abcb8aeb6b078b6235834cc4ab6176c26)
29
30 Upstream-Status: Pending
31
32 ---
33  libweston/backend-drm/drm.c | 10 +++++++---
34  1 file changed, 7 insertions(+), 3 deletions(-)
35
36 diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
37 index 42787702..8425b0e9 100644
38 --- a/libweston/backend-drm/drm.c
39 +++ b/libweston/backend-drm/drm.c
40 @@ -1769,14 +1769,11 @@ drm_output_attach_crtc(struct drm_output *output)
41  static void
42  drm_output_detach_crtc(struct drm_output *output)
43  {
44 -       struct drm_backend *b = output->backend;
45         struct drm_crtc *crtc = output->crtc;
46  
47         crtc->output = NULL;
48         output->crtc = NULL;
49  
50 -       /* Force resetting unused CRTCs */
51 -       b->state_invalid = true;
52  }
53  
54  static int
55 @@ -1839,6 +1836,13 @@ drm_output_deinit(struct weston_output *base)
56  {
57         struct drm_output *output = to_drm_output(base);
58         struct drm_backend *b = to_drm_backend(base->compositor);
59 +       struct drm_pending_state *pending;
60 +
61 +       if (!b->shutting_down) {
62 +               pending = drm_pending_state_alloc(b);
63 +               drm_output_get_disable_state(pending, output);
64 +               drm_pending_state_apply_sync(pending);
65 +       }
66  
67         if (b->use_pixman)
68                 drm_output_fini_pixman(output);
69 -- 
70 2.39.2
71