Blame SOURCES/handle-hotplug-better.patch

657d8e
From d442ef48412e3dc1b24a9f97b02ee3383404d501 Mon Sep 17 00:00:00 2001
657d8e
From: Emil Velikov <emil.velikov@collabora.com>
657d8e
Date: Wed, 12 Jun 2019 16:58:54 +0000
657d8e
Subject: [PATCH 1/8] renderer/native: add missing eglTerminate in EGLDevice
657d8e
 error path
657d8e
MIME-Version: 1.0
657d8e
Content-Type: text/plain; charset=UTF-8
657d8e
Content-Transfer-Encoding: 8bit
657d8e
657d8e
Currently the EGLDevice code gets the display and calls eglInitialize.
657d8e
As a follow-up it checks the required EGL extensions - technically it
657d8e
could check the EGL device extensions earlier.
657d8e
657d8e
In either case, eglTerminate is missing. Thus the connection to the
657d8e
display was still bound.
657d8e
657d8e
This was highlighted with Mesa commit d6edccee8da ("egl: add
657d8e
EGL_platform_device support") + amdgpu.
657d8e
657d8e
In that case, since the eglTerminate is missing, we end up reusing the
657d8e
underlying amdgpu_device due to some caching in libdrm_amdgpu. The
657d8e
latter in itself being a good solution since it allows buffer sharing
657d8e
across primary and render node of the same device.
657d8e
657d8e
Note: we should really get this in branches all the way back to 3.30.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/619
657d8e
657d8e
Fixes: 934184e23 ("MetaRendererNative: Add EGLDevice based rendering support")
657d8e
Cc: Jonas Ã…dahl <jadahl@gmail.com>
657d8e
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
657d8e
657d8e
657d8e
(cherry picked from commit 9213574870faee7fe40609791fc48f4b44f861c0)
657d8e
---
657d8e
 src/backends/native/meta-renderer-native.c | 1 +
657d8e
 1 file changed, 1 insertion(+)
657d8e
657d8e
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
657d8e
index dbfc97aae..207b654fa 100644
657d8e
--- a/src/backends/native/meta-renderer-native.c
657d8e
+++ b/src/backends/native/meta-renderer-native.c
657d8e
@@ -4038,6 +4038,7 @@ create_renderer_gpu_data_egl_device (MetaRendererNative  *renderer_native,
657d8e
                    G_IO_ERROR_FAILED,
657d8e
                    "Missing EGL extensions required for EGLDevice renderer: %s",
657d8e
                    missing_extensions_str);
657d8e
+      meta_egl_terminate (egl, egl_display, NULL);
657d8e
       g_free (missing_extensions_str);
657d8e
       g_free (missing_extensions);
657d8e
       return NULL;
657d8e
-- 
657d8e
2.24.1
657d8e
657d8e
657d8e
From e18dfc888343585d21b3f64568571009c4967a95 Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Mon, 17 Jun 2019 18:18:12 +0200
657d8e
Subject: [PATCH 2/8] renderer/native: Use g_set_error() instead of
657d8e
 _cogl_set_error()
657d8e
657d8e
It's even a GError, so lets use the proper API.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
657d8e
(cherry picked from commit 1efb32d3000ca06ee3cfcc146dc812866d243619)
657d8e
---
657d8e
 src/backends/native/meta-renderer-native.c | 2 +-
657d8e
 1 file changed, 1 insertion(+), 1 deletion(-)
657d8e
657d8e
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
657d8e
index 207b654fa..e7aa6f389 100644
657d8e
--- a/src/backends/native/meta-renderer-native.c
657d8e
+++ b/src/backends/native/meta-renderer-native.c
657d8e
@@ -1277,7 +1277,7 @@ meta_renderer_native_egl_context_created (CoglDisplay *cogl_display,
657d8e
                                       cogl_display_egl->dummy_surface,
657d8e
                                       cogl_display_egl->egl_context))
