From 6e3170b674d7ae3f2f00f982798a21c635ba3926 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 21 Feb 2020 13:40:38 +0100 Subject: eglfs_kms: Prevent drm errors with more than one window during the screen's lifetime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QML Live Preview tool exercises the problematic case of having a QQuickWindow, then closing it, then showing another, then destroying that, ..., and so on. It seems that the eglfs_kms backend does not handle this gracefully: if there was a page flip issued for a window that is then closed, the new window will result in drm errors (like -22 EINVAL) because the logic gets confused due to holding on to surface buffers from the old window. To remedy this, make sure the same cleanup is performed on a failing atomic commit as it is done on the non-atomic code path. In addition, reset more things in resetSurface(). Change-Id: I7e13dbbf4d74b4ed9beaf71472680a0daafb4f95 Fixes: QTBUG-82104 Reviewed-by: Christian Strømme --- .../eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/eglfs') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 722d0266ce..0f829ee00c 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -161,6 +161,9 @@ gbm_surface *QEglFSKmsGbmScreen::createSurface(EGLConfig eglConfig) void QEglFSKmsGbmScreen::resetSurface() { + m_flipPending = false; + m_gbm_bo_current = nullptr; + m_gbm_bo_next = nullptr; m_gbm_surface = nullptr; } @@ -423,9 +426,15 @@ void QEglFSKmsGbmScreen::flip() } } + if (device()->hasAtomicSupport()) { #if QT_CONFIG(drm_atomic) - device()->threadLocalAtomicCommit(this); + if (!device()->threadLocalAtomicCommit(this)) { + m_flipPending = false; + gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next); + m_gbm_bo_next = nullptr; + } #endif + } } void QEglFSKmsGbmScreen::flipFinished() -- cgit v1.2.3