neutrinolabs / xrdp

xrdp: an open source RDP server
http://www.xrdp.org/
Apache License 2.0
5.59k stars 1.73k forks source link

Enabled Glamor - Fails to take device /dev/dri/card0 #2165

Open Xboarder56 opened 2 years ago

Xboarder56 commented 2 years ago

I built xrdp + xorgrdp from the most recent releases utilizing this guide: https://gist.github.com/ehoppmann/0b10bcaa1e793f757d1caddbd7ec2300

However I seem to get permission errors for accessing /dev/dri/card0 but glamor_init returns ok, I don't see any improvement with CPU usage when moving windows around making me believe it's not actually accelerating anything.

I have made sure my user is in the video/render groups, I have also changed xorg to /usr/lib/xorg/Xorg. However thing seems to help.

[    83.230] Build Operating System: linux Ubuntu
[    83.230] Current Operating System: Linux nuc8i5beh 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64
[    83.230] Kernel command line: BOOT_IMAGE=/vmlinuz-5.4.0-100-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro
[    83.230] Build Date: 14 December 2021  02:14:13PM
[    83.230] xorg-server 2:1.20.13-1ubuntu1~20.04.2 (For technical support please see http://www.ubuntu.com/support)
[    83.230] Current version of pixman: 0.38.4
[    83.230]    Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
[    83.230] Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[    83.230] (++) Log file: ".xorgxrdp.10.log", Time: Wed Mar  2 22:16:55 2022
[    83.231] (++) Using config file: "/etc/X11/xrdp/xorg.conf"
[    83.231] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[    83.233] (**) Option "defaultserverlayout" "X11 Server"
[    83.233] (**) ServerLayout "X11 Server"
[    83.233] (**) |-->Screen "Screen (xrdpdev)" (0)
[    83.233] (**) |   |-->Monitor "Monitor"
[    83.236] (**) |   |-->Device "Video Card (xrdpdev)"
[    83.236] (**) |-->Input Device "xrdpMouse"
[    83.236] (**) |-->Input Device "xrdpKeyboard"
[    83.236] (**) Option "DontVTSwitch" "on"
[    83.236] (**) Option "AutoAddDevices" "off"
[    83.236] (**) Not automatically adding devices
[    83.236] (==) Automatically enabling devices
[    83.236] (==) Automatically adding GPU devices
[    83.236] (==) Automatically binding GPU devices
[    83.236] (==) Max clients allowed: 256, resource mask: 0x1fffff
[    83.236] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist.
[    83.236]    Entry deleted from font path.
[    83.236] (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist.
[    83.236]    Entry deleted from font path.
[    83.237] (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist.
[    83.237]    Entry deleted from font path.
[    83.237] (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist.
[    83.237]    Entry deleted from font path.
[    83.237] (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist.
[    83.237]    Entry deleted from font path.
[    83.237] (==) FontPath set to:
        /usr/share/fonts/X11/misc,
        /usr/share/fonts/X11/Type1,
        built-ins
[    83.237] (==) ModulePath set to "/usr/lib/xorg/modules"
[    83.237] (II) Loader magic: 0x55b5865a7020
[    83.237] (II) Module ABI versions:
[    83.237]    X.Org ANSI C Emulation: 0.4
[    83.237]    X.Org Video Driver: 24.1
[    83.237]    X.Org XInput driver : 24.1
[    83.237]    X.Org Server Extension : 10.0
[    83.239] (II) systemd-logind: took control of session /org/freedesktop/login1/session/c2
[    83.239] (II) xfree86: Adding drm device (/dev/dri/card0)
[    83.240] (EE) systemd-logind: failed to take device /dev/dri/card0: Operation not permitted
[    83.240] (EE) /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied
[    83.242] (--) PCI:*(0@0:2:0) 8086:3ea5:8086:2074 rev 1, Mem @ 0xbf000000/16777216, 0x80000000/268435456, I/O @ 0x00004000/64, BIOS @ 0x????????/131072
[    83.242] (II) "glx" will be loaded. This was enabled by default and also specified in the config file.
[    83.242] (II) LoadModule: "dbe"
[    83.242] (II) Module "dbe" already built-in
[    83.242] (II) LoadModule: "ddc"
[    83.242] (II) Module "ddc" already built-in
...skipping...
[    83.278] (II) Loading sub module "glamoregl"
[    83.278] (II) LoadModule: "glamoregl"
[    83.278] (II) Loading /usr/lib/xorg/modules/libglamoregl.so
[    83.284] (II) Module glamoregl: vendor="X.Org Foundation"
[    83.284]    compiled for 1.20.13, module version = 1.0.1
[    83.284]    ABI class: X.Org ANSI C Emulation, version 0.4
[    83.284] rdpPreInit: glamor module load ok
[    83.305] (II) XRDPDEV(0): glamor X acceleration enabled on Mesa Intel(R) Iris(R) Plus Graphics 655 (CFL GT3)
[    83.305] rdpPreInit: glamor init ok
[    83.308] rdpScreenInit: virtualX 800 virtualY 600 rgbBits 8 depth 24
[    83.308] rdpScreenInit: pfbMemory bytes 1920000
[    83.308] rdpScreenInit: pfbMemory 0x7f7778038010
[    83.311] rdpSimdInit: assigning yuv functions
[    83.311] rdpSimdInit: cpuid ax 1 cx 0 return ax 0x000806ea bx 0x04100800 cx 0x7ffafbbf dx 0xbfebfbff
[    83.311] rdpSimdInit: sse2 amd64 yuv functions assigned
[    83.334] rdpScreenInit: glamor_init ok
Nexarian commented 2 years ago

First, what video card(s) are you using? Glamor only works for AMD/Intel cards right now, not Nvidia. If you want Nvidia, there's a special prototype that you can use.

Xboarder56 commented 2 years ago

This one is with a Intel Iris 655 I have also tried a Radeon Pro V520 and get it to the same point with glamor init ok but high cpu usage and can't even move a window around without stuttering.

Nexarian commented 2 years ago

My bad! I see it in the logs now. I was searching for it :). Anyway, I assume that XRDP works if you disable glamor?

Xboarder56 commented 2 years ago

it actually works even like this just don't see any performance improvement. I have also tried the standard apt-get xrdp way and that works fine as well (lacking glamor though).

I'm testing this on ubuntu 20.04.4 LTS box with the default gnome desktop.

ubuntu@nuc8i5beh:~$ ls -lah /dev/dri/
total 0
drwxr-xr-x   3 root root        100 Mar  2 22:23 .
drwxr-xr-x  21 root root       4.3K Mar  2 22:32 ..
drwxr-xr-x   2 root root         80 Mar  2 22:23 by-path
crw-rw----+  1 root video  226,   0 Mar  2 22:37 card0
crw-rw----+  1 root render 226, 128 Mar  2 22:37 renderD128
ubuntu@nuc8i5beh:~$ groups ubuntu
ubuntu : ubuntu adm cdrom sudo dip video plugdev render lxd
ubuntu@nuc8i5beh:~$
matt335672 commented 2 years ago

@Xboarder56 - depending on how you user is added to those groups, the X server may not have inherited them. There are a few gremlins in this area (e.g. #1978)

You could try setting the permissions on the devices in /dev/dri/ directly with sudo chmod 666. It won't survive a reboot, but it might at least see if we can get over the permissions errors, and you can see if the performance is any better.

Xboarder56 commented 2 years ago

Thanks for the suggestion I tried changing it, then doing a sudo systemctl restart xrdp and no luck. Still getting the same permission denied error but further down in the xorg log glamor init ok.

matt335672 commented 2 years ago

It may not be a file permissions issue then. Or indeed, it might not be a problem at all. I don't personally know that bit of the code well enough to be sure.

You can find out whether the X server has got the correct group memberships by using ps -ef | grep Xorg to find the PID, and then looking in /proc/<pid>/status at the Groups line. More info on the proc status file is here.

jsorg71 commented 2 years ago

Glamor uses /dev/dri/renderD128 which is the render node. /dev/dri/cardX is used for 'mode setting'. Mode setting is changing the resolution and other things. xorgxrdp does not need access to /dev/dri/cardX, that error is normal. I don't know how to tell Xorg to not query those. I think it's trying to auto-detect stuff even tho we set that off in xorg.conf. I think you are getting an accelerated session. I like to use xvinfo to look for "GLAMOR Textured Video" to see if I got a glamor session. If it's software, it says xorgxrdp something. NVidia wrapper says nv something. Use glxgears to test performance, moving a window around might not be obvious. Note, an easy way to turn glamor off for testing, edit /etc/X11/xrdp/xorg.conf and change the renderD128 to something that does not exist.

Xboarder56 commented 2 years ago

So I actually ended up resolve this, but it seems to have hardly increased performance if at any. Is there anything specific I could check to try and see what the issue might be?

This is ubuntu 20.04 + ubuntu gnome variant. I also tried to get audio redirection working and modules are compiled but just doesn't seem to work. Checking audio settings I don't see any output device (not sure if this is an issue?)