657d8e
     {
657d8e
-      _cogl_set_error (error, COGL_WINSYS_ERROR,
657d8e
+      g_set_error (error, COGL_WINSYS_ERROR,
657d8e
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
657d8e
                    "Failed to make context current");
657d8e
       return FALSE;
657d8e
-- 
657d8e
2.24.1
657d8e
657d8e
657d8e
From 1947a81db93624d57471ce1edf5548c7774c3569 Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Mon, 17 Jun 2019 18:18:42 +0200
657d8e
Subject: [PATCH 3/8] renderer/native: Make sure we're not destroying an active
657d8e
 EGLSurface
657d8e
657d8e
When making a new surface/context pair current, mesa may want to flush
657d8e
the old context. Make sure we don't try to flush any freed memory by
657d8e
unmaking a surface/context pair current before freeing it.
657d8e
657d8e
Not doing this results in the following valgrind warnings:
657d8e
657d8e
==15986== Invalid read of size 8
657d8e
==15986==    at 0x69A6D80: dri_flush_front_buffer (gbm_dri.c:92)
657d8e
==15986==    by 0x1750D458: intel_flush_front (brw_context.c:251)
657d8e
==15986==    by 0x1750D4BB: intel_glFlush (brw_context.c:296)
657d8e
==15986==    by 0x1739D8DD: dri2_make_current (egl_dri2.c:1461)
657d8e
==15986==    by 0x17393A3A: eglMakeCurrent (eglapi.c:869)
657d8e
==15986==    by 0x54381FB: InternalMakeCurrentVendor (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
657d8e
==15986==    by 0x5438515: eglMakeCurrent (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
657d8e
==15986==    by 0x522A782: _cogl_winsys_egl_make_current (cogl-winsys-egl.c:303)
657d8e
==15986==    by 0x49B64C8: meta_renderer_native_create_view (meta-renderer-native.c:3076)
657d8e
==15986==    by 0x48D26E7: meta_renderer_create_view (meta-renderer.c:78)
657d8e
==15986==    by 0x48D277A: meta_renderer_rebuild_views (meta-renderer.c:111)
657d8e
==15986==    by 0x49BF46E: meta_stage_native_rebuild_views (meta-stage-native.c:142)
657d8e
==15986==  Address 0x1b076600 is 0 bytes inside a block of size 48 free'd
657d8e
==15986==    at 0x4839A0C: free (vg_replace_malloc.c:540)
657d8e
==15986==    by 0x49B59F3: meta_renderer_native_release_onscreen (meta-renderer-native.c:2651)
657d8e
==15986==    by 0x5211441: _cogl_onscreen_free (cogl-onscreen.c:167)
657d8e
==15986==    by 0x5210D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
657d8e
==15986==    by 0x51D0066: _cogl_object_default_unref (cogl-object.c:103)
657d8e
==15986==    by 0x520F989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
657d8e
==15986==    by 0x51D00B1: cogl_object_unref (cogl-object.c:115)
657d8e
==15986==    by 0x536F3C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
657d8e
==15986==    by 0x4B7DAF2: g_object_unref (gobject.c:3309)
657d8e
==15986==    by 0x4A9596C: g_list_foreach (glist.c:1013)
657d8e
==15986==    by 0x4A9599A: g_list_free_full (glist.c:223)
657d8e
==15986==    by 0x48D2737: meta_renderer_rebuild_views (meta-renderer.c:100)
657d8e
==15986==  Block was alloc'd at
657d8e
==15986==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
657d8e
==15986==    by 0x69A76B2: gbm_dri_surface_create (gbm_dri.c:1252)
657d8e
==15986==    by 0x69A6BFE: gbm_surface_create (gbm.c:600)
657d8e
==15986==    by 0x49B4E29: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2221)
657d8e
==15986==    by 0x49B57DB: meta_onscreen_native_allocate (meta-renderer-native.c:2569)
657d8e
==15986==    by 0x49B6423: meta_renderer_native_create_view (meta-renderer-native.c:3062)
657d8e
==15986==    by 0x48D26E7: meta_renderer_create_view (meta-renderer.c:78)
657d8e
==15986==    by 0x48D277A: meta_renderer_rebuild_views (meta-renderer.c:111)
657d8e
==15986==    by 0x49BF46E: meta_stage_native_rebuild_views (meta-stage-native.c:142)
657d8e
==15986==    by 0x49A75B5: meta_backend_native_update_screen_size (meta-backend-native.c:520)
657d8e
==15986==    by 0x48B01BB: meta_backend_sync_screen_size (meta-backend.c:224)
657d8e
==15986==    by 0x48B09B7: meta_backend_real_post_init (meta-backend.c:501)
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
657d8e
(cherry picked from commit 56ddaaa3809240a357b5e19b5789d1aa49aaecc3)
657d8e
---
657d8e
 src/backends/native/meta-renderer-native.c | 13 +++++++++++++
657d8e
 1 file changed, 13 insertions(+)
657d8e
657d8e
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
657d8e
index e7aa6f389..b7bc3121a 100644
657d8e
--- a/src/backends/native/meta-renderer-native.c
657d8e
+++ b/src/backends/native/meta-renderer-native.c
657d8e
@@ -3040,6 +3040,8 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
657d8e
 {
657d8e
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
657d8e
   CoglContext *cogl_context = framebuffer->context;
657d8e
+  CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
657d8e
+  CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
657d8e
   CoglRenderer *cogl_renderer = cogl_context->display->renderer;
657d8e
   CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
657d8e
   CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
657d8e
@@ -3052,6 +3054,17 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
657d8e
 
657d8e
   onscreen_native = onscreen_egl->platform;
657d8e
 
657d8e
+  if (onscreen_egl->egl_surface != EGL_NO_SURFACE &&
657d8e
+      (cogl_display_egl->current_draw_surface == onscreen_egl->egl_surface ||
657d8e
+       cogl_display_egl->current_read_surface == onscreen_egl->egl_surface))
657d8e
+    {
657d8e
+      if (!_cogl_winsys_egl_make_current (cogl_display,
657d8e
+                                          cogl_display_egl->dummy_surface,
657d8e
+                                          cogl_display_egl->dummy_surface,
657d8e
+                                          cogl_display_egl->egl_context))
657d8e
+        g_warning ("Failed to clear current context");
657d8e
+    }
657d8e
+
657d8e
   g_list_free_full (onscreen_native->pending_page_flip_retries,
657d8e
                     (GDestroyNotify) retry_page_flip_data_free);
657d8e
   if (onscreen_native->retry_page_flips_source)
657d8e
-- 
657d8e
2.24.1
657d8e
657d8e
657d8e
From 60551e5e6f984a7ed3ba3339f027ed7b37f802c4 Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Mon, 17 Jun 2019 19:16:12 +0200
657d8e
Subject: [PATCH 4/8] renderer/native: Fix EGLSurface destruction order
657d8e
657d8e
Make sure to destroy the EGL surface after releasing held buffers,
657d8e
otherwise we'll get the following valgrind warnings:
657d8e
657d8e
==24016== Invalid read of size 8
657d8e
==24016==    at 0x1739943F: release_buffer (platform_drm.c:73)
657d8e
==24016==    by 0x49AC355: meta_drm_buffer_gbm_finalize (meta-drm-buffer-gbm.c:213)
657d8e
==24016==    by 0x4B75B61: g_object_unref (gobject.c:3346)
657d8e
==24016==    by 0x49B4B41: free_current_bo (meta-renderer-native.c:991)
657d8e
==24016==    by 0x49B816F: meta_renderer_native_release_onscreen (meta-renderer-native.c:2971)
657d8e
==24016==    by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167)
657d8e
==24016==    by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
657d8e
==24016==    by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103)
657d8e
==24016==    by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
657d8e
==24016==    by 0x51C80B1: cogl_object_unref (cogl-object.c:115)
657d8e
==24016==    by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
657d8e
==24016==    by 0x4B75AF2: g_object_unref (gobject.c:3309)
657d8e
==24016==  Address 0x18e742a8 is 536 bytes inside a block of size 784 free'd
657d8e
==24016==    at 0x4839A0C: free (vg_replace_malloc.c:540)
657d8e
==24016==    by 0x17399764: dri2_drm_destroy_surface (platform_drm.c:231)
657d8e
==24016==    by 0x1738550A: eglDestroySurface (eglapi.c:1145)
657d8e
==24016==    by 0x5440286: eglDestroySurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
657d8e
==24016==    by 0x49613A5: meta_egl_destroy_surface (meta-egl.c:432)
657d8e
==24016==    by 0x49B80F9: meta_renderer_native_release_onscreen (meta-renderer-native.c:2954)
657d8e
==24016==    by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167)
657d8e
==24016==    by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
657d8e
==24016==    by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103)
657d8e
==24016==    by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
657d8e
==24016==    by 0x51C80B1: cogl_object_unref (cogl-object.c:115)
657d8e
==24016==    by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
657d8e
==24016==  Block was alloc'd at
657d8e
==24016==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
657d8e
==24016==    by 0x173997AE: dri2_drm_create_window_surface (platform_drm.c:145)
657d8e
==24016==    by 0x17388906: _eglCreateWindowSurfaceCommon (eglapi.c:929)
657d8e
==24016==    by 0x5440197: eglCreateWindowSurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
657d8e
==24016==    by 0x49612FF: meta_egl_create_window_surface (meta-egl.c:396)
657d8e
==24016==    by 0x49B752E: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2538)
657d8e
==24016==    by 0x49B7E6C: meta_onscreen_native_allocate (meta-renderer-native.c:2870)
657d8e
==24016==    by 0x49B8BCF: meta_renderer_native_create_view (meta-renderer-native.c:3387)
657d8e
==24016==    by 0x48D274B: meta_renderer_create_view (meta-renderer.c:78)
657d8e
==24016==    by 0x48D27DE: meta_renderer_rebuild_views (meta-renderer.c:111)
657d8e
==24016==    by 0x49BB4FB: meta_stage_native_rebuild_views (meta-stage-native.c:142)
657d8e
==24016==    by 0x49A733C: meta_backend_native_update_screen_size (meta-backend-native.c:517)
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/622
657d8e
(cherry picked from commit d9fb11b04319c00fd89715dd9207fe54e1d18c2d)
657d8e
---
657d8e
 src/backends/native/meta-renderer-native.c | 38 +++++++++++++++-------
