backend-drm: destroy scanout fb in GPU recovery

The GBM BO (Graphics Buffer Manager Buffer Object) associated with
the scanout fb will be destroyed by eglDestroySurface in GPU recovery
regardless of its reference count. Therefore, we need to manually
destroy the corresponding scanout fb as well.

Signed-off-by: Wei Zhao <Wei.Zhao@amd.com>
This commit is contained in:
Wei Zhao 2026-04-24 13:55:45 +08:00 committed by Trigger Huang
parent 10d8c02fec
commit 0f13cd0eee

View file

@ -805,8 +805,25 @@ drm_handle_gl_renderer_error(struct weston_compositor *compositor, int err)
renderer->gl->set_recovering(compositor, true);
/* 1, Destroy the renderer outputs */
wl_list_for_each(output, &compositor->output_list, link)
wl_list_for_each(output, &compositor->output_list, link) {
struct drm_output *drm = to_drm_output(output);
struct drm_plane *scanout = drm->scanout_handle->plane;
/*
* When the output is destroyed, its associated
* EGLSurface will also be destroyed. Consequently, the
* GBM BOs backing this surface will be freed. Mesa will
* destroy the GBM BO user_data (fb) regardless of
* refcount, so ensure we destroy them here before
* invoking output_destroy.
*/
if (scanout && scanout->state_cur &&
scanout->state_cur->fb &&
scanout->state_cur->fb->type == BUFFER_GBM_SURFACE)
drm_plane_reset_state(scanout);
renderer->gl->output_destroy(output);
}
/* 2, Destroy the renderer */
renderer->destroy(compositor);