[plasma/kwin] src/backends/drm: backends/drm: don't remove GPUs without outputs

Xaver Hugl <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit f8f5bec7b0adcf37bf069b61cd8d992ac830b2bd by Xaver Hugl.
Committed on 28/07/2026 at 13:25.
Pushed by zamundaaa into branch 'master'.

backends/drm: don't remove GPUs without outputs

Non-primary GPUs without outputs were removed previously because:
- it was required for allowing GPUs to fully power down
- being able to unload the driver for VFIO requires file descriptors of the
  device to be closed

However, this was 5 years ago, and GPU power management has gotten less terrible
since then. Vulkan drivers also open file descriptors of all GPUs, so drivers
must handle this situation properly either way.

For VFIO, udev "remove" events can be used to make KWin remove the GPU, which is
a better solution, since it works even while displays are connected to it.

This also fixes KWin waking up GPUs when it receives udev events for a GPU
that's in powersave mode, which could (besides the power management impact)
also block KWin's main thread for some time.

BUG: 519461

M  +1    -4    src/backends/drm/drm_backend.cpp

https://invent.kde.org/plasma/kwin/-/commit/f8f5bec7b0adcf37bf069b61cd8d992ac830b2bd

diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp
index 412a3627a0c..8e270fd1f71 100644
--- a/src/backends/drm/drm_backend.cpp
+++ b/src/backends/drm/drm_backend.cpp
@@ -168,9 +168,6 @@ void DrmBackend::handleUdevEvent()
             }
         } else if (device->action() == QLatin1StringView("change")) {
             DrmGpu *gpu = findGpu(device->devNum());
-            if (!gpu) {
-                gpu = addGpu(device->devNode());
-            }
             if (gpu && gpu->isActive()) {
                 qCDebug(KWIN_DRM) << "Received change event for monitored drm device" << gpu->drmDevice()->path();
                 updateOutputs(gpu);
@@ -246,7 +243,7 @@ void DrmBackend::updateOutputs(DrmGpu *onlyUpdate)
 
     for (auto it = m_gpus.begin(); it != m_gpus.end();) {
         DrmGpu *gpu = it->get();
-        if (gpu->isRemoved() || gpu->drmOutputs().isEmpty()) {
+        if (gpu->isRemoved()) {
             qCDebug(KWIN_DRM) << "Removing GPU" << it->get();
             const std::unique_ptr<DrmGpu> keepAlive = std::move(*it);
             it = m_gpus.erase(it);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.