657d8e
 1 file changed, 27 insertions(+), 11 deletions(-)
657d8e
657d8e
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
657d8e
index b7bc3121a..62c27c191 100644
657d8e
--- a/src/backends/native/meta-renderer-native.c
657d8e
+++ b/src/backends/native/meta-renderer-native.c
657d8e
@@ -3035,6 +3035,28 @@ meta_onscreen_native_allocate (CoglOnscreen *onscreen,
657d8e
   return TRUE;
657d8e
 }
657d8e
 
657d8e
+static void
657d8e
+destroy_egl_surface (CoglOnscreen *onscreen)
657d8e
+{
657d8e
+  CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
657d8e
+
657d8e
+  if (onscreen_egl->egl_surface != EGL_NO_SURFACE)
657d8e
+    {
657d8e
+      MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
657d8e
+      MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
657d8e
+      CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
657d8e
+      CoglContext *cogl_context = framebuffer->context;
657d8e
+      CoglRenderer *cogl_renderer = cogl_context->display->renderer;
657d8e
+      CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
657d8e
+
657d8e
+      meta_egl_destroy_surface (egl,
657d8e
+                                cogl_renderer_egl->edpy,
657d8e
+                                onscreen_egl->egl_surface,
657d8e
+                                NULL);
657d8e
+      onscreen_egl->egl_surface = EGL_NO_SURFACE;
657d8e
+    }
657d8e
+}
657d8e
+
657d8e
 static void
