Bug 102976 - nvidia_drm remains in use for no apparent reason after Xorg shutdown.
Summary: nvidia_drm remains in use for no apparent reason after Xorg shutdown.
Status: RESOLVED MOVED
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/modesetting (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-25 13:25 UTC by Antonio Orefice
Modified: 2018-12-13 18:10 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Antonio Orefice 2017-09-25 13:25:43 UTC
nvidia_drm remains in use for no apparent reason after Xorg shutdown.

Hi, i'm trying to Nvidia "Reverse Prime" with a gtx750 + intel hd4000
Displays are attached to the intel connectors.
What i've done so far:

My xorg.conf:
##########################
Section "Module"
	Load "modesetting"
EndSection

Section "Device"
	Identifier "nvidia"
	Driver "nvidia"
	#BusID ""
	Option "AllowEmptyConfiguration"
EndSection
##########################



my xinitrc:
##########################
export DISPLAY=:0.0 
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
openbox --replace &
setxkbmap it
xset mouse 1.4 4
exec sudo -u koko lxterminal &
p1=$!
wait $p1
##########################



System starts with intel as the primary adapter, nvidia modules are NOT autoloaded.

So i do:
##########################
modprobe nvidia-drm
modprobe nvidia_modeset
modprobe nvidia
##########################


Prime synchronization is working fine:
##########################
cat /sys/module/nvidia_drm/parameters/modeset 
Y
##########################


All is good whitin the X server, and works as expected, but what seems wrong to me is that as i exit the Xorg session, nvidia_drm remains in use.
##########################
lsmod | grep nvidia
nvidia_drm             45056  1
nvidia_modeset        798720  1 nvidia_drm
nvidia              11476992  1 nvidia_modeset
drm_kms_helper        126976  2 i915,nvidia_drm
drm                   299008  7 i915,ttm,nvidia_drm,drm_kms_helper
##########################


It took me a while to understand, but there was an open handle to /dev/dri/card1 (nvidia):
##########################
# lsof -n | grep "/dev/dri/card/1"
systemd      1           root   19u      CHR              226,1      0t0            21785 /dev/dri/card1
##########################

It prevents me from unloading nvidia_drm and i need to do that to pass the gpu to a libvirt domain.

Manually attach to systemd and closing the handle makes it work, but i cannot do that ugly hacks all of the times.
Note that the open handles i am speaking about increases by on on every xorg restart.

Who is to blame? nvidia driver? Modesetting driver?
Comment 1 Antonio Orefice 2017-09-25 13:26:53 UTC
Sorry, I forgot to add that i'm running xorg-server 1.19 on linux 4.11.9
Comment 2 Antonio Orefice 2017-09-25 16:13:30 UTC
As stated here, stopping systemd-logind frees the handle:

https://devtalk.nvidia.com/default/topic/1024407/linux/nvidia_drm-remains-in-use-for-no-apparent-reason-after-xorg-shutdown-/?offset=6#5211187

...so nmaybe is a systemd issue?
https://github.com/systemd/systemd/issues/6908ù

Sorry for crossposting.
Comment 3 GitLab Migration User 2018-12-13 18:10:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/xserver/issues/34.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.