You are not logged in.

#1 2015-12-28 22:49:13

yanom
Member
Registered: 2013-06-30
Posts: 36

Bumblebee programs (optirun/primusrun) don't work after suspend

Hi all, I have a laptop which uses Optimus graphics. There's an Intel integrated graphics with an NVIDIA GeForce GTX 850M graphics card. I installed Bumblebee as described on the wiki and I use the proprietary "nvidia" driver to drive the 850M.

Now I have a problem. When I boot my computer up I can start programs using the 850M graphics card by starting them like:

$ primusrun glxgears

And it works fine. But if I suspend my laptop by closing the lid or issuing "systemctl suspend" command, then wake it back up, primusrun and optirun don't work anymore. I get this error:

$ primusrun glxgears
primus: fatal: Bumblebee daemon reported: error: [XORG] (EE) /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied

same error happens when I run that command as root.

Does anyone know what's happening here? Is there any diagnostic information I can post that will shed some light on this problem?

Offline

#2 2016-01-07 02:56:00

tankmcp
Member
From: Tulsa, OK
Registered: 2007-09-17
Posts: 54

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

I am having the same type of problem. After suspend, no programs will use optirun/primusrun without reboot.

For example:

user@home$optirun feedthebeast
[19778.858566] [ERROR]Cannot access secondary GPU - error: [XORG] (EE) /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied

[19778.858609] [ERROR]Aborting because fallback start is disabled.

Yeilds the same as root.

root@home# optirun feedthebeast
[20221.921555] [ERROR]Cannot access secondary GPU - error: [XORG] (EE) /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied

[20221.921598] [ERROR]Aborting because fallback start is disabled.

I followed the suggestion for this error on the wiki (adding the DiscreteNividia  Screen identifier and also checked my iptables), but no change.

Thanks for your help.

Last edited by tankmcp (2016-01-07 02:56:52)

Offline

#3 2016-01-07 21:03:24

zmjjmz
Member
Registered: 2016-01-07
Posts: 8

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

I'm running into pretty much the same issue (Thinkpad W540, Quadro K2100M, latest nvidia package).

lspci output:

01:00.0 VGA compatible controller: NVIDIA Corporation GK106GLM [Quadro K2100M] (rev a1)

It's worth noting that the revision is a1, as it's originally ff when I come out of suspend but when I try to use optirun it switches to a1... Not sure if it's significant but I thought it might be.


I have some more info from dmesg that shows the GPU falling off the bus:

[ 1853.274494] NVRM: GPU at 0000:01:00.0 has fallen off the bus.
[ 1853.274656] NVRM: A GPU crash dump has been created. If possible, please run
               NVRM: nvidia-bug-report.sh as root to collect this data before
               NVRM: the NVIDIA kernel module is unloaded.
[ 1853.277077] NVRM: RmInitAdapter failed! (0x25:0x40:1353)
[ 1853.277087] NVRM: rm_init_adapter failed for device bearing minor number 0
[ 1853.277140] NVRM: nvidia_frontend_open: minor 0, module->open() failed, error -5
[ 1886.022610] bbswitch: enabling discrete graphics

Here's the nvidida-bug-report.sh output, couldn't find anything useful in there but I don't know much about this stuff.

