[plasma/kwin] src: core/gpumanager: show notifications about GPU resets
Xaver Hugl <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit ef89a7b1559ba073310524d129dd383b7b1519ef by Xaver Hugl.
Committed on 18/08/2026 at 11:30.
Pushed by zamundaaa into branch 'master'.
core/gpumanager: show notifications about GPU resets
This is better than the previous notification, since we can actually
show it for all GPUs, and even if KWin wasn't affected by the reset.
M +0 -8 src/compositor.cpp
M +32 -0 src/core/gpumanager.cpp
https://invent.kde.org/plasma/kwin/-/commit/ef89a7b1559ba073310524d129dd383b7b1519ef
diff --git a/src/compositor.cpp b/src/compositor.cpp
index 8137aa00eaa..54df6209e88 100644
--- a/src/compositor.cpp
+++ b/src/compositor.cpp
@@ -42,11 +42,6 @@
#include "workspace.h"
#include <KCrash>
-#if KWIN_BUILD_NOTIFICATIONS
-#include <KLocalizedString>
-#include <KNotification>
-#endif
-
#include <QQuickWindow>
#include <optional>
#include <ranges>
@@ -756,9 +751,6 @@ void Compositor::composite(RenderLoop *renderLoop)
{
if (m_backend->checkGraphicsReset()) {
qCDebug(KWIN_CORE) << "Graphics reset occurred";
-#if KWIN_BUILD_NOTIFICATIONS
- KNotification::event(QStringLiteral("graphicsreset"), i18n("Desktop effects were restarted due to a graphics reset"));
-#endif
reinitialize();
return;
}
diff --git a/src/core/gpumanager.cpp b/src/core/gpumanager.cpp
index 9051ffae14e..d70a3a2481d 100644
--- a/src/core/gpumanager.cpp
+++ b/src/core/gpumanager.cpp
@@ -25,6 +25,11 @@
#include <linux/udmabuf.h>
#endif
+#if KWIN_BUILD_NOTIFICATIONS
+#include <KLocalizedString>
+#include <KNotification>
+#endif
+
namespace KWin
{
@@ -250,6 +255,33 @@ void GpuManager::scanForRenderDevices()
void GpuManager::handleUdevEvent()
{
while (auto udevDevice = m_udevMonitor->getDevice()) {
+ if (udevDevice->action() == QLatin1StringView("change")) {
+ auto gpu = compatibleRenderDevice(udevDevice->devNum());
+ if (!gpu) {
+ continue;
+ }
+ const auto props = udevDevice->properties();
+ const auto it = props.find(QByteArrayLiteral("WEDGED"));
+ if (it == props.end()) {
+ continue;
+ }
+ const auto actions = it->split(',');
+ if (actions.isEmpty()) {
+ qCWarning(KWIN_CORE, "Got a WEDGED event without any actions?");
+ return;
+ }
+ qCWarning(KWIN_CORE) << "GPU" << gpu->name() << gpu->path() << "was wedged:" << actions;
+#if KWIN_BUILD_NOTIFICATIONS
+ // TODO add the app name once we can get that information
+ const auto sameNameCount = std::ranges::count(m_renderDevices, gpu->name(), &RenderDevice::name);
+ if (sameNameCount > 1) {
+ KNotification::event(QStringLiteral("graphicsreset"), i18nc("@info: status", "Graphics card “%1” (%2) was reset", gpu->name(), gpu->path()));
+ } else {
+ KNotification::event(QStringLiteral("graphicsreset"), i18nc("@info: status", "Graphics card “%1” was reset", gpu->name()));
+ }
+#endif
+ continue;
+ }
int devNum = -1;
const bool isPrimaryNode = sscanf(udevDevice->sysName().data(), DRM_PRIMARY_MINOR_NAME "%d", &devNum) == 1;
if (isPrimaryNode) {