657d8e
 meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
657d8e
 {
657d8e
@@ -3077,17 +3099,6 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
657d8e
                        g_source_destroy);
657d8e
     }
657d8e
 
657d8e
-  if (onscreen_egl->egl_surface != EGL_NO_SURFACE)
657d8e
-    {
657d8e
-      MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
657d8e
-
657d8e
-      meta_egl_destroy_surface (egl,
657d8e
-                                cogl_renderer_egl->edpy,
657d8e
-                                onscreen_egl->egl_surface,
657d8e
-                                NULL);
657d8e
-      onscreen_egl->egl_surface = EGL_NO_SURFACE;
657d8e
-    }
657d8e
-
657d8e
   renderer_gpu_data =
657d8e
     meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
657d8e
                                        onscreen_native->render_gpu);
657d8e
@@ -3100,6 +3111,8 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
657d8e
 
657d8e
       free_current_bo (onscreen);
657d8e
 
657d8e
+      destroy_egl_surface (onscreen);
657d8e
+
657d8e
       if (onscreen_native->gbm.surface)
657d8e
         {
657d8e
           gbm_surface_destroy (onscreen_native->gbm.surface);
657d8e
@@ -3110,6 +3123,9 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
657d8e
     case META_RENDERER_NATIVE_MODE_EGL_DEVICE:
657d8e
       release_dumb_fb (&onscreen_native->egl.dumb_fb,
657d8e
                        onscreen_native->render_gpu);
657d8e
+
657d8e
+      destroy_egl_surface (onscreen);
657d8e
+
657d8e
       if (onscreen_native->egl.stream != EGL_NO_STREAM_KHR)
657d8e
         {
657d8e
           MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
657d8e
-- 
657d8e
2.24.1
657d8e
657d8e
657d8e
From c447010a23edc03c7a1103b477972ad666c2600f Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Wed, 19 Jun 2019 20:55:48 +0200
657d8e
Subject: [PATCH 5/8] renderer/native: Remove left-over function declarations
657d8e
657d8e
There are no callers and no definitions of these.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/655
657d8e
---
657d8e
 src/backends/native/meta-renderer-native.h | 12 ------------
657d8e
 1 file changed, 12 deletions(-)
657d8e
657d8e
diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h
657d8e
index a006dcbe7..8468208e1 100644
657d8e
--- a/src/backends/native/meta-renderer-native.h
657d8e
+++ b/src/backends/native/meta-renderer-native.h
657d8e
@@ -55,18 +55,6 @@ gboolean meta_renderer_native_supports_mirroring (MetaRendererNative *renderer_n
657d8e
 
657d8e
 void meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native);
657d8e
 
657d8e
-gboolean meta_renderer_native_set_legacy_view_size (MetaRendererNative *renderer_native,
657d8e
-                                                    MetaRendererView   *view,
657d8e
-                                                    int                 width,
657d8e
-                                                    int                 height,
657d8e
-                                                    GError            **error);
657d8e
-
657d8e
-void meta_renderer_native_set_ignore_crtc (MetaRendererNative *renderer_native,
657d8e
-                                           uint32_t            id,
657d8e
-                                           gboolean            ignore);
657d8e
-
657d8e
-MetaRendererView * meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native);
657d8e
-
657d8e
 void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native);
