From 6d8e3c569cf7e9ad80569768871e1ed30bf4d2a8 Mon Sep 17 00:00:00 2001 From: Leandro Ribeiro Date: Thu, 1 Jun 2023 18:51:34 -0300 Subject: [PATCH] drm: drop disable_planes being false as a condition to support writeback In 2d70bdfdcdb236ee3e466b1a24df494da43c8a68 "drm-backend: add support to output capture writeback source" we've ensured that disable_planes should be false in order to support writeback capture tasks. But this was wrong; disable_planes is transient (it is true when there's some sort of content recording happening), and we enable/disable that during compositor's lifetime. This is dangerous and may result in a crash. Imagine the following sequence: 1. screen recording starts, disable_planes is set to true. 2. for whatever reason the output size changes, and we end up not updating capture info because we think that writeback is not supported by the device. 3. screen recording stops, disable_planes is set to false. 4. user tries to take a writeback screenshot, and the DRM-backend will pull a writeback capture task with weston_output_pull_capture_task(). 5. this function has an assert to ensure that the DRM-backend did not forget to update the capture info, and we hit that assert. With this patch we drop disable_planes being false as a condition to support writeback. So now we keep the capture info up-to-date even when screen recording is happening, and we gracefully fail writeback tasks. Signed-off-by: Leandro Ribeiro --- libweston/backend-drm/drm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 1078b89b..a1e61df8 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -561,6 +561,12 @@ drm_output_pick_writeback_capture_task(struct drm_output *output) assert(output->device->atomic_modeset); + if (output->base.disable_planes > 0) { + msg = "drm: KMS planes usage is disabled for now, so " \ + "writeback capture tasks are rejected"; + goto err; + } + wb = drm_output_find_compatible_writeback(output); if (!wb) { msg = "drm: could not find writeback connector for output"; @@ -948,7 +954,7 @@ drm_output_apply_mode(struct drm_output *output) } } - if (device->atomic_modeset && !output->base.disable_planes) + if (device->atomic_modeset) weston_output_update_capture_info(&output->base, WESTON_OUTPUT_CAPTURE_SOURCE_WRITEBACK, output->base.current_mode->width, @@ -2138,7 +2144,7 @@ drm_output_enable(struct weston_output *base) output->base.switch_mode = drm_output_switch_mode; output->base.set_gamma = drm_output_set_gamma; - if (device->atomic_modeset && !base->disable_planes) + if (device->atomic_modeset) weston_output_update_capture_info(base, WESTON_OUTPUT_CAPTURE_SOURCE_WRITEBACK, base->current_mode->width, base->current_mode->height,