From df4adb88115877f51e47db1d2e41e55b4cf9e2cd Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 16 Oct 2024 21:19:39 +0200 Subject: [PATCH] backends/drm: reduce the timeout for waiting for pageflips 30s makes the user suspect the whole PC is completely frozen, even though this can happen in some cases when unplugging an external GPU for example. The kernel should never take more than one frame to deliver the pageflip event, one second is plenty to be safe. --- src/backends/drm/drm_commit_thread.cpp | 7 +------ src/backends/drm/drm_gpu.cpp | 2 +- src/backends/drm/drm_gpu.h | 6 ++++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/backends/drm/drm_commit_thread.cpp b/src/backends/drm/drm_commit_thread.cpp index 0ba3957877..c3421108dd 100644 --- a/src/backends/drm/drm_commit_thread.cpp +++ b/src/backends/drm/drm_commit_thread.cpp @@ -19,11 +19,6 @@ using namespace std::chrono_literals; namespace KWin { -/** - * This should always be longer than any real pageflip can take, even with PSR and modesets - */ -static constexpr auto s_pageflipTimeout = 5s; - DrmCommitThread::DrmCommitThread(DrmGpu *gpu, const QString &name) { if (!gpu->atomicModeSetting()) { @@ -40,7 +35,7 @@ DrmCommitThread::DrmCommitThread(DrmGpu *gpu, const QString &name) std::unique_lock lock(m_mutex); bool timeout = false; if (m_committed) { - timeout = m_commitPending.wait_for(lock, s_pageflipTimeout) == std::cv_status::timeout; + timeout = m_commitPending.wait_for(lock, DrmGpu::s_pageflipTimeout) == std::cv_status::timeout; } else if (m_commits.empty()) { m_commitPending.wait(lock); } diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp index 6ad191f6b1..e151811f5b 100644 --- a/src/backends/drm/drm_gpu.cpp +++ b/src/backends/drm/drm_gpu.cpp @@ -522,7 +522,7 @@ void DrmGpu::waitIdle() pfds[0].fd = m_fd; pfds[0].events = POLLIN; - const int ready = poll(pfds, 1, 30000); + const int ready = poll(pfds, 1, s_pageflipTimeout.count()); if (ready < 0) { if (errno != EINTR) { qCWarning(KWIN_DRM) << Q_FUNC_INFO << "poll() failed:" << strerror(errno); diff --git a/src/backends/drm/drm_gpu.h b/src/backends/drm/drm_gpu.h index de3b5df2d1..c7858cffab 100644 --- a/src/backends/drm/drm_gpu.h +++ b/src/backends/drm/drm_gpu.h @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -62,6 +63,11 @@ class DrmGpu : public QObject { Q_OBJECT public: + /** + * This should always be longer than any real pageflip can take, even with PSR and modesets + */ + static constexpr std::chrono::milliseconds s_pageflipTimeout = std::chrono::seconds(1); + DrmGpu(DrmBackend *backend, int fd, std::unique_ptr &&device); ~DrmGpu();