657d8e
 
657d8e
 int64_t meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native);
657d8e
-- 
657d8e
2.24.1
657d8e
657d8e
657d8e
From 7f97403d12df19cf936a341cc218743ec339aa0a Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Wed, 19 Jun 2019 20:57:14 +0200
657d8e
Subject: [PATCH 6/8] renderer/native: Queue mode reset from new rebuild_views
657d8e
 vfunc
657d8e
657d8e
Simplify the call site a bit and make the native renderer know it should
657d8e
queue mode reset itself when views have been rebuilt. This is done
657d8e
partly due to more things needing to be dealt with after views have been
657d8e
rebuilt.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/655
657d8e
---
657d8e
 src/backends/meta-renderer.c               |  8 ++++++++
657d8e
 src/backends/meta-renderer.h               |  1 +
657d8e
 src/backends/native/meta-renderer-native.c | 17 ++++++++++++++++-
657d8e
 src/backends/native/meta-renderer-native.h |  2 --
657d8e
 src/backends/native/meta-stage-native.c    |  1 -
657d8e
 5 files changed, 25 insertions(+), 4 deletions(-)
657d8e
657d8e
diff --git a/src/backends/meta-renderer.c b/src/backends/meta-renderer.c
657d8e
index 28637437b..87ba9f9f0 100644
657d8e
--- a/src/backends/meta-renderer.c
657d8e
+++ b/src/backends/meta-renderer.c
657d8e
@@ -90,6 +90,12 @@ meta_renderer_create_view (MetaRenderer       *renderer,
657d8e
  */
657d8e
 void
657d8e
 meta_renderer_rebuild_views (MetaRenderer *renderer)
657d8e
+{
657d8e
+  return META_RENDERER_GET_CLASS (renderer)->rebuild_views (renderer);
657d8e
+}
657d8e
+
657d8e
+static void
657d8e
+meta_renderer_real_rebuild_views (MetaRenderer *renderer)
657d8e
 {
657d8e
   MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
657d8e
   MetaBackend *backend = meta_get_backend ();
657d8e
@@ -181,4 +187,6 @@ meta_renderer_class_init (MetaRendererClass *klass)
657d8e
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
657d8e
 
657d8e
   object_class->finalize = meta_renderer_finalize;
657d8e
+
657d8e
+  klass->rebuild_views = meta_renderer_real_rebuild_views;
657d8e
 }
657d8e
diff --git a/src/backends/meta-renderer.h b/src/backends/meta-renderer.h
657d8e
index dae52cb9a..478baee91 100644
657d8e
--- a/src/backends/meta-renderer.h
657d8e
+++ b/src/backends/meta-renderer.h
657d8e
@@ -43,6 +43,7 @@ struct _MetaRendererClass
657d8e
   CoglRenderer * (* create_cogl_renderer) (MetaRenderer *renderer);
657d8e
   MetaRendererView * (* create_view) (MetaRenderer       *renderer,
657d8e
                                       MetaLogicalMonitor *logical_monitor);
657d8e
+  void (* rebuild_views) (MetaRenderer *renderer);
657d8e
 };
