Drakulix / nvscreencopy

A userspace utility to mirror outputs on wayland to nvidia gpus
MIT License
7 stars 0 forks source link

Error loading resource handles on device `Some("/dev/dri/card0")` #1

Closed RomeoV closed 2 years ago

RomeoV commented 2 years ago

Hi, thanks for working on this!

I was looking into trying this out, since it seems to enable using the HDMI port connected to an nvidia card even on laptops with optimus (Lenovo P1 in my case). This would be very exciting! Unfortunately, I get an error:

[romeo@Romeo-P1 release]$ ./nvscreencopy 
Jul 23 01:50:30.634 INFO Found nvidia gpu /dev/dri/card0
Jul 23 01:50:30.634 INFO DrmDevice initializing, smithay_module: backend_drm
Jul 23 01:50:30.634 INFO Dropping device: Some("/dev/dri/card0"), smithay_module: backend_drm
Error: DRM access error: Error loading resource handles on device `Some("/dev/dri/card0")` (unknown system error: EOPNOTSUPP: Operation not supported on transport endpoint)

Caused by:
    unknown system error: EOPNOTSUPP: Operation not supported on transport endpoint
[romeo@Romeo-P1 release]$ ./nvscreencopy  list-connectors
# the same output

Here's the setup steps to get there:

[romeo@Romeo-P1 ~]$ env | grep WLR_
WLR_DRM_DEVICES=/dev/dri/card1
[romeo@Romeo-P1 ~]$ sudo modprobe nvidia-drm modeset=1
[sudo] password for romeo: 
[romeo@Romeo-P1 release]$ swaymsg -t get_outputs | grep Output
Output eDP-1 'Unknown 0x06AA 0x00000000' (focused)
Output HEADLESS-1 'headless headless '
[romeo@Romeo-P1 release]$ ./nvscreencopy list-sources
Unknown
headless
[romeo@Romeo-P1 ~]$ ./nvscreencopy
# see above

And some system information:

[romeo@Romeo-P1 release]$ pacman -Qi sway | head -n 2
Name            : sway
Version         : 1:1.7-9
[romeo@Romeo-P1 release]$ pacman -Qi wlroots | head -n 2
Name            : wlroots
Version         : 0.15.1-6

I tried to understand where this error is coming from, but running it with RUST_BACKTRACE=1 didn't yield anything (perhaps the error occurs in some C code instead?) and I'm not too familiar with the whole concepts of DRMs etc. But I would be happy to look into some details if you can point me to the problem.

Cheers, Romeo

Drakulix commented 2 years ago

Hi Romeo, some additional infos that could help us figure out whats wrong:

RomeoV commented 2 years ago

Thanks for getting back to me! I'm not sure what changed, but I was now able to load the nvidia-drm module after explicitly unloading it first. Now I am getting some more output, but unfortunately it ends up in the error Failed to lookup NVKMS gem object for export: 0x00000001.

Nvidia driver:

[romeo@Romeo-P1 ~]$ pacman -Qi nvidia | head -n2
Name            : nvidia
Version         : 515.57-7

DMESG LOG (containing error)

[romeo@Romeo-P1 ~]$ sudo modprobe -r nvidia-drm
[romeo@Romeo-P1 ~]$ sudo modprobe nvidia-drm modeset=1
[romeo@Romeo-P1 ~]$ sudo dmesg
[36523.639201] [drm] [nvidia-drm] [GPU ID 0x00000100] Unloading driver
[36523.688910] nvidia-modeset: Unloading
[36523.729733] audit: type=1106 audit(1658574975.071:170): pid=8584 uid=1000 auid=1000 ses=1 msg='op=PAM:session_close grantors=pam_systemd_home,pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[36523.729845] audit: type=1104 audit(1658574975.071:171): pid=8584 uid=1000 auid=1000 ses=1 msg='op=PAM:setcred grantors=pam_faillock,pam_permit,pam_faillock acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[36527.064179] audit: type=1101 audit(1658574978.404:172): pid=8637 uid=1000 auid=1000 ses=1 msg='op=PAM:accounting grantors=pam_unix,pam_permit,pam_time acct="romeo" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[36527.064465] audit: type=1110 audit(1658574978.404:173): pid=8637 uid=1000 auid=1000 ses=1 msg='op=PAM:setcred grantors=pam_faillock,pam_permit,pam_env,pam_faillock acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[36527.064521] audit: type=1105 audit(1658574978.404:174): pid=8637 uid=1000 auid=1000 ses=1 msg='op=PAM:session_open grantors=pam_systemd_home,pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[36527.099889] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  515.57  Wed Jun 22 22:31:08 UTC 2022
[36527.103028] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver
[36527.326099] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:01:00.0 on minor 0
[36527.326674] audit: type=1106 audit(1658574978.667:175): pid=8637 uid=1000 auid=1000 ses=1 msg='op=PAM:session_close grantors=pam_systemd_home,pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[36527.462832] [drm:nv_drm_gem_export_nvkms_memory_ioctl [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000100] Failed to lookup NVKMS gem object for export: 0x00000001
[36532.242367] kauditd_printk_skb: 1 callbacks suppressed
[36532.242368] audit: type=1101 audit(1658574983.584:177): pid=8650 uid=1000 auid=1000 ses=1 msg='op=PAM:accounting grantors=pam_unix,pam_permit,pam_time acct="romeo" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[36532.242578] audit: type=1110 audit(1658574983.584:178): pid=8650 uid=1000 auid=1000 ses=1 msg='op=PAM:setcred grantors=pam_faillock,pam_permit,pam_env,pam_faillock acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[36532.242630] audit: type=1105 audit(1658574983.584:179): pid=8650 uid=1000 auid=1000 ses=1 msg='op=PAM:session_open grantors=pam_systemd_home,pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'

