Bug 441372 - optimus laptop: nvidia driver is unnecessarily loaded/grabbed by kwin on an intel GPU session
Summary: optimus laptop: nvidia driver is unnecessarily loaded/grabbed by kwin on an i...
Status: RESOLVED WORKSFORME
Alias: None
Product: kwin
Classification: Plasma
Component: platform-drm (show other bugs)
Version: 5.22.4
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-22 15:29 UTC by Romain D.
Modified: 2023-05-02 03:46 UTC (History)
5 users (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 Romain D. 2021-08-22 15:29:29 UTC
SUMMARY
(This indirectly causes my laptop to not suspend any more, which seems related to https://bugzilla.rpmfusion.org/show_bug.cgi?id=6066)

As it appears, only on a Wayland session, the nvidia kernel driver gets loaded even though I am not using the discrete GPU of my laptop

STEPS TO REPRODUCE
1. After a cold boot, from SDDM, jump to a non-graphical terminal and observe that `lsmod | grep nvidia` returns nothing
2. Then, login into a KDE-Wayland session from SDDM, switch to the same non-graphical terminal and observe that the same command indicates "nvidia" and "nvidia_uvm" to be loaded
3. Note that `modprobe -r nvidia` fails with "modprobe: FATAL: Module nvidia is in use."
4. Note from the system info that the session runs on intel and not actually on nvidia
5. Log-out from the Wayland shell back into SDDM
6. Then, `modprobe -r nvidia` completes successfully
7. Log into an X11 shell, and observe that no nvidia driver is loaded

OBSERVED RESULT
The nvidia driver is unnecessarily loaded on Wayland

EXPECTED RESULT
The nvidia driver to be loaded only on demand (through PRIME_RENDER_OFFLOAD, optirun & al.) on such a machine with a discrete GPU

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.13.10-200.fc34.x86_64/plasma-desktop-5.22.4-1.fc34.x86_64
KDE Frameworks Version: kf5-kwindowsystem-5.85.0-1.fc34.x86_64
Qt Version: qt5-qtbase-5.15.2-16.fc34.x86_64

ADDITIONAL INFORMATION
xorg-x11-drv-nvidia-470.63.01-1.fc34.x86_64
User Eighth_Doctor‎ on LiberaChat reporting that this might have to do with display enumeration
Comment 1 Zamundaaa 2021-08-23 21:37:44 UTC
> User Eighth_Doctor‎ on LiberaChat reporting that this might have to do with display enumeration

That is correct. We have to load the GPU to be able to list its outputs; when there are no outputs we do unload it again though.
I double checked and there is a bug in the gpu removal code but it's pretty unlikely to cause this as it's mostly a memory leak.
Comment 2 Zamundaaa 2021-08-24 12:37:04 UTC
Git commit fbff8636b9a1d21772fccaacb8b2a55aa517aa90 by Xaver Hugl.
Committed on 24/08/2021 at 12:36.
Pushed by zamundaaa into branch 'master'.

platforms/drm: fix gpu removal

As soon as m_backends.removeOne(*it) returns, "it" no longer
points to the same value.

M  +3    -3    src/plugins/platforms/drm/egl_multi_backend.cpp

https://invent.kde.org/plasma/kwin/commit/fbff8636b9a1d21772fccaacb8b2a55aa517aa90
Comment 3 Zamundaaa 2021-08-24 12:37:33 UTC
Git commit 5611c905cea800ee57ba5690c3ec75b086258612 by Xaver Hugl.
Committed on 24/08/2021 at 12:37.
Pushed by zamundaaa into branch 'Plasma/5.22'.

platforms/drm: fix gpu removal

As soon as m_backends.removeOne(*it) returns, "it" no longer
points to the same value.


(cherry picked from commit fbff8636b9a1d21772fccaacb8b2a55aa517aa90)

M  +3    -3    src/plugins/platforms/drm/egl_multi_backend.cpp

https://invent.kde.org/plasma/kwin/commit/5611c905cea800ee57ba5690c3ec75b086258612
Comment 4 Zamundaaa 2023-03-27 16:37:33 UTC
Is this still happening on Plasma 5.27?
Comment 5 Romain D. 2023-04-02 12:15:00 UTC
(In reply to Zamundaaa from comment #4)
> Is this still happening on Plasma 5.27?

Hard for me to reproduce nowadays, because my distro switched to sddm-wayland since, and current power management features require the module to be loaded at all times (AFAIU). I'd say it's ok to close if nobody objects.
Comment 6 Bug Janitor Service 2023-04-17 03:45:33 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Bug Janitor Service 2023-05-02 03:46:14 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!