657d8e
 
657d8e
 CoglRenderer * meta_renderer_create_cogl_renderer (MetaRenderer *renderer);
657d8e
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
657d8e
index 62c27c191..70e1c4f9d 100644
657d8e
--- a/src/backends/native/meta-renderer-native.c
657d8e
+++ b/src/backends/native/meta-renderer-native.c
657d8e
@@ -258,6 +258,9 @@ cogl_pixel_format_from_drm_format (uint32_t               drm_format,
657d8e
                                    CoglPixelFormat       *out_format,
657d8e
                                    CoglTextureComponents *out_components);
657d8e
 
657d8e
+static void
657d8e
+meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native);
657d8e
+
657d8e
 static MetaBackend *
657d8e
 backend_from_renderer_native (MetaRendererNative *renderer_native)
657d8e
 {
657d8e
@@ -3186,7 +3189,7 @@ meta_renderer_native_supports_mirroring (MetaRendererNative *renderer_native)
657d8e
   return TRUE;
657d8e
 }
657d8e
 
657d8e
-void
657d8e
+static void
657d8e
 meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native)
657d8e
 {
657d8e
   MetaRenderer *renderer = META_RENDERER (renderer_native);
657d8e
@@ -3552,6 +3555,17 @@ meta_renderer_native_create_view (MetaRenderer       *renderer,
657d8e
   return view;
657d8e
 }
657d8e
 
657d8e
+static void
657d8e
+meta_renderer_native_rebuild_views (MetaRenderer *renderer)
657d8e
+{
657d8e
+  MetaRendererClass *parent_renderer_class =
657d8e
+    META_RENDERER_CLASS (meta_renderer_native_parent_class);
657d8e
+
657d8e
+  parent_renderer_class->rebuild_views (renderer);
657d8e
+
657d8e
+  meta_renderer_native_queue_modes_reset (META_RENDERER_NATIVE (renderer));
657d8e
+}
657d8e
+
657d8e
 void
657d8e
 meta_renderer_native_finish_frame (MetaRendererNative *renderer_native)
657d8e
 {
657d8e
@@ -4350,6 +4364,7 @@ meta_renderer_native_class_init (MetaRendererNativeClass *klass)
657d8e
 
657d8e
   renderer_class->create_cogl_renderer = meta_renderer_native_create_cogl_renderer;
657d8e
   renderer_class->create_view = meta_renderer_native_create_view;
657d8e
+  renderer_class->rebuild_views = meta_renderer_native_rebuild_views;
657d8e
 
657d8e
   obj_props[PROP_MONITOR_MANAGER] =
657d8e
     g_param_spec_object ("monitor-manager",
657d8e
diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h
657d8e
index 8468208e1..9eecdead1 100644
657d8e
--- a/src/backends/native/meta-renderer-native.h
657d8e
+++ b/src/backends/native/meta-renderer-native.h
657d8e
@@ -53,8 +53,6 @@ struct gbm_device * meta_gbm_device_from_gpu (MetaGpuKms *gpu_kms);
657d8e
 
657d8e
 gboolean meta_renderer_native_supports_mirroring (MetaRendererNative *renderer_native);
657d8e
 
657d8e
-void meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native);
657d8e
-
657d8e
 void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native);
657d8e
 
657d8e
 int64_t meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native);
