From 52ec2ea5144d2a624ccfa2b828b15526da5add7f Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Sun, 10 May 2026 00:34:24 +0300 Subject: [PATCH] kdrive: Don't enable drm master by default On some cards, `drmSetMaster` hangs. Since Xfbdev does not set the video card mode, it does not need master permissions. As such, we can just drop master at the begining to not conflict with other drm users. For any cards that do require master permissions, Xfbdev can still do the `drm{Set,Drop}Master` dance on {Enter,Leave}VT, with a command line argument. Fixes: https://github.com/X11Libre/xserver/issues/2711 Signed-off-by: stefan11111 --- hw/kdrive/fbdev/fb_glamor.c | 15 +++++++++++---- hw/kdrive/fbdev/fbdev.h | 1 + hw/kdrive/fbdev/fbinit.c | 7 +++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hw/kdrive/fbdev/fb_glamor.c b/hw/kdrive/fbdev/fb_glamor.c index 1c05618923..236a702bb1 100644 --- a/hw/kdrive/fbdev/fb_glamor.c +++ b/hw/kdrive/fbdev/fb_glamor.c @@ -22,10 +22,13 @@ #include #endif +#include + char *fbdev_glvnd_provider = NULL; char *fbdev_dri_path = NULL; bool fbdev_auto_dri3 = FALSE; +bool fbdev_drm_master = FALSE; bool es_allowed = TRUE; bool force_es = FALSE; bool fbGlamorAllowed = TRUE; @@ -43,10 +46,14 @@ fbdevInitAccel(ScreenPtr pScreen) scrpriv->dri_fd = open(fbdev_dri_path, O_RDWR); if (scrpriv->dri_fd >= 0) { #ifdef WITH_LIBDRM - drmSetMaster(scrpriv->dri_fd); + if (fbdev_drm_master) { + drmSetMaster(scrpriv->dri_fd); + } else { + drmDropMaster(scrpriv->dri_fd); + } #endif } else { - perror("open"); + LogMessage(X_WARNING, "Could not open %s: %s\n", fbdev_dri_path, strerror(errno)); } } else { scrpriv->dri_fd = -1; @@ -115,7 +122,7 @@ fbdevEnableAccel(ScreenPtr pScreen) KdScreenInfo *screen = pScreenPriv->screen; FbdevScrPriv *scrpriv = screen->driver; - if (scrpriv->dri_fd >= 0) { + if (fbdev_drm_master && scrpriv->dri_fd >= 0) { drmSetMaster(scrpriv->dri_fd); } #endif @@ -129,7 +136,7 @@ fbdevDisableAccel(ScreenPtr pScreen) KdScreenInfo *screen = pScreenPriv->screen; FbdevScrPriv *scrpriv = screen->driver; - if (scrpriv->dri_fd >= 0) { + if (fbdev_drm_master && scrpriv->dri_fd >= 0) { drmDropMaster(scrpriv->dri_fd); } #endif diff --git a/hw/kdrive/fbdev/fbdev.h b/hw/kdrive/fbdev/fbdev.h index 6254684ba9..eb829687e0 100644 --- a/hw/kdrive/fbdev/fbdev.h +++ b/hw/kdrive/fbdev/fbdev.h @@ -60,6 +60,7 @@ extern Bool fbDisableShadow; extern char *fbdev_glvnd_provider; extern char *fbdev_dri_path; extern bool fbdev_auto_dri3; +extern bool fbdev_drm_master; extern bool es_allowed; extern bool force_es; extern bool fbGlamorAllowed; diff --git a/hw/kdrive/fbdev/fbinit.c b/hw/kdrive/fbdev/fbinit.c index 010db9f873..46c94d038a 100644 --- a/hw/kdrive/fbdev/fbinit.c +++ b/hw/kdrive/fbdev/fbinit.c @@ -72,6 +72,8 @@ ddxUseMsg(void) ("-fb path Framebuffer device to use. Defaults to /dev/fb0\n"); ErrorF ("-dri Optional drm device path to use\n"); + ErrorF + ("-drm-master Enable master permissions on the fd used for dri\n"); ErrorF ("-noshadow Disable the ShadowFB layer if possible\n"); ErrorF @@ -140,6 +142,11 @@ ddxProcessArgument(int argc, char **argv, int i) } } + if (!strcmp(argv[i], "-drm-master")) { + fbdev_drm_master = TRUE; + return 1; + } + if (!strcmp(argv[i], "-force-gl")) { es_allowed = FALSE; return 1;