bumblebee team mailing list archive
-
bumblebee team
-
Mailing list archive
-
Message #00471
[Bug 1791883] [NEW] Feature request: modify bumblebee to unload nvidia modules if power management is done by the kernel
Public bug reported:
It would be great to implement something like feature request
bumblebee#978 (https://github.com/Bumblebee-
Project/Bumblebee/issues/978), because bbswitch doesn't work with later
kernels unless you disable pci power management at boot with
pcie_port_pm=off added to GRUB_CMDLINE_LINUX_DEFAULT in
/etc/default/grub (see https://github.com/Bumblebee-
Project/bbswitch/issues/140 for more details) and in fact later kernels
automatically activate and suspend the card as required, replacing the
functionality of bbswitch.
To confirm this, I tried modifying the Ubuntu bumblebee source package,
but it fails to build in Cosmic on my laptop with a number of reference
errors like so (even though I do have libkmod2 installed):
/usr/bin/ld: src/module.o: in function `module_is_loaded':
/home/rocko/src/bumblebee-3.2.1/src/module.c:46: undefined reference to `kmod_module_new_from_name'
So I modified the bumblebee develop branch from git (https://github.com
/Bumblebee-Project/Bumblebee/tree/develop) with the attached patch and
built it to confirm that bumblebee works when allowing the kernel to
manage power management. The most relevant part of the patch is this:
@@ -227,8 +228,12 @@ static void switch_and_unload(void)
char driver[BUFFER_SIZE];
if (bb_config.pm_method == PM_DISABLED && bb_status.runmode != BB_RUN_EXIT) {
- /* do not disable the card if PM is disabled unless exiting */
- return;
+ /* RR: unload the driver loaded by the graphics card */
+ bb_log(LOG_INFO, "PM disabled, unloading nvidia drivers anyway\n");
+ if (pci_get_driver(driver, pci_bus_id_discrete, sizeof driver)) {
+ module_unload(driver);
+ }
+ return;
}
//if card is on and can be switched, switch it off
but I have also included changing configuration defaults like
PM_METHOD=none and setting up the Ubuntu library paths for nvidia and
primus in Ubuntu 18.04/18.10 (see
https://bugs.launchpad.net/ubuntu/+source/bumblebee/+bug/1758243 for
why).
Then I configured and built it with:
autoreconf -f
./configure CONF_DRIVER=nvidia CONF_DRIVER_MODULE_NVIDIA=nvidia CONF_PM_METHOD=none \
CONF_LDPATH_NVIDIA=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu \
CONF_MODPATH_NVIDIA=/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules,/usr/lib/xorg/modules/input \
--prefix=/usr --sysconfdir=/etc
make clean
make && sudo make install
I disabled bbswitch via /etc/modprobe.d/bbswitch:
blacklist bbswitch
and then on reboot, optirun seems to be working fine:
$ optirun glxinfo|grep NVIDIA
server glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation
OpenGL core profile version string: 4.6.0 NVIDIA 396.54
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 396.54
OpenGL shading language version string: 4.60 NVIDIA
and afterwards, the nvidia card is turned off:
$ cat /sys/bus/pci/devices/0000\:01\:00.0/power/runtime_status
suspended
This works even after a suspend/resume cycle.
ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: bumblebee 3.2.1-17 [modified: usr/bin/bumblebee-bugreport usr/bin/optirun usr/sbin/bumblebeed usr/share/doc/bumblebee/README.markdown]
Uname: Linux 4.19.0-041900rc3-generic x86_64
ApportVersion: 2.20.10-0ubuntu9
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Tue Sep 11 13:30:22 2018
InstallationDate: Installed on 2017-08-16 (390 days ago)
InstallationMedia: Ubuntu 17.04 "Zesty Zapus" - Release amd64 (20170412)
SourcePackage: bumblebee
UpgradeStatus: Upgraded to cosmic on 2018-08-15 (26 days ago)
mtime.conffile..etc.bumblebee.bumblebee.conf: 2018-09-10T12:33:56.368908
mtime.conffile..etc.bumblebee.xorg.conf.nvidia: 2018-09-10T12:33:56.368908
** Affects: bumblebee (Ubuntu)
Importance: Undecided
Status: New
** Tags: amd64 apport-bug cosmic
** Patch added: "bumblebee-git-develop.diff"
https://bugs.launchpad.net/bugs/1791883/+attachment/5187396/+files/bumblebee-git-develop.diff
** Description changed:
It would be great to implement something like feature request
- bumblebee#140 (https://github.com/Bumblebee-
+ bumblebee#978 (https://github.com/Bumblebee-
Project/Bumblebee/issues/978), because bbswitch doesn't work with later
kernels unless you disable pci power management at boot with
pcie_port_pm=off added to GRUB_CMDLINE_LINUX_DEFAULT in
/etc/default/grub (see https://github.com/Bumblebee-
Project/bbswitch/issues/140 for more details) and in fact later kernels
automatically activate and suspend the card as required, replacing the
functionality of bbswitch.
To confirm this, I tried modifying the Ubuntu bumblebee source package,
but it fails to build in Cosmic on my laptop with a number of reference
errors like so (even though I do have libkmod2 installed):
/usr/bin/ld: src/module.o: in function `module_is_loaded':
/home/rocko/src/bumblebee-3.2.1/src/module.c:46: undefined reference to `kmod_module_new_from_name'
So I modified the bumblebee develop branch from git (https://github.com
/Bumblebee-Project/Bumblebee/tree/develop) with the attached patch and
built it to confirm that bumblebee works when allowing the kernel to
manage power management. The most relevant part of the patch is this:
@@ -227,8 +228,12 @@ static void switch_and_unload(void)
- char driver[BUFFER_SIZE];
-
- if (bb_config.pm_method == PM_DISABLED && bb_status.runmode != BB_RUN_EXIT) {
+ char driver[BUFFER_SIZE];
+
+ if (bb_config.pm_method == PM_DISABLED && bb_status.runmode != BB_RUN_EXIT) {
- /* do not disable the card if PM is disabled unless exiting */
- return;
+ /* RR: unload the driver loaded by the graphics card */
+ bb_log(LOG_INFO, "PM disabled, unloading nvidia drivers anyway\n");
+ if (pci_get_driver(driver, pci_bus_id_discrete, sizeof driver)) {
+ module_unload(driver);
+ }
+ return;
- }
-
- //if card is on and can be switched, switch it off
+ }
+
+ //if card is on and can be switched, switch it off
but I have also included changing configuration defaults like
PM_METHOD=none and setting up the Ubuntu library paths for nvidia and
primus in Ubuntu 18.04/18.10 (see
https://bugs.launchpad.net/ubuntu/+source/bumblebee/+bug/1758243 for
why).
Then I configured and built it with:
autoreconf -f
./configure CONF_DRIVER=nvidia CONF_DRIVER_MODULE_NVIDIA=nvidia CONF_PM_METHOD=none \
- CONF_LDPATH_NVIDIA=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu \
- CONF_MODPATH_NVIDIA=/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules,/usr/lib/xorg/modules/input \
- --prefix=/usr --sysconfdir=/etc
+ CONF_LDPATH_NVIDIA=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu \
+ CONF_MODPATH_NVIDIA=/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules,/usr/lib/xorg/modules/input \
+ --prefix=/usr --sysconfdir=/etc
make clean
make && sudo make install
I disabled bbswitch via /etc/modprobe.d/bbswitch:
blacklist bbswitch
and then on reboot, optirun seems to be working fine:
$ optirun glxinfo|grep NVIDIA
server glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation
OpenGL core profile version string: 4.6.0 NVIDIA 396.54
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 396.54
OpenGL shading language version string: 4.60 NVIDIA
and afterwards, the nvidia card is turned off:
$ cat /sys/bus/pci/devices/0000\:01\:00.0/power/runtime_status
suspended
This works even after a suspend/resume cycle.
ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: bumblebee 3.2.1-17 [modified: usr/bin/bumblebee-bugreport usr/bin/optirun usr/sbin/bumblebeed usr/share/doc/bumblebee/README.markdown]
Uname: Linux 4.19.0-041900rc3-generic x86_64
ApportVersion: 2.20.10-0ubuntu9
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Tue Sep 11 13:30:22 2018
InstallationDate: Installed on 2017-08-16 (390 days ago)
InstallationMedia: Ubuntu 17.04 "Zesty Zapus" - Release amd64 (20170412)
SourcePackage: bumblebee
UpgradeStatus: Upgraded to cosmic on 2018-08-15 (26 days ago)
mtime.conffile..etc.bumblebee.bumblebee.conf: 2018-09-10T12:33:56.368908
mtime.conffile..etc.bumblebee.xorg.conf.nvidia: 2018-09-10T12:33:56.368908
--
You received this bug notification because you are a member of Bumblebee
Project, which is subscribed to bumblebee in Ubuntu.
Matching subscriptions: Bumblebee Team
https://bugs.launchpad.net/bugs/1791883
Title:
Feature request: modify bumblebee to unload nvidia modules if power
management is done by the kernel
Status in bumblebee package in Ubuntu:
New
Bug description:
It would be great to implement something like feature request
bumblebee#978 (https://github.com/Bumblebee-
Project/Bumblebee/issues/978), because bbswitch doesn't work with
later kernels unless you disable pci power management at boot with
pcie_port_pm=off added to GRUB_CMDLINE_LINUX_DEFAULT in
/etc/default/grub (see https://github.com/Bumblebee-
Project/bbswitch/issues/140 for more details) and in fact later
kernels automatically activate and suspend the card as required,
replacing the functionality of bbswitch.
To confirm this, I tried modifying the Ubuntu bumblebee source
package, but it fails to build in Cosmic on my laptop with a number of
reference errors like so (even though I do have libkmod2 installed):
/usr/bin/ld: src/module.o: in function `module_is_loaded':
/home/rocko/src/bumblebee-3.2.1/src/module.c:46: undefined reference to `kmod_module_new_from_name'
So I modified the bumblebee develop branch from git
(https://github.com/Bumblebee-Project/Bumblebee/tree/develop) with the
attached patch and built it to confirm that bumblebee works when
allowing the kernel to manage power management. The most relevant part
of the patch is this:
@@ -227,8 +228,12 @@ static void switch_and_unload(void)
char driver[BUFFER_SIZE];
if (bb_config.pm_method == PM_DISABLED && bb_status.runmode != BB_RUN_EXIT) {
- /* do not disable the card if PM is disabled unless exiting */
- return;
+ /* RR: unload the driver loaded by the graphics card */
+ bb_log(LOG_INFO, "PM disabled, unloading nvidia drivers anyway\n");
+ if (pci_get_driver(driver, pci_bus_id_discrete, sizeof driver)) {
+ module_unload(driver);
+ }
+ return;
}
//if card is on and can be switched, switch it off
but I have also included changing configuration defaults like
PM_METHOD=none and setting up the Ubuntu library paths for nvidia and
primus in Ubuntu 18.04/18.10 (see
https://bugs.launchpad.net/ubuntu/+source/bumblebee/+bug/1758243 for
why).
Then I configured and built it with:
autoreconf -f
./configure CONF_DRIVER=nvidia CONF_DRIVER_MODULE_NVIDIA=nvidia CONF_PM_METHOD=none \
CONF_LDPATH_NVIDIA=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu \
CONF_MODPATH_NVIDIA=/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules,/usr/lib/xorg/modules/input \
--prefix=/usr --sysconfdir=/etc
make clean
make && sudo make install
I disabled bbswitch via /etc/modprobe.d/bbswitch:
blacklist bbswitch
and then on reboot, optirun seems to be working fine:
$ optirun glxinfo|grep NVIDIA
server glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation
OpenGL core profile version string: 4.6.0 NVIDIA 396.54
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 396.54
OpenGL shading language version string: 4.60 NVIDIA
and afterwards, the nvidia card is turned off:
$ cat /sys/bus/pci/devices/0000\:01\:00.0/power/runtime_status
suspended
This works even after a suspend/resume cycle.
ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: bumblebee 3.2.1-17 [modified: usr/bin/bumblebee-bugreport usr/bin/optirun usr/sbin/bumblebeed usr/share/doc/bumblebee/README.markdown]
Uname: Linux 4.19.0-041900rc3-generic x86_64
ApportVersion: 2.20.10-0ubuntu9
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Tue Sep 11 13:30:22 2018
InstallationDate: Installed on 2017-08-16 (390 days ago)
InstallationMedia: Ubuntu 17.04 "Zesty Zapus" - Release amd64 (20170412)
SourcePackage: bumblebee
UpgradeStatus: Upgraded to cosmic on 2018-08-15 (26 days ago)
mtime.conffile..etc.bumblebee.bumblebee.conf: 2018-09-10T12:33:56.368908
mtime.conffile..etc.bumblebee.xorg.conf.nvidia: 2018-09-10T12:33:56.368908
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bumblebee/+bug/1791883/+subscriptions
Follow ups