[mutter/gnome-41] cursor-renderer/native: Clear GPU state before closing device
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-41] cursor-renderer/native: Clear GPU state before closing device
- Date: Wed, 22 Dec 2021 20:28:47 +0000 (UTC)
commit 8eeccfc349ec898d17e2c57229e64a010c72b319
Author: Jonas Ådahl <jadahl gmail com>
Date: Mon Nov 15 14:27:54 2021 +0100
cursor-renderer/native: Clear GPU state before closing device
This ensures we don't have any left over cursor GPU buffers (via
gbm_bo's) after destroying the corresponding gbm_device (owned by
MetaRenderDevice).
Fixes crashes with backtraces such as
1) meta_drm_buffer_gbm_finalize at ../src/backends/native/meta-drm-buffer-gbm.c:450
4) invalidate_cursor_gpu_state at ../src/backends/native/meta-cursor-renderer-native.c:1167
9) update_cursor_sprite_texture at ../src/wayland/meta-wayland-cursor-surface.c:70
10) meta_wayland_surface_role_apply_state at ../src/wayland/meta-wayland-surface.c:1869
11) meta_wayland_surface_apply_state at ../src/wayland/meta-wayland-surface.c:832
12) meta_wayland_surface_commit at ../src/wayland/meta-wayland-surface.c:993
13) wl_surface_commit at ../src/wayland/meta-wayland-surface.c:1158
14) ffi_call_unix64 at ../src/x86/unix64.S:76
15) ffi_call at ../src/x86/ffi64.c:525
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
(cherry picked from commit 4159c76a5b5b0fd0dfff8c9ba6b8269aedaebfec)
src/backends/native/meta-cursor-renderer-native.c | 14 +++++++++
src/backends/native/meta-cursor-renderer-native.h | 5 ++++
src/backends/native/meta-renderer-native-private.h | 1 +
src/backends/native/meta-renderer-native.c | 35 ++++++++++++++++++++++
4 files changed, 55 insertions(+)
---
diff --git a/src/backends/native/meta-cursor-renderer-native.c
b/src/backends/native/meta-cursor-renderer-native.c
index d9e4a7e1d7..81f4da05cb 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -1876,3 +1876,17 @@ static void
meta_cursor_renderer_native_init (MetaCursorRendererNative *native)
{
}
+
+void
+meta_cursor_renderer_native_invalidate_gpu_state (MetaCursorRendererNative *native,
+ MetaCursorSprite *cursor_sprite,
+ MetaGpuKms *gpu_kms)
+{
+ MetaCursorNativePrivate *cursor_priv;
+
+ cursor_priv = get_cursor_priv (cursor_sprite);
+ if (!cursor_priv)
+ return;
+
+ g_hash_table_remove (cursor_priv->gpu_states, gpu_kms);
+}
diff --git a/src/backends/native/meta-cursor-renderer-native.h
b/src/backends/native/meta-cursor-renderer-native.h
index 5113b96ce1..72b7b3c35f 100644
--- a/src/backends/native/meta-cursor-renderer-native.h
+++ b/src/backends/native/meta-cursor-renderer-native.h
@@ -26,6 +26,7 @@
#define META_CURSOR_RENDERER_NATIVE_H
#include "backends/meta-cursor-renderer.h"
+#include "backends/native/meta-backend-native-types.h"
#include "meta/meta-backend.h"
#define META_TYPE_CURSOR_RENDERER_NATIVE (meta_cursor_renderer_native_get_type ())
@@ -39,4 +40,8 @@ void meta_cursor_renderer_native_prepare_frame (MetaCursorRendererNative *cursor
MetaCursorRendererNative * meta_cursor_renderer_native_new (MetaBackend *backend,
ClutterInputDevice *device);
+void meta_cursor_renderer_native_invalidate_gpu_state (MetaCursorRendererNative *native,
+ MetaCursorSprite *cursor_sprite,
+ MetaGpuKms *gpu_kms);
+
#endif /* META_CURSOR_RENDERER_NATIVE_H */
diff --git a/src/backends/native/meta-renderer-native-private.h
b/src/backends/native/meta-renderer-native-private.h
index acadb3fff9..9d51a51c86 100644
--- a/src/backends/native/meta-renderer-native-private.h
+++ b/src/backends/native/meta-renderer-native-private.h
@@ -50,6 +50,7 @@ typedef struct _MetaRendererNativeGpuData
MetaRendererNative *renderer_native;
MetaDeviceFile *device_file;
+ MetaGpuKms *gpu_kms;
struct {
struct gbm_device *device;
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 75751fb672..3b08b1c18f 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -46,9 +46,11 @@
#include <string.h>
#include <unistd.h>
+#include "backends/meta-cursor-tracker-private.h"
#include "backends/meta-gles3.h"
#include "backends/meta-logical-monitor.h"
#include "backends/native/meta-backend-native-private.h"
+#include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-cogl-utils.h"
#include "backends/native/meta-crtc-kms.h"
#include "backends/native/meta-crtc-virtual.h"
@@ -121,6 +123,11 @@ meta_renderer_native_gpu_data_free (MetaRendererNativeGpuData *renderer_gpu_data
{
MetaRendererNative *renderer_native = renderer_gpu_data->renderer_native;
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
+ MetaRenderer *renderer = META_RENDERER (renderer_gpu_data->renderer_native);
+ MetaBackend *backend = meta_renderer_get_backend (renderer);
+ MetaCursorRenderer *cursor_renderer;
+ MetaGpuKms *gpu_kms;
+ GList *l;
if (renderer_gpu_data->secondary.egl_context != EGL_NO_CONTEXT)
{
@@ -130,11 +137,33 @@ meta_renderer_native_gpu_data_free (MetaRendererNativeGpuData *renderer_gpu_data
NULL);
}
+ cursor_renderer = meta_backend_get_cursor_renderer (backend);
+ gpu_kms = renderer_gpu_data->gpu_kms;
+ if (cursor_renderer && gpu_kms)
+ {
+ MetaCursorRendererNative *cursor_renderer_native =
+ META_CURSOR_RENDERER_NATIVE (cursor_renderer);
+ MetaCursorTracker *cursor_tracker =
+ meta_backend_get_cursor_tracker (backend);
+ GList *cursor_sprites =
+ meta_cursor_tracker_peek_cursor_sprites (cursor_tracker);
+
+ for (l = cursor_sprites; l; l = l->next)
+ {
+ MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (l->data);
+
+ meta_cursor_renderer_native_invalidate_gpu_state (cursor_renderer_native,
+ cursor_sprite,
+ gpu_kms);
+ }
+ }
+
if (renderer_gpu_data->egl_display != EGL_NO_DISPLAY)
meta_egl_terminate (egl, renderer_gpu_data->egl_display, NULL);
g_clear_pointer (&renderer_gpu_data->gbm.device, gbm_device_destroy);
g_clear_pointer (&renderer_gpu_data->device_file, meta_device_file_release);
+
g_free (renderer_gpu_data);
}
@@ -1588,6 +1617,7 @@ init_gbm_egl_display (MetaRendererNative *renderer_native,
static MetaRendererNativeGpuData *
create_renderer_gpu_data_gbm (MetaRendererNative *renderer_native,
+ MetaGpuKms *gpu_kms,
MetaDeviceFile *device_file,
GError **error)
{
@@ -1607,6 +1637,7 @@ create_renderer_gpu_data_gbm (MetaRendererNative *renderer_native,
renderer_gpu_data = meta_create_renderer_native_gpu_data ();
renderer_gpu_data->device_file = meta_device_file_acquire (device_file);
renderer_gpu_data->renderer_native = renderer_native;
+ renderer_gpu_data->gpu_kms = gpu_kms;
renderer_gpu_data->gbm.device = gbm_device;
renderer_gpu_data->mode = META_RENDERER_NATIVE_MODE_GBM;
@@ -1813,6 +1844,7 @@ count_drm_devices (MetaRendererNative *renderer_native)
static MetaRendererNativeGpuData *
create_renderer_gpu_data_egl_device (MetaRendererNative *renderer_native,
+ MetaGpuKms *gpu_kms,
MetaDeviceFile *device_file,
GError **error)
{
@@ -1873,6 +1905,7 @@ create_renderer_gpu_data_egl_device (MetaRendererNative *renderer_native,
renderer_gpu_data->egl.device = egl_device;
renderer_gpu_data->mode = META_RENDERER_NATIVE_MODE_EGL_DEVICE;
renderer_gpu_data->egl_display = egl_display;
+ renderer_gpu_data->gpu_kms = gpu_kms;
return renderer_gpu_data;
}
@@ -1911,6 +1944,7 @@ meta_renderer_native_create_renderer_gpu_data (MetaRendererNative *renderer_nat
return NULL;
gbm_renderer_gpu_data = create_renderer_gpu_data_gbm (renderer_native,
+ gpu_kms,
device_file,
&gbm_error);
if (gbm_renderer_gpu_data)
@@ -1922,6 +1956,7 @@ meta_renderer_native_create_renderer_gpu_data (MetaRendererNative *renderer_nat
#ifdef HAVE_EGL_DEVICE
egl_stream_renderer_gpu_data =
create_renderer_gpu_data_egl_device (renderer_native,
+ gpu_kms,
device_file,
&egl_device_error);
if (egl_stream_renderer_gpu_data)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]