Also the error I get from Xorg (through bumblebeed's output) when trying to use it is interesting because it thinks it's a driver issue, which is definitely wrong...

[17052.900640] [ERROR][XORG] (EE) Failed to load module "mouse" (module does not exist, 0)
[17052.900656] [ERROR][XORG] (EE) NVIDIA(GPU-0): The NVIDIA GPU at PCI:1:0:0 is not supported by the 358.16
[17052.900662] [ERROR][XORG] (EE) NVIDIA(GPU-0):     NVIDIA driver.
[17052.900668] [ERROR][XORG] (EE) NVIDIA(GPU-0): Failed to initialize the NVIDIA graphics device!
[17052.900673] [ERROR][XORG] (EE) NVIDIA(0): Failing initialization of X screen 0
[17052.900679] [ERROR][XORG] (EE) Screen(s) found, but none have a usable configuration.
[17052.900684] [ERROR][XORG] (EE) 
[17052.900690] [ERROR][XORG] (EE) no screens found(EE) 
[17052.900695] [ERROR][XORG] (EE) 
[17052.900700] [ERROR][XORG] (EE) Please also check the log file at "/var/log/Xorg.8.log" for additional information.
[17052.900706] [ERROR][XORG] (EE) 
[17052.900711] [ERROR][XORG] (EE) Server terminated with error (1). Closing log file.
[17052.903443] [ERROR]X did not start properly

Not sure where to go from here, tried a lot of things (reinstalling drivers, putting in the rcutree boot parameter thing, etc) to no avail.

Offline

#4 2016-01-08 19:39:28

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

Same issue, I have a GTX850m too.

Offline

#5 2016-01-08 20:57:00

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

So I've done some research and I've found that this seems to be a known issue.
I'll post what I've found (github links):

- Cannot access GPU after sleep: this is from March 2012
- Xorg freeze after laptop suspend: from Jan 2015, same issue;continues the discussion where the previous report lefted.
- "error: Could not enable discrete graphics card" after suspend.: from April 2015, again same issue, still not fixed.
- Problems after resuming from suspend - nvidia is not unloaded when optirun stops: from Nov 2015 same thing, but the author of the report actually discovered that if you manually unload the nvidia_modeset first, and then the nvidia module, after you close the lid, it actually works. So after you run primusrun or optirun the first time both the modules (nvidia and nvidia_modeset) are not unloaded and that's what is causing the problem, it seems that resuming from standby is not causing problems.

One of the guys maintaining bumblebee actually posted on the last report, he said: "we have a potential mix of bbswitch suspend issues and unloading troubles." This was 12 days ago.

Just to make sure,can you guys try one thing (I'm away from my laptop): boot your laptop like you normally would, don't run optirun or primusrun (if you already did that, reboot, just to have a fresh boot), now close the lid, open it and try running either primusrun glxgears or optirun glxgears and see if it works or not.

I hope this post makes some sense. I'm not involved with the bumblebee project.

Last edited by spider-net (2016-01-08 21:14:02)

Offline

#6 2016-01-09 19:07:13

NeroBurner
Member
Registered: 2013-09-05
Posts: 30

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

Did what you said.
Reboot - Standby - run `optirun glxgears` - just works
Reboot - Run `optirun glxgears` works - Standby - Run `optirun glxgears` doesn't work anymore

$ uname -r
4.3.3-2-ARCH

$ pacman -Qs nvidia
local/bumblebee 3.2.1-10
    NVIDIA Optimus support for Linux through VirtualGL
local/lib32-nvidia-utils 358.16-1
    NVIDIA drivers utilities (32-bit)
local/libvdpau 1.1.1-2
    Nvidia VDPAU library
local/nvidia 358.16-3
    NVIDIA drivers for linux
local/nvidia-utils 358.16-1
    NVIDIA drivers utilities
local/opencl-nvidia 358.16-1
    OpenCL implemention for NVIDIA

Offline

#7 2016-01-09 22:26:39

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

Yep, it's an issue with bumblebee: after you run optirun / primusrun, it won't unload the nvidia modules, they are aware of the issue and a fix is in the works. But we probably have to wait for bumblebee 4.0.
That being said some distribution like gentoo and Manjaro already have a patch for it (see here).

If someone wants to learn more I'll link bumblebee github page: https://github.com/Bumblebee-Project/Bumblebee/issues

Last edited by spider-net (2016-01-09 22:27:43)

Offline

#8 2016-01-10 02:26:45

zmjjmz
Member
Registered: 2016-01-07
Posts: 8

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

Well I tried to recreate this on my machine (reboot - suspend - run optirun glxspheres64), and I got an error about not being able to load the GPU driver -- also the output in dmesg is pretty different , including a stack trace to something bbswitch related...

Does the latest nvidia driver actually not support the K2100M? I'm not sure if that's part of the problem or just an irrelevant error message thrown up because it can't communicate with the GPU...

Offline

#9 2016-01-10 10:13:21

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

zmjjmz wrote:

Well I tried to recreate this on my machine (reboot - suspend - run optirun glxspheres64), and I got an error about not being able to load the GPU driver -- also the output in dmesg is pretty different , including a stack trace to something bbswitch related...

Does the latest nvidia driver actually not support the K2100M? I'm not sure if that's part of the problem or just an irrelevant error message thrown up because it can't communicate with the GPU...

I think I got something like that too. I only got it one time tho.
Usually when I do: reboot - run optirun - susped - run optirun Xorg just freezes and I have to power it down using the power button.
But when I do reboot - susped - run optirun it works,if I close the lid one more time and I run optirun again, then X dies.

Offline

#10 2016-01-10 17:54:13

zmjjmz
Member
Registered: 2016-01-07
Posts: 8

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

I actually had this driver crash happen when I tried to use optirun on some Steam games (namely Shadow of Mordor), so it might not be related to the problem at hand...

Offline

#11 2016-01-10 19:09:19

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

zmjjmz wrote:

I actually had this driver crash happen when I tried to use optirun on some Steam games (namely Shadow of Mordor), so it might not be related to the problem at hand...

Last time I tried Shadow of Mordor worked fine for me. I used primusrun.

EDIT: I just tested it again, it works, I use this launch option primusrun %command%

Last edited by spider-net (2016-01-10 19:19:15)

Offline

#12 2016-01-10 19:42:48

zmjjmz
Member
Registered: 2016-01-07
Posts: 8

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

Yep, primusrun works for me as well, not sure why optirun doesn't -- must be something w/the bridge not being correct, as optirun -b primus works just fine... Either way it's bit off-topic smile

Offline

#13 2016-01-11 19:36:03

yanom
Member
Registered: 2013-06-30
Posts: 36

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

NeroBurner wrote:

Did what you said.
Reboot - Standby - run `optirun glxgears` - just works
Reboot - Run `optirun glxgears` works - Standby - Run `optirun glxgears` doesn't work anymore

Can confirm that this is the pattern on my computer too.

Yep, it's an issue with bumblebee: after you run optirun / primusrun, it won't unload the nvidia modules, they are aware of the issue and a fix is in the works. But we probably have to wait for bumblebee 4.0.
That being said some distribution like gentoo and Manjaro already have a patch for it (see here).

Is there a way to manually unload the nvidia modules? I don't know much about kernel modules but it seems like there should be a command to do that.

Offline

#14 2016-01-11 19:40:14

zmjjmz
Member
Registered: 2016-01-07
Posts: 8

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

I've tried this in the second scenario (as root, modprobe -r nvidia_modeset and then modprobe -r nvidia), and then I get this in dmesg if I try to do primusrung glxspheres64

[143846.400916] nvidia-modeset: Unloading
[143846.412430] nvidia-nvlink: Unregistered the Nvlink Core, major device number 243
[143846.412543] [drm] Module unloaded
[143853.351015] bbswitch: enabling discrete graphics
[143853.364691] pci 0000:01:00.0: Refused to change power state, currently in D3

Offline

#15 2016-01-12 07:20:46

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

modprobe -r nvidia_modeset should unload all the nvidia modules. But when I tried using optirun or primusrun it didn't work. Just like @zmjjmz. So maybe try doing a modprobe nvidia before running optirun/primusrun.

If you're interested there's a whole discussion about it here: https://github.com/Bumblebee-Project/Bu … issues/699 some people suggested some fixes, others patched the code.
For me unloading the modules and then launching primusrun didn't work.

Edit: someone did report it here too: https://bugs.archlinux.org/task/47140

Last edited by spider-net (2016-01-12 09:03:00)

Offline

#16 2016-01-12 20:12:26

yanom
Member
Registered: 2013-06-30
Posts: 36

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

as root, modprobe -r nvidia_modeset and then modprobe -r nvidia

I found if I do this before suspending the machine, Bumblebee will still work after I resume it. Is there anyway to script this behavior so that Arch will unload these modules before going to sleep every time?

Offline

#17 2016-01-12 20:34:35

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

yanom wrote:

as root, modprobe -r nvidia_modeset and then modprobe -r nvidia

I found if I do this before suspending the machine, Bumblebee will still work after I resume it. Is there anyway to script this behavior so that Arch will unload these modules before going to sleep every time?

I can confirm. As I said only modprobe -r nvidia_modeset is necessary, it will unload the nvidia module too.

EDIT: as for the script you can do something along these lines

#!/bin/bash

case "$1" in
    suspend)
        sudo modprobe -r nvidia_modeset;
        ;;
    resume) 
        # executed on resume
        ;;
    *)
        ;;
