weston: Port small fix for always creating a hash table 38/30138/2
authorMarius Vlad <marius.vlad@collabora.com>
Fri, 26 Jul 2024 10:54:47 +0000 (13:54 +0300)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tue, 30 Jul 2024 08:46:47 +0000 (08:46 +0000)
This is a attempting for SPEC-5208 which brings in two changes from
Weston main, which could potentially fix the issue.

Bug-AGL: SPEC-5208
Change-Id: I7d350797bddae9e3aef1ab7c8816f8269f2a14e7
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/30138
ci-image-build: Jenkins Job builder account
Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tested-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
meta-agl-core/recipes-graphics/wayland/weston/0001-backend-drm-don-t-leak-gem_handle_refcnt-in-drm_dest.patch [new file with mode: 0644]
meta-agl-core/recipes-graphics/wayland/weston/0002-backend-drm-always-create-gem_handle_refcnt-hash-tab.patch [new file with mode: 0644]
meta-agl-core/recipes-graphics/wayland/weston_13.0_aglcore.inc

diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-backend-drm-don-t-leak-gem_handle_refcnt-in-drm_dest.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-backend-drm-don-t-leak-gem_handle_refcnt-in-drm_dest.patch
new file mode 100644 (file)
index 0000000..0e3ab76
--- /dev/null
@@ -0,0 +1,27 @@
+From fb60f9c16ce8865fbdcd181419f44b72af1aa3c2 Mon Sep 17 00:00:00 2001
+From: Ray Smith <rsmith@brightsign.biz>
+Date: Tue, 19 Dec 2023 11:43:55 +0000
+Subject: [PATCH 1/2] backend-drm: don't leak gem_handle_refcnt in drm_destroy
+
+Signed-off-by: Ray Smith <rsmith@brightsign.biz>
+---
+ libweston/backend-drm/drm.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
+index 8092789..fcececb 100644
+--- a/libweston/backend-drm/drm.c
++++ b/libweston/backend-drm/drm.c
+@@ -3364,6 +3364,9 @@ drm_destroy(struct weston_backend *backend)
+       weston_launcher_close(ec->launcher, device->drm.fd);
+       weston_launcher_destroy(ec->launcher);
++      if (device->gem_handle_refcnt)
++              hash_table_destroy(device->gem_handle_refcnt);
++
+       free(device->drm.filename);
+       free(device);
+       free(b);
+-- 
+2.43.0
+
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0002-backend-drm-always-create-gem_handle_refcnt-hash-tab.patch b/meta-agl-core/recipes-graphics/wayland/weston/0002-backend-drm-always-create-gem_handle_refcnt-hash-tab.patch
new file mode 100644 (file)
index 0000000..0ae8208
--- /dev/null
@@ -0,0 +1,56 @@
+From 10fcfd66069c774e28f67b18afd329e4bcf9f5b3 Mon Sep 17 00:00:00 2001
+From: Ray Smith <rsmith@brightsign.biz>
+Date: Tue, 19 Dec 2023 11:45:45 +0000
+Subject: [PATCH 2/2] backend-drm: always create gem_handle_refcnt hash table
+
+Devices created via drm_device_create have this hash table, but those
+created via drm_backend_create don't.
+
+Signed-off-by: Ray Smith <rsmith@brightsign.biz>
+---
+ libweston/backend-drm/drm.c | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
+index fcececb..9d6a9cf 100644
+--- a/libweston/backend-drm/drm.c
++++ b/libweston/backend-drm/drm.c
+@@ -3364,8 +3364,7 @@ drm_destroy(struct weston_backend *backend)
+       weston_launcher_close(ec->launcher, device->drm.fd);
+       weston_launcher_destroy(ec->launcher);
+-      if (device->gem_handle_refcnt)
+-              hash_table_destroy(device->gem_handle_refcnt);
++      hash_table_destroy(device->gem_handle_refcnt);
+       free(device->drm.filename);
+       free(device);
+@@ -3867,10 +3866,13 @@ drm_backend_create(struct weston_compositor *compositor,
+       device = zalloc(sizeof *device);
+       if (device == NULL)
+-              return NULL;
++              goto err_backend;
+       device->state_invalid = true;
+       device->drm.fd = -1;
+       device->backend = b;
++      device->gem_handle_refcnt = hash_table_create();
++      if (!device->gem_handle_refcnt)
++              goto err_device;
+       b->drm = device;
+       wl_list_init(&b->kms_list);
+@@ -4108,6 +4110,10 @@ err_compositor:
+       if (b->gbm)
+               gbm_device_destroy(b->gbm);
+ #endif
++      hash_table_destroy(device->gem_handle_refcnt);
++err_device:
++      free(device);
++err_backend:
+       free(b);
+       return NULL;
+ }
+-- 
+2.43.0
+
index 843a068..a377bbe 100644 (file)
@@ -5,6 +5,8 @@ PACKAGECONFIG:append = "${@bb.utils.contains('DISTRO_FEATURES', 'weston-remoting
 SRC_URI:append = " \
                  file://0001-clients-Handle-missing-pointer_surface-is-there-s-no.patch \
                  file://0001-libweston-Add-paint-node-destruction-into-weston_lay.patch \
+                 file://0001-backend-drm-don-t-leak-gem_handle_refcnt-in-drm_dest.patch \
+                 file://0002-backend-drm-always-create-gem_handle_refcnt-hash-tab.patch \
 "