core,backends/drm: Improve error logging

Write something into the logs when a call goes awry, it can save some
time to the next person porting kwin to a dysfunctional driver.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
This commit is contained in:
Aleix Pol Gonzalez 2024-06-03 08:14:32 +00:00
parent 31a3961c4c
commit 26d9361695
4 changed files with 17 additions and 3 deletions

View file

@ -264,6 +264,7 @@ bool DrmConnector::updateProperties()
path.update(props);
if (gpu()->atomicModeSetting() && !crtcId.isValid()) {
qCWarning(KWIN_DRM) << "Failed to update the basic connector properties (CRTC_ID)";
return false;
}

View file

@ -49,7 +49,11 @@ bool DrmCrtc::updateProperties()
degammaLut.update(props);
degammaLutSize.update(props);
return !gpu()->atomicModeSetting() || (modeId.isValid() && active.isValid());
const bool ret = !gpu()->atomicModeSetting() || (modeId.isValid() && active.isValid());
if (!ret) {
qCWarning(KWIN_DRM) << "Failed to update the basic crtc properties. modeId:" << modeId.isValid() << "active:" << active.isValid();
}
return ret;
}
drmModeModeInfo DrmCrtc::queryCurrentMode()

View file

@ -100,6 +100,7 @@ bool DrmPlane::updateProperties()
if (!type.isValid() || !srcX.isValid() || !srcY.isValid() || !srcW.isValid() || !srcH.isValid()
|| !crtcX.isValid() || !crtcY.isValid() || !crtcW.isValid() || !crtcH.isValid() || !fbId.isValid()) {
qCWarning(KWIN_DRM) << "Failed to update the basic plane properties";
return false;
}

View file

@ -9,6 +9,7 @@
#include "drmdevice.h"
#include "gbmgraphicsbufferallocator.h"
#include "utils/common.h"
#include <fcntl.h>
#include <gbm.h>
@ -73,19 +74,26 @@ std::unique_ptr<DrmDevice> DrmDevice::openWithAuthentication(const QString &path
{
FileDescriptor fd(::open(path.toLocal8Bit(), O_RDWR | O_CLOEXEC));
if (!fd.isValid()) {
qCWarning(KWIN_CORE) << "Failed to open drm node:" << path;
return nullptr;
}
struct stat buf;
if (fstat(fd.get(), &buf) == -1) {
qCWarning(KWIN_CORE) << "Failed to fstat drm fd" << path;
return nullptr;
}
if (authenticatedFd != -1) {
drm_magic_t magic;
drmGetMagic(fd.get(), &magic);
drmAuthMagic(authenticatedFd, magic);
if (drmGetMagic(fd.get(), &magic) < 0) {
qCDebug(KWIN_CORE) << "Failed to get the drm magic token for" << path;
}
if (drmAuthMagic(authenticatedFd, magic) < 0) {
qCWarning(KWIN_CORE) << "Failed to authenticate the drm magic token. path:" << path << "error:" << strerror(errno);
}
}
gbm_device *device = gbm_create_device(fd.get());
if (!device) {
qCWarning(KWIN_CORE) << "Failed to create gbm device for" << path;
return nullptr;
}
return std::unique_ptr<DrmDevice>(new DrmDevice(path, buf.st_rdev, std::move(fd), device));