Bug 496738 - kwin_wayland don't release /dev/nvidia0 after sending 'remove' to udev event
Summary: kwin_wayland don't release /dev/nvidia0 after sending 'remove' to udev event
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-27 03:54 UTC by Wind He
Modified: 2024-11-27 17:08 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wind He 2024-11-27 03:54:01 UTC
SUMMARY
Sending 'remove' to nvidia driver will update screen output, but kwin_wayland process is still using /dev/nvidia0 so I can't remove nvidia driver.

STEPS TO REPRODUCE
1. echo -n "remove" > /sys/bus/pci/devices/0000:01:00.0/drm/card0/uevent
2. fuser -v /dev/nvidia0

OBSERVED RESULT
                               USER        PID      ACCESS COMMAND
/dev/nvidia0:        heddxh    1354   F...m      kwin_wayland
                               heddxh    13461 F....         electron

Running nvidia-smi show "No running processes found".

So due to there are processes using this device, I can't remove nvidia driver. If I run `echo "$gpu" > "/sys/bus/pci/devices/$gpu/driver/unbind"` , system will hang with kernel warning spamming the journal.

EXPECTED RESULT
kwin_wayland will release the nvidia card when receiving remove udev event.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.11.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i7-12700H
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: HP
Product Name: OMEN by HP Laptop 16-b1xxx

ADDITIONAL INFORMATION
My system is hybrid gpu, intel + nvidia, booting gpu in intel. I want to dynamically binding my nvidia card to vfio-pci, and can also rebind to nvidia driver when vm is off and I want to use it on host.
I also have __EGL_VENDOR_IBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json as env var to avoid EGL program using nvidia card. And I pass Environment="KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0" to kwin_wayland, card0 is nvidia and card1 is intel.