Why does KMS drmModeSetCrtc() fail with permission denied while running in X11 session?
Asked Answered
H

2

5

The title already implies the question, so what is blocking the execution from the sample program in this repo https://github.com/dvdhrm/docs/tree/master/drm-howto

It's a simple program showing KMS in action, so I downloaded it, compiled it and gave it a run. This was the output:

michael@lord:~/Downloads/docs/drm-howto$ sudo ./modeset
[sudo] password for michael: 
using card '/dev/dri/card0'
mode for connector 59 is 1920x1080
ignoring unused connector 68
ignoring unused connector 71
ignoring unused connector 75
cannot set CRTC for connector 59 (13): Permission denied
exiting

Also note that I have a running X11 session on my machine. It seems X is already using the device /dev/dri/card0 and blocks it for all other programs.

Here is my video card:

michael@lord:~/Downloads/docs/drm-howto$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)

I have also added i915.modeset=1 into /etc/initramfs-tools/modules and rebuilt it with sudo update-initramfs -u so it loads the driver from inside my kernel and not from the xorg side.

There is also the possibility that my driver doesn't support KMS but lspci has shown that I only have an internal intel graphics card installed. So I sticked with the xorg core display driver package which is installed by default from xserver-xorg-core.

None of these changes have taken affect. The only way I can execute those examples is by killing the xorg session and let it run in tty.

Any ideas?

Holmium answered 21/10, 2018 at 15:56 Comment(0)
Z
5

It works as expected. Only DRM-Master is allowed to do modesetting, and there can only be one DRM-Master. X is already master.

You can become master using drmSetMaster() or implicitly by opening the the primary device node when there is no current master. (The example code becomes DRM-Master implicitly.)

See also the drm-kms(7) man page.

Zap answered 24/10, 2018 at 12:40 Comment(4)
In the example, where/how did you insert the call to drmSetMaster()? I'm trying to run under X.Enrapture
@RyanMcClue You can't. You need to be master, but X is already master.Zap
How would a game become master then? Is direct rendering by a video game from a x11/wayland session not a covered use case? oOIzzy
Great answer! I did not have to stop anything, I just switched to tty1, and during the switch I saw the video mode change and my monitor reinitialize. Then I could just run my master application and it worked (Raspberry OS Bookworm, Wayland).Sterne
E
1

To execute any modeset application first disable the display server by

sudo systemctl stop gdm3

sudo systemctl stop lightdm

switch to command line through eighter CTL + ALT + F1, CTL + ALT + F2, CTL + ALT + F3

and execute $ sudo ./modeset

Eldoneldora answered 12/12, 2022 at 7:0 Comment(1)
In fact I just used CTL + ALT + F2 and then ran the demo, it worked even without sudo. One thing is that it took me 10 seconds to switch back to X after the demo completed.Grau

© 2022 - 2024 — McMap. All rights reserved.