drm_lease_v1: avoid waking GPU when creating lease device

This is a slight downgrade to the check since it's technically possible
for the FD returned by open to be a DRM master and policy preventing the
downgrade. With this patch, it's only noticed afterwards.

In typical modern environments, all FDs should be non-master right away.

Signed-off-by: Leon M. Busch-George <leon@georgemail.eu>
This commit is contained in:
Leon M. Busch-George 2026-06-08 14:16:51 +02:00
parent a94cd29eb1
commit 75f0571eb3

View file

@ -1,4 +1,5 @@
#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@ -586,15 +587,15 @@ static void drm_lease_device_v1_create(struct wlr_drm_lease_v1_manager *manager,
struct wlr_backend *backend) {
struct wlr_drm_backend *drm_backend = get_drm_backend_from_backend(backend);
// Make sure we can get a non-master FD for the DRM backend. On some setups
// we don't have the permission for this.
int fd = wlr_drm_backend_get_non_master_fd(backend);
if (fd < 0) {
wlr_log(WLR_INFO, "Skipping %s: failed to get read-only DRM FD",
// Make sure we can access the device without opening it to avoid
// potentially waking the GPU from suspend.
// A non-master FD is required later which is what open should already
// yield on modern systems.
if (faccessat(AT_FDCWD, drm_backend->name, R_OK|W_OK, 0) < 0) {
wlr_log(WLR_INFO, "Skipping %s: cannot access DRM device",
drm_backend->name);
return;
}
close(fd);
wlr_log(WLR_DEBUG, "Creating wlr_drm_lease_device_v1 for %s",
drm_backend->name);