esac

Save it in in /usr/lib/pm-utils/sleep.d or /etc/pm/sleep.d/ After that give it executable permissions.
If someone wants to test it,feel free.

Last edited by spider-net (2016-01-12 21:05:12)

Offline

#18 2016-01-13 02:37:25

zmjjmz
Member
Registered: 2016-01-07
Posts: 8

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

Using systemd I had to put this in as a service target for root-suspend, as follows (in /etc/systemd/system/root-suspend.service) (basically following this wiki page.)

[Unit]
Description=Local system suspend actions
Before=sleep.target

[Service]
Type=simple
ExecStart=-/usr/bin/modprobe -r nvidia_modeset

[Install]
WantedBy=sleep.target

It seems to work! Though I'm not sure if just having a suspend target and no resume target will have any weird side effects...

Offline

#19 2016-01-13 07:19:41

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

zmjjmz wrote:

Using systemd I had to put this in as a service target for root-suspend, as follows (in /etc/systemd/system/root-suspend.service) (basically following this wiki page.)

It seems to work! Though I'm not sure if just having a suspend target and no resume target will have any weird side effects...

Nice one! I don't think we need a resume target. I shall test it later smile

Offline

#20 2016-01-13 19:12:42

spider-net
Member
Registered: 2015-12-09
Posts: 31

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

zmjjmz wrote:

It seems to work!

I've tested it and works for me too, smile

Offline

#21 2016-01-14 19:45:14

yanom
Member
Registered: 2013-06-30
Posts: 36

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

spider-net wrote:
zmjjmz wrote:

It seems to work!

I've tested it and works for me too, smile

Seconded. Thanks BBS!

Offline

#22 2016-01-15 05:19:37

tankmcp
Member
From: Tulsa, OK
Registered: 2007-09-17
Posts: 54

Re: Bumblebee programs (optirun/primusrun) don't work after suspend

This fix works for me. Thank you so much, zmjjmz!

zmjjmz wrote:

Using systemd I had to put this in as a service target for root-suspend, as follows (in /etc/systemd/system/root-suspend.service) (basically following this wiki page.)

[Unit]
Description=Local system suspend actions
Before=sleep.target

[Service]
Type=simple
ExecStart=-/usr/bin/modprobe -r nvidia_modeset

[Install]
WantedBy=sleep.target

It seems to work! Though I'm not sure if just having a suspend target and no resume target will have any weird side effects...

Offline

Board footer

Powered by FluxBB