From 7bc347c7696d89e7de244d22d3ee68f3911dc29c Mon Sep 17 00:00:00 2001 From: Christophe Priouzeau Date: Wed, 9 Oct 2019 11:27:51 +0200 Subject: [PATCH] WESTON: patch backport and drm fix - clients: close unused keymap fd This patch is already merged upstream and solves a crash during suspend/resume. - drm: fix race during system suspend --- .../0005-clients-close-unused-keymap-fd.patch | 74 +++++++++++++++ ...d-drm-fix-race-during-system-suspend.patch | 94 +++++++++++++++++++ .../wayland/weston_5.0.0.bbappend | 2 + 3 files changed, 170 insertions(+) create mode 100644 recipes-graphics/wayland/weston/0005-clients-close-unused-keymap-fd.patch create mode 100644 recipes-graphics/wayland/weston/0006-backend-drm-fix-race-during-system-suspend.patch diff --git a/recipes-graphics/wayland/weston/0005-clients-close-unused-keymap-fd.patch b/recipes-graphics/wayland/weston/0005-clients-close-unused-keymap-fd.patch new file mode 100644 index 0000000..1bacda8 --- /dev/null +++ b/recipes-graphics/wayland/weston/0005-clients-close-unused-keymap-fd.patch @@ -0,0 +1,74 @@ +From dc6538a73577ee23841ea3c5150b3907a7cef04a Mon Sep 17 00:00:00 2001 +From: Antonio Borneo +Date: Mon, 29 Apr 2019 17:54:10 +0200 +Subject: [PATCH] clients: close unused keymap fd + +commit 4071225cdc12a36a08ddd3102a3dd17d4006c320 upstream. + +In the simple examples in which keymap is not handled, the open +descriptor has to be properly closed. + +After each suspend/resume sequence the keymap is send again to +every client. On client weston-simple-egl the leak causes a +segfault when no more file descriptors can be opened. + +Close the file descriptor and lazily copy/paste the comment +already available in simple-dmabuf-v4l. + +Signed-off-by: Antonio Borneo +--- + clients/multi-resource.c | 2 ++ + clients/simple-egl.c | 2 ++ + clients/weston-info.c | 3 +++ + 3 files changed, 7 insertions(+) + +diff --git a/clients/multi-resource.c b/clients/multi-resource.c +index 2be0a7e3..0a035118 100644 +--- a/clients/multi-resource.c ++++ b/clients/multi-resource.c +@@ -296,6 +296,8 @@ static void + keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, + uint32_t format, int fd, uint32_t size) + { ++ /* Just so we don’t leak the keymap fd */ ++ close(fd); + } + + static void +diff --git a/clients/simple-egl.c b/clients/simple-egl.c +index a1e57aef..ac99b449 100644 +--- a/clients/simple-egl.c ++++ b/clients/simple-egl.c +@@ -695,6 +695,8 @@ static void + keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, + uint32_t format, int fd, uint32_t size) + { ++ /* Just so we don’t leak the keymap fd */ ++ close(fd); + } + + static void +diff --git a/clients/weston-info.c b/clients/weston-info.c +index 609e270a..20c96d0f 100644 +--- a/clients/weston-info.c ++++ b/clients/weston-info.c +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + + #include + +@@ -435,6 +436,8 @@ static void + keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, + uint32_t format, int fd, uint32_t size) + { ++ /* Just so we don’t leak the keymap fd */ ++ close(fd); + } + + static void +-- +2.21.0 + diff --git a/recipes-graphics/wayland/weston/0006-backend-drm-fix-race-during-system-suspend.patch b/recipes-graphics/wayland/weston/0006-backend-drm-fix-race-during-system-suspend.patch new file mode 100644 index 0000000..28c5f96 --- /dev/null +++ b/recipes-graphics/wayland/weston/0006-backend-drm-fix-race-during-system-suspend.patch @@ -0,0 +1,94 @@ +From 084d5600c6b8ff7189b40f5a0a844ea602e0d428 Mon Sep 17 00:00:00 2001 +From: Antonio Borneo +Date: Mon, 27 May 2019 17:06:33 +0200 +Subject: [PATCH] backend-drm: fix race during system suspend + +Depending on system loading, weston-launcher could drop the drm +master access before compositor and all the clients receive the +notification. In this case, some commit could be sent to the drm +driver too late and get refused with error EACCES. +This error condition is not properly managed and causes weston to +hang. + +Only for atomic modesetting, cancel current repaint in case of +EACCES. +No need to wait for suspend or for any notification; in case the +client reschedules and try a repaint, it will get EACCES again. +At resume, damage-all guarantees a complete repaint. + +Non-atomic modesetting suffers from similar problems, but it is +not fixed by this change. Since drm_pending_state_apply() never +returns error for non-atomic modesetting, this change has no +impact on non-atomic modesetting. + +Signed-off-by: Antonio Borneo +Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/117 +--- + libweston/compositor-drm.c | 15 +++++++++++++-- + libweston/compositor.c | 2 +- + libweston/compositor.h | 2 ++ + 3 files changed, 16 insertions(+), 3 deletions(-) + +diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c +index 3891176..d88bc1e 100644 +--- a/libweston/compositor-drm.c ++++ b/libweston/compositor-drm.c +@@ -2885,7 +2885,9 @@ drm_output_start_repaint_loop(struct weston_output *output_base) + ret = drm_pending_state_apply(pending_state); + if (ret != 0) { + weston_log("applying repaint-start state failed: %m\n"); +- goto finish_frame; ++ if (ret != -EACCES) ++ goto finish_frame; ++ weston_output_schedule_repaint_reset(output_base); + } + + return; +@@ -2987,8 +2989,17 @@ drm_repaint_flush(struct weston_compositor *compositor, void *repaint_data) + { + struct drm_backend *b = to_drm_backend(compositor); + struct drm_pending_state *pending_state = repaint_data; ++ struct weston_output *output; ++ int ret; + +- drm_pending_state_apply(pending_state); ++ ret = drm_pending_state_apply(pending_state); ++ if (ret == -EACCES) { ++ weston_log("failed repaint flush: Permission denied\n"); ++ wl_list_for_each(output, &compositor->output_list, link) { ++ if (output->repainted) ++ weston_output_schedule_repaint_reset(output); ++ } ++ } + b->repaint_data = NULL; + } + +diff --git a/libweston/compositor.c b/libweston/compositor.c +index 9deb781..51705f7 100644 +--- a/libweston/compositor.c ++++ b/libweston/compositor.c +@@ -2435,7 +2435,7 @@ weston_output_repaint(struct weston_output *output, void *repaint_data) + return r; + } + +-static void ++WL_EXPORT void + weston_output_schedule_repaint_reset(struct weston_output *output) + { + output->repaint_status = REPAINT_NOT_SCHEDULED; +diff --git a/libweston/compositor.h b/libweston/compositor.h +index 8b7a102..4f9b989 100644 +--- a/libweston/compositor.h ++++ b/libweston/compositor.h +@@ -1704,6 +1704,8 @@ weston_output_finish_frame(struct weston_output *output, + void + weston_output_schedule_repaint(struct weston_output *output); + void ++weston_output_schedule_repaint_reset(struct weston_output *output); ++void + weston_output_damage(struct weston_output *output); + void + weston_compositor_schedule_repaint(struct weston_compositor *compositor); +-- +2.7.4 + diff --git a/recipes-graphics/wayland/weston_5.0.0.bbappend b/recipes-graphics/wayland/weston_5.0.0.bbappend index 92e0094..c3db1f2 100644 --- a/recipes-graphics/wayland/weston_5.0.0.bbappend +++ b/recipes-graphics/wayland/weston_5.0.0.bbappend @@ -5,3 +5,5 @@ SRC_URI_append_stm32mpcommon = " file://0001-desktop-shell-always-paint-backgrou SRC_URI_append_stm32mpcommon = " file://0002-desktop-shell-allow-to-center-background-image.patch " SRC_URI_append_stm32mpcommon = " file://0003-Allow-to-get-hdmi-output-with-several-outputs.patch " SRC_URI_append_stm32mpcommon = " file://0004-Force-to-close-all-output.patch " +SRC_URI_append_stm32mpcommon = " file://0005-clients-close-unused-keymap-fd.patch " +SRC_URI_append_stm32mpcommon = " file://0006-backend-drm-fix-race-during-system-suspend.patch "