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: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (other bugs)
Version First Reported In: 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: 2025-12-13 20:34 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.4.0
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.
Comment 1 Zamundaaa 2025-10-14 16:27:20 UTC
Does this still happen in Plasma 6.4? KWin has code to clean up all resources when a GPU is removed, so it shouldn't be used anymore after a remove event.

If it does still happen, please attach the output of
journalctl --user-unit plasma-kwin_wayland --boot 0
after sending the remove event.
Comment 2 Wind He 2025-10-18 04:11:39 UTC
It seems fixed on Plasma 6.4
Thank you !