657d8e
diff --git a/src/backends/native/meta-stage-native.c b/src/backends/native/meta-stage-native.c
657d8e
index add3e81fd..9b9c45ef3 100644
657d8e
--- a/src/backends/native/meta-stage-native.c
657d8e
+++ b/src/backends/native/meta-stage-native.c
657d8e
@@ -140,7 +140,6 @@ meta_stage_native_rebuild_views (MetaStageNative *stage_native)
657d8e
   ClutterActor *stage = meta_backend_get_stage (backend);
657d8e
 
657d8e
   meta_renderer_rebuild_views (renderer);
657d8e
-  meta_renderer_native_queue_modes_reset (META_RENDERER_NATIVE (renderer));
657d8e
   clutter_stage_update_resource_scales (CLUTTER_STAGE (stage));
657d8e
   ensure_frame_callbacks (stage_native);
657d8e
 }
657d8e
-- 
657d8e
2.24.1
657d8e
657d8e
657d8e
From 025054c93e43e8359c9ecafb6edea1eb4b7ad681 Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Wed, 19 Jun 2019 21:14:05 +0200
657d8e
Subject: [PATCH 7/8] renderer/native: Discard page flip retries when
657d8e
 rebuilding views
657d8e
657d8e
Rebuilding views means we don't care to retry page flip attempts for
657d8e
previous views, especially since connectors may have been disconnected,
657d8e
making a page flip retry hit an assert a flipped CRTC has connectors
657d8e
associated with it.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/655
657d8e
---
657d8e
 src/backends/native/meta-renderer-native.c | 50 +++++++++++++++++-----
657d8e
 1 file changed, 39 insertions(+), 11 deletions(-)
657d8e
657d8e
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
657d8e
index 70e1c4f9d..3cd01bcb7 100644
657d8e
--- a/src/backends/native/meta-renderer-native.c
657d8e
+++ b/src/backends/native/meta-renderer-native.c
657d8e
@@ -3060,6 +3060,24 @@ destroy_egl_surface (CoglOnscreen *onscreen)
657d8e
     }
657d8e
 }
657d8e
 
657d8e
+static void
657d8e
+discard_onscreen_page_flip_retries (MetaOnscreenNative *onscreen_native)
657d8e
+{
657d8e
+  g_list_free_full (onscreen_native->pending_page_flip_retries,
657d8e
+                    (GDestroyNotify) retry_page_flip_data_free);
657d8e
+  onscreen_native->pending_page_flip_retries = NULL;
657d8e
+
657d8e
+  if (onscreen_native->retry_page_flips_source)
657d8e
+    {
657d8e
+      MetaBackend *backend =
657d8e
+        backend_from_renderer_native (onscreen_native->renderer_native);
657d8e
+
657d8e
+      meta_backend_thaw_updates (backend);
657d8e
+      g_clear_pointer (&onscreen_native->retry_page_flips_source,
657d8e
+                       g_source_destroy);
657d8e
+    }
657d8e
+}
657d8e
+
657d8e
 static void
657d8e
 meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
657d8e
 {
657d8e
@@ -3090,17 +3108,7 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
657d8e
         g_warning ("Failed to clear current context");
657d8e
     }
657d8e
 