nvscreencopy log

[romeo@Romeo-P1 release]$ swaymsg create_output
[romeo@Romeo-P1 release]$ ./nvscreencopy 
Jul 23 13:18:33.092 INFO Found nvidia gpu /dev/dri/card0
Jul 23 13:18:33.092 INFO DrmDevice initializing, smithay_module: backend_drm
Jul 23 13:18:33.092 WARN Unable to become drm master, assuming unprivileged mode, smithay_module: backend_drm
Jul 23 13:18:33.100 INFO Connected: HDMIA-2
Jul 23 13:18:33.101 INFO Initializing drm surface (crtc::Handle(40):plane::Handle(33)) with mode Mode { name: "1920x1080", clock: 148500, size: (1920, 1080), hsync: (2008, 2052, 2200), vsync: (1084, 1089, 1125), hskew: 0, vscan: 0, vrefresh: 60 } and connectors [connector::Handle(92)], drm_module: surface, smithay_module: backend_drm_atomic, smithay_module: backend_drm
Jul 23 13:18:33.101 INFO Adding connector: HDMIA, drm_module: surface, smithay_module: backend_drm_atomic, smithay_module: backend_drm
Jul 23 13:18:33.101 INFO Setting new mode: "1920x1080", drm_module: surface, smithay_module: backend_drm_atomic, smithay_module: backend_drm
Jul 23 13:18:33.101 WARN New screen configuration invalid!:
    AtomicModeReq {
    objects: [
        33,
        40,
        92,
    ],
    count_props_per_object: [
        10,
        2,
        1,
    ],
    props: [
        property::Handle(
            9,
        ),
        property::Handle(
            10,
        ),
        property::Handle(
            11,
        ),
        property::Handle(
            12,
        ),
        property::Handle(
            13,
        ),
        property::Handle(
            14,
        ),
        property::Handle(
            15,
        ),
        property::Handle(
            16,
        ),
        property::Handle(
            17,
        ),
        property::Handle(
            20,
        ),
        property::Handle(
            22,
        ),
        property::Handle(
            23,
        ),
        property::Handle(
            20,
        ),
    ],
    values: [
        0,
        0,
        125829120,
        70778880,
        0,
        0,
        1920,
        1080,
        93,
        40,
        1,
        95,
        40,
    ],
}
    Atomic Test failed for new properties on crtc (crtc::Handle(40))
, drm_module: surface, smithay_module: backend_drm_atomic, smithay_module: backend_drm
Jul 23 13:18:33.101 WARN Failed to clear plane plane::Handle(33) on crtc::Handle(40): DRM access error: Failed to commit on clear_plane on device `Some("/dev/dri/card0")` (permission denied), drm_module: surface, smithay_module: backend_drm_atomic, smithay_module: backend_drm
Jul 23 13:18:33.101 WARN Unable to disable connectors: permission denied, drm_module: surface, smithay_module: backend_drm_atomic, smithay_module: backend_drm
Jul 23 13:18:33.101 ERRO Failed to restore previous state. Error: permission denied, drm_module: device, smithay_module: backend_drm_atomic, smithay_module: backend_drm
Jul 23 13:18:33.101 INFO Dropping device: Some("/dev/dri/card0"), smithay_module: backend_drm
Error: Atomic Test failed for new properties on crtc (crtc::Handle(40))

If you have some clue what's going on that's great, but otherwise no need to loose sleep over it.

Drakulix commented 2 years ago

I think the dmesg error is just an artifact of one of the codepaths nvscreencopy is trying to use. That is not fatal.

The error indicates that some of the settings nvscreencopy is applying aren't working.

It could be as simple as the resolution not matching (though full hd is widely supported) or something really obscure.

Really difficult to debug from a distance, sorry :/

RomeoV commented 2 years ago

Alright, thanks for looking into it nonetheless. I'll close the issue, but may reopen if I there is any progress.