657d8e
-  g_list_free_full (onscreen_native->pending_page_flip_retries,
657d8e
-                    (GDestroyNotify) retry_page_flip_data_free);
657d8e
-  if (onscreen_native->retry_page_flips_source)
657d8e
-    {
657d8e
-      MetaBackend *backend =
657d8e
-        backend_from_renderer_native (onscreen_native->renderer_native);
657d8e
-
657d8e
-      meta_backend_thaw_updates (backend);
657d8e
-      g_clear_pointer (&onscreen_native->retry_page_flips_source,
657d8e
-                       g_source_destroy);
657d8e
-    }
657d8e
+  discard_onscreen_page_flip_retries (onscreen_native);
657d8e
 
657d8e
   renderer_gpu_data =
657d8e
     meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
657d8e
@@ -3555,12 +3563,32 @@ meta_renderer_native_create_view (MetaRenderer       *renderer,
657d8e
   return view;
657d8e
 }
657d8e
 
657d8e
+static void
657d8e
+discard_page_flip_retries (MetaRenderer *renderer)
657d8e
+{
657d8e
+  GList *l;
657d8e
+
657d8e
+  for (l = meta_renderer_get_views (renderer); l; l = l->next)
657d8e
+    {
657d8e
+      ClutterStageView *stage_view = l->data;
657d8e
+      CoglFramebuffer *framebuffer =
657d8e
+        clutter_stage_view_get_onscreen (stage_view);
657d8e
+      CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
657d8e
+      CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
657d8e
+      MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
657d8e
+
657d8e
+      discard_onscreen_page_flip_retries (onscreen_native);
657d8e
+    }
657d8e
+}
657d8e
+
657d8e
 static void
657d8e
 meta_renderer_native_rebuild_views (MetaRenderer *renderer)
657d8e
 {
657d8e
   MetaRendererClass *parent_renderer_class =
657d8e
     META_RENDERER_CLASS (meta_renderer_native_parent_class);
657d8e
 
657d8e
+  discard_page_flip_retries (renderer);
657d8e
+
657d8e
   parent_renderer_class->rebuild_views (renderer);
657d8e
 
657d8e
   meta_renderer_native_queue_modes_reset (META_RENDERER_NATIVE (renderer));
657d8e
-- 
657d8e
2.24.1
657d8e
657d8e
657d8e
From f4fdec6003e2cf9fa4b1882e92faf1da64e6052e Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Wed, 27 Nov 2019 17:34:35 +0100
657d8e
Subject: [PATCH 8/8] =?UTF-8?q?crtc-kms:=20Ignore=2090=C2=B0=20rotations?=
657d8e
MIME-Version: 1.0
657d8e
Content-Type: text/plain; charset=UTF-8
657d8e
Content-Transfer-Encoding: 8bit
657d8e
657d8e
They tend to require special modifiers or won't work at all; ignore
657d8e
them.
657d8e
---
657d8e
 src/backends/native/meta-crtc-kms.c | 4 ----
657d8e
 1 file changed, 4 deletions(-)
657d8e
657d8e
diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c
657d8e
index 8c2fbfe3c..8374376d5 100644
657d8e
--- a/src/backends/native/meta-crtc-kms.c
657d8e
+++ b/src/backends/native/meta-crtc-kms.c
657d8e
@@ -368,12 +368,8 @@ parse_transforms (MetaCrtc          *crtc,
657d8e
 
657d8e
       if (strcmp (prop->enums[i].name, "rotate-0") == 0)
657d8e
         transform = META_MONITOR_TRANSFORM_NORMAL;
657d8e
-      else if (strcmp (prop->enums[i].name, "rotate-90") == 0)
657d8e
-        transform = META_MONITOR_TRANSFORM_90;
657d8e
       else if (strcmp (prop->enums[i].name, "rotate-180") == 0)
657d8e
         transform = META_MONITOR_TRANSFORM_180;
657d8e
-      else if (strcmp (prop->enums[i].name, "rotate-270") == 0)
657d8e
-        transform = META_MONITOR_TRANSFORM_270;
657d8e
 
657d8e
       if (transform != -1)
657d8e
         {
657d8e
-- 
657d8e
2.24.1
657d8e