Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T440s with kernel >= 3.15 doesn't power off properly (Analysis and possible solution included !) #112

Open
smunaut opened this issue Jul 20, 2015 · 96 comments

Comments

@smunaut
Copy link

smunaut commented Jul 20, 2015

Hi,

So I'm using a T440s with a modern kernel that reports "Windows 2013" compatibility (and soon Windows 2015 with kernel 4.2). This breaks bbswitch because of some changes this triggers in the ACPI table. Manually overriding acpi_osi does fix the issue and allow the current bbswitch to work, but what I'm looking it here is how to make it work with the "new" Win 8.1 method of shutting down the card.

So the main symptoms of the issue are :

  • Using vanilla bbswith : Switching OFF does put it to D3, but it's not entirely off. The power usage is lower but not as low as it should be (in my case, about 1W lower than full power while it should be more like 2.5W). Also, bbswith reports the card as "ON" because lspci still works fine and you can still access the config space. There is no way to turn the card back ON and so loading nvidia driver will actually crash trying to access a card that's only half powered.
  • Using the bbswitch patched like in PR Fix ON/OFF handling on recent ThinkPad t440p BIOS #102 . This is the same effect, power down is not complete and you only save 1W instead of 2.5W. But at least you can turn the card ON and OFF properly. But once nvidia has been loaded, then it won't switch off at all ....

This is the DSDT table from the T440s with the latest bios (which even has Windows 10 support) :
http://pastebin.com/raw.php?i=C6Q3A8aa

The important thing to note is that when "Windown 2013" string is found, then OSYS is set to 0x07DD. This in turn cause VMSH to be set to 1. This in turn causes SB.PCI0.PEG_.VID_._PS3 to NOT call GPOF ... and so the card is never really turned off completely.

Now if you look at how GPOF can be called, you can see it will be called as part of NVP3 power resource which is PR3 ... but on the node SB.PCI0.PEG and not SB.PCI0.PEG_.VID_ !

So basically you need to put the PCIe root port (parent pci device) in D3 and not just the card.

I tested this and it indeed triggered the proper expected power saving and seemed to behave exactly like if I tweaked acpi_osi.

@doudou
Copy link

doudou commented Jul 23, 2015

Do you have code to put the PCIe root in D3 as well ? Would gladly integrate it in #102.

@smunaut
Copy link
Author

smunaut commented Jul 24, 2015

This is what I've been using this last week on my T440s :

https://github.com/smunaut/bbswitch/commit/ca87980cb6105c34e1a138b553eac602d8151519

Note that this is non-conditional ... maybe there should be a whitelist of supported machines ?
I know on the T440s, the subsystem product id changes depending on which mode (i.e. old mode or new mode) is currently active. (So if you boot with an old kernel you see one subsystem id and if you boot with a new one, you see another).

@doudou
Copy link

doudou commented Aug 5, 2015

@smunaut: this change causes memory corruption after I wake up the NVidia card (i.e. back to base one). I am really not a kernel developer, but the obvious problem is that the patch puts the port in D3 but the actual PCIe driver is not informed of that.

I've checked the kernel source code, PCIe ports do not seem to have runtime suspend/resume. That would probably be the better fix (use a dummy nvidia driver to suspend/resume the NV card using the kernel PM handlers and have the PCIe root port go into suspend accordingly). I already wrote the dummy driver, but I'm now trying to find someone I could contact that would be willing to look into this. If you know anybody doing kernel dev ...

The alternative (that I'm going to try as soon as I have the time) would be to unbind the PCIe root port driver from the port and bind yet-another-dummy-driver to put the port to sleep.

@smunaut
Copy link
Author

smunaut commented Aug 5, 2015

@doudou Mmm ... when I think about it, it must be #78 ... I mean for all intents and purposes, my patch will trigger the same behavior in ACPI as when using the acpi_osi string to revert to the old shutdown behavior.

AFAIK there is no drivers binded to the pcie ports themselves, which is why they don't do auto runtime/suspend. I did raise the issue on linux-pm and linux-acpi but didn't really get any answers.

@doudou
Copy link

doudou commented Aug 5, 2015

AFAIK there is no drivers binded to the pcie ports themselves

It seems that there is. lspci reports "pcieport", which matches the driver in drivers/pci/pcie/portdrv_pci.c.

As to whether we can unbind it, that's another story altogether ;-)

@doudou
Copy link

doudou commented Aug 5, 2015

As to whether we can unbind it, that's another story altogether ;-)

Yes, it seems to work. In /sys/bus/pci/drivers/pcieport

After

echo 0000:00:01.1 > unbind 

the driver is not listed as driver of the port, and after

echo 0000:00:01.1 > bind 

it gets listed again

@smunaut
Copy link
Author

smunaut commented Aug 6, 2015

I'd also point out that doing the ACPI DSM call is useless with this new method. It's not required and so maybe removing it would help your issues ?
Did you try shutdown when pcieport is unbinded ? Did it help ?

@doudou
Copy link

doudou commented Aug 6, 2015

Yes, I already removed the DSM calls.

I'm going to push the module I wrote, which basically registers a PCI driver for the NV card and for the PCIe root port, and manages to make them autosuspend. They both go to D3 on autosuspend, and then boom, the system crashes hard. I did not investigate further, I should really be doing something else than this ;-)

I start to believe that the corruption issues directly stem from the hard shutdown of the NV card.

@doudou
Copy link

doudou commented Aug 13, 2015

Some progress.

I've managed to get to a state where both the NVidia and PCIe port get into suspend, using only normal runtime suspend kernel paths. Basically, they get into D3 thanks to the common PCI power-management code. The code is on this branch.

The catch: I get the memory corruption anyways as soon as the card(s) are woken up :( I want to do some reading in intel documentation, whether there are things that need to be done before one is allowed to put a PCIe port in D3.

Note that because I use runtime suspend, you cannot use lspci to check the card's state. This wakes it up. I've used systemtap and powertop to verify that (1) the kernel was attempting to put the cards in D3 and succeeded, and (2) that it led to significant power savings (it did, almost 2W more than with having the NV card in D3).

@gsgatlin
Copy link

gsgatlin commented Sep 9, 2015

@doudou Does this code mess up non thinkpad laptops? Like do you plan on doing a pull request?

@doudou
Copy link

doudou commented Sep 10, 2015

Does this code mess up non thinkpad laptops?

Don't know ... only have a thinkpad

Like do you plan on doing a pull request?

No, given its effects on my laptop ... I already have a pull request (#102) on a method that kind-of works. Meaning:

  • has some power benefits (put the NV card in D3, but not the root port) without filesystem corruption
  • is compatible with the bumblebee daemon
  • but is unable to put the card back to sleep after the nvidia module got loaded

I personally use this one on a 4.0.7 kernel. Left the rest on the side, I don't have time for this right now.

@gsgatlin
Copy link

@doudou Ok. Cool. Thanks for the info. If you ever have time to get it in a state where you'd like it to be tested on a non thinkpad I have a spare optimus ideapad I could test it on.

@sharms
Copy link

sharms commented Sep 24, 2015

I successfully tested the patch on Fedora 23 / 4.2.1-300 on a Thinkpad W541 / Optimus K2100 and power consumption went from 25W to 19W. Thanks!

@andrewgdunn
Copy link

Is there a plan to merge this fix into mainline? I'm about to jump to F23.

@Lacrymology
Copy link

I'm seeing some possibly related issue with a brand new T450s

@andrewgdunn
Copy link

It'd be very nice if we could get this mainlined rather than have it as a required patch.

@smunaut
Copy link
Author

smunaut commented Oct 4, 2015

@storrgie The issue is that this fix is completely ThinkPad specific ... It would probably break things on other brands.

(and even on thinkpads it's only been tested on a few models)

@Lacrymology
Copy link

this is still failing for me, I'm getting this when trying to load bbswitch

[  454.627938] bbswitch: Found integrated VGA device 0000:00:02.0: \_SB_.PCI0.VID_
[  454.627945] bbswitch: Found discrete VGA device 0000:04:00.0: \_SB_.PCI0.PEG_.VID_
[  454.627957] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[  454.629069] bbswitch: detected an Optimus _DSM function
[  454.629872] bbswitch: Succesfully loaded. Discrete card 0000:04:00.0 is on

@Lacrymology
Copy link

trying to turn off with tee:

# tee /proc/acpi/bbswitch<<<OFF
# dmesg
...
[  531.504356] bbswitch: device 0000:04:00.0 is in use by driver 'bbswitch_nv', refusing OFF
# rmmod bbswitch_nv
# dmesg
[  546.959043] bbswitch_nv: attempting to resume
[  546.959058] bbswitch_nv: attempting to suspend
[  547.076317] bbswitch_nv: attempting to resume
# tee /proc/acpi/bbswitch<<<OFF
# dmesg
[  553.644208] bbswitch: disabling discrete graphics
[  553.644225] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[  553.659670] pci 0000:04:00.0: Refused to change power state, currently in D0

@Lacrymology
Copy link

bumblebee works correctly, in the sense of loading the nvidia driver when run with optirun, it's just that the card won't switch off

@Lacrymology
Copy link

here's my lspci -v output for the nvidia card (while running glxgears with optirun)

04:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 940M] (rev a2)
        Subsystem: Lenovo Device 5037
        Flags: bus master, fast devsel, latency 0, IRQ 49
        Memory at f1000000 (32-bit, non-prefetchable) [size=16M]
        Memory at c0000000 (64-bit, prefetchable) [size=256M]
        Memory at d0000000 (64-bit, prefetchable) [size=32M]
        I/O ports at 3000 [size=128]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Express Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Capabilities: [250] Latency Tolerance Reporting
        Capabilities: [258] L1 PM Substates
        Capabilities: [128] Power Budgeting <?>
        Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
        Kernel driver in use: nvidia
        Kernel modules: nouveau, nvidia

@Lacrymology
Copy link

dmesg when running optirun:

[ 1022.584913] NVLINK: Nvlink Core is being initialized, major device number 244
[ 1022.585100] [drm] Initialized nvidia-drm 0.0.0 20150116 for 0000:04:00.0 on minor 1
[ 1022.585108] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  355.11  Wed Aug 26 16:35:41 PDT 2015
[ 1022.829610] vgaarb: this pci device is not a vga device
[ 1022.833781] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1022.834091] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1022.834244] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1022.834389] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1022.834948] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1022.835382] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1022.835532] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1022.873564] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1023.067067] vgaarb: this pci device is not a vga device

and when stopping it:

[ 1065.933239] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1065.949611] NVLINK: Unregistered the Nvlink Core, major device number 244
[ 1065.951791] [drm] Module unloaded
[ 1065.968420] bbswitch: disabling discrete graphics
[ 1065.968435] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1065.980288] pci 0000:04:00.0: Refused to change power state, currently in D0

@smunaut
Copy link
Author

smunaut commented Oct 4, 2015

There is nothing that indicates in your logs that it's not working.

The "Refused to change power state" is inconsequential.

The only way to check if it's working or not is to check if the rev is "ff" during a lspci when it's turned off.

@Lacrymology
Copy link

@smunaut the rev is not ff, it doesn't change. The first time I tried to turn it off with the vanilla module I got a traceback, as well, I'd forgotten about that:

[  163.280190]  snd_pcm i2c_algo_bit i2c_i801 ptp shpchp snd_timer snd soundcore pps_core lpc_ich processor sch_fq_codel ip_tables x_tables ext4 crc16 mbcache jbd2 sd_mod rtsx_pci_sdmmc mmc_core atkbd libps2 ahci libahci libata scsi_mod xhci_pci ehci_pci ehci_hcd xhci_hcd rtsx_pci usbcore usb_common i8042 serio
[  163.280205] CPU: 0 PID: 2385 Comm: tee Tainted: G        W  O    4.2.1-1-ARCH #1
[  163.280206] Hardware name: LENOVO 20BXCTO1WW/20BXCTO1WW, BIOS JBET51WW (1.16 ) 07/08/2015
[  163.280207]  0000000000000000 00000000619135a4 ffff88030e58fcc8 ffffffff8156b77a
[  163.280209]  0000000000000000 ffff88030e58fd20 ffff88030e58fd08 ffffffff81074846
[  163.280210]  ffff88030e58fce8 ffff88033f6e1000 ffff88033f661c40 00007ffdb03cc1a0
[  163.280212] Call Trace:
[  163.280216]  [<ffffffff8156b77a>] dump_stack+0x4c/0x6e
[  163.280218]  [<ffffffff81074846>] warn_slowpath_common+0x86/0xc0
[  163.280220]  [<ffffffff810748d5>] warn_slowpath_fmt+0x55/0x70
[  163.280223]  [<ffffffff812f503b>] ? __pci_set_master+0x3b/0xf0
[  163.280224]  [<ffffffff812f7b50>] pci_disable_device+0xb0/0xd0
[  163.280227]  [<ffffffffa07714ad>] bbswitch_off+0xad/0x240 [bbswitch]
[  163.280228]  [<ffffffffa077187b>] bbswitch_proc_write+0x9b/0xb2 [bbswitch]
[  163.280231]  [<ffffffff81236742>] proc_reg_write+0x42/0x70
[  163.280233]  [<ffffffff811d01c7>] __vfs_write+0x37/0x100
[  163.280235]  [<ffffffff811d2fd8>] ? __sb_start_write+0x58/0x100
[  163.280237]  [<ffffffff811d0ad4>] vfs_write+0xa4/0x1a0
[  163.280238]  [<ffffffff811d0a14>] ? vfs_read+0x114/0x130
[  163.280240]  [<ffffffff811d17e5>] SyS_write+0x55/0xc0
[  163.280242]  [<ffffffff81570cee>] entry_SYSCALL_64_fastpath+0x12/0x71
[  163.280243] ---[ end trace be475d6cb25e4d1e ]---

Also, according to KDE's battery status panel, I do get an hour less of battery while optirun is running something, but when it's supposed to be turned off, I'm still getting this with lspci

04:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 940M] (rev a2)

Notice that as reported above by other people, I'm also getting

root@hex /home/lacrymology/aur/bbswitch # cat /proc/acpi/bbswitch 
0000:04:00.0 ON

regardless

@smunaut
Copy link
Author

smunaut commented Oct 4, 2015

Are you sure you took the source from my repo and switched to the right branch ? (the default at checkout is 'master' and doesn't have the patch)

@Lacrymology
Copy link

yes, branch runtime_suspend, right? I even copied the module over to /lib/modules/... manually and tried to load it with modprobe, it lodaed correctly (after running depmod -a), but still the same results:

# dmesg
[ 1256.134906] bbswitch: version 0.8
[ 1256.134918] bbswitch: Found integrated VGA device 0000:00:02.0: \_SB_.PCI0.VID_
[ 1256.134926] bbswitch: Found discrete VGA device 0000:04:00.0: \_SB_.PCI0.PEG_.VID_
[ 1256.134938] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
[ 1256.135548] bbswitch: detected an Optimus _DSM function
[ 1256.135564] bbswitch: Succesfully loaded. Discrete card 0000:04:00.0 is on
[ 1282.007356] bbswitch: disabling discrete graphics
[ 1282.007365] ACPI Warning: \_SB_.PCI0.PEG_.VID_._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20150619/nsarguments-95)
# lspci
04:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 940M] (rev a2)
        Subsystem: Lenovo Device 5037
        Flags: fast devsel, IRQ 16
        Memory at f1000000 (32-bit, non-prefetchable) [size=16M]
        Memory at c0000000 (64-bit, prefetchable) [size=256M]
        Memory at d0000000 (64-bit, prefetchable) [size=32M]
        I/O ports at 3000 [size=128]
        Expansion ROM at <ignored> [disabled]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Express Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Capabilities: [250] Latency Tolerance Reporting
        Capabilities: [258] L1 PM Substates
        Capabilities: [128] Power Budgeting <?>
        Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
        Capabilities: [900] #19
        Kernel modules: nouveau, nvidia

@wuqso
Copy link

wuqso commented Mar 25, 2016

I have a Lenovo T450s with Fedora 23.

#uname -r
4.4.6-300.fc23.x86_64

I downloaded doudou's bbswitch code from https://github.com/doudou/bbswitch, build it with 'make' and load it with 'make load' with no error. But the Nvidia card is still on.

# cat /proc/acpi/bbswitch
0000:04:00.0 ON
# tee /proc/acpi/bbswitch <<< OFF
OFF
# cat /proc/acpi/bbswitch
0000:04:00.0 ON
# lspci -vnn | grep '\''[030[02]\]'
00:02.0 VGA compatible controller [0300]: Intel Corporation Broadwell-U Integrated Graphics [8086:1616] (rev 09) (prog-if 00 [VGA controller])
04:00.0 3D controller [0302]: NVIDIA Corporation GM108M [GeForce 940M] [10de:1347] (rev a2)

What's the problem? I'm a user rather than a programmer. I just want a long battery life in linux system.

@wuqso
Copy link

wuqso commented Mar 30, 2016

@valneacsu, using acpi_osi=Linux solves my problem. Thank you!

@Lekensteyn
Copy link
Member

For those who are wondering why the methods are different depending on the kernel version (or the setting of acpi_osi), apparently Windows 10 (Windows 2015) drops the use of DSM completely. For that OS you have to toggle the power resources (basically the parent PCIe port).

David Airlie posted a patch to handle the power resources for nouveau/vgaswitcheroo, but I don't know what happened to those patches (https://lkml.org/lkml/2016/3/9/65). You could probably check the power resources of the parent device, but that smells hacky if you call it directly (shouldn't the Linux PM take care of this?). See also the analysis at #115 (comment). While turning off has no DSM methods, surprisingly there are some involved with turning it on. Can you reproduce/match this with your machines?

(Will comment later on the patch, my battery is dieing)

@doudou
Copy link

doudou commented May 12, 2016

David Airlie's patch definitely looks interesting. Even more so because the PM handler is exported, and could therefore be used outside of vgaswitcheroo-enabled drivers.

@doudou
Copy link

doudou commented May 12, 2016

If you look at the LKML thread, it seems that the kernel devs are tackling the root problem ... that is adding runtime PM to the PCIe root ports. What it means for the future of bbswitch, I'm not sure, since it will work only if the card itself is put in D3 first.

While turning off has no DSM methods, surprisingly there are some involved with turning it on. Can you reproduce/match this with your machines?

On mine, the NVidia suspend/resume with pcie-root-port in D3 works without any calls to any DSM.

@Lekensteyn
Copy link
Member

Lekensteyn commented May 12, 2016

I read the full thread (and some of the linked patchwork entries). David's patch adds a function to enabble PM operations that power off/on the parent (PCIe port) device and hooks it into nouveau. Rafael commented that the patches PM for PCIe ports are still under discussion. Especially note:

I'm guessing on Windows this all happens automatically.

PCIe ports are power-managend by (newer) Windows AFAICS, but we know for a fact
that this simply doesn't work reliably on some older hardware which is why
we don't do that. I suppose that the Windows in question uses a cut-off date
or similar to decide what do do with PCIe ports PM.

Edit: latest version of PCIe patches are scheduled for v4.7, see http://article.gmane.org/gmane.linux.power-management.general/75997 and https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/pm

As for bbswitch's future, it is currently broken for newer devices so I'll probably do this:

  • Add detection for newer devices (TBD, maybe I can check for the _PR3 method on parent device (PCIe port)? Calling DSM could also be done, but I am afraid that this is less well tested.)
  • If an old device is detected, keep the current situation (important, I don't want to break old devices).
    • If a new device is detected:
    • Skip DSM before PS3
    • After PS3, disable the parent device (new; but has to be future-proof as well)

In case upstream Linux adds proper PM to the PCIe root port, then bbswitch should not interfere with that, so there also needs to be checks for that (PM domains?). Some reading material: https://www.kernel.org/doc/Documentation/power/devices.txt

bbswitch differentiates itself from nouveau in that it will always keep the device powered off unless explicitly asked by the user (via /proc/acpi/bbswitch). Currently nouveau will flip the card on when you execute lspci for example or open /dev/dri/.... Note that I will probably use nouveau though since external screens are connected via the Nvidia card on my laptop.

On mine, the NVidia suspend/resume with pcie-root-port in D3 works without any calls to any DSM.

Did you observe this on Windows? Is Windows doing any DSM calls after D0?

@doudou
Copy link

doudou commented May 13, 2016

Currently nouveau will flip the card on when you execute lspci for example or open /dev/dri/....

This is due to the usage of runtime PM. lspci triggers a wakeup. I had a version of bbswitch that was purely relying on runtime PM and noticed that.

Once all the PCIe root port work is in the kernel, I'm planning try to use nouveau instead of bbswitch just for the PM work. I still rely on the nvidia proprietary driver for proper opengl support.

Did you observe this on Windows?

I would not even begin to know how I could check that.

@shadoxx
Copy link

shadoxx commented May 28, 2016

Just wanted to confirm this issue on a Thinkpad W550s running BIOS version 1.14. bbswitch worked fine on the BIOS that was shipped with this laptop which was version 1.06. I would downgrade the BIOS, but Lenovo has disabled that functionality as well, citing security concerns.

@Lekensteyn
Copy link
Member

@shadoxx https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1452979 lists acpidump for a W550s (Quadro K620M, BIOS 1.02). The SSDT changes are not relevant. DSDT has changes a bit, mainly wrt USB 3.0, some TPM changes. These are the hunks relevant for graphics (GPON, GPOF and Win10 detection):

diff --git a/acpi-1.02/dsdt.dsl b/acpi-1.14/dsdt.dsl
index 53b2c77..9717867 100644
--- a/acpi-1.02/dsdt.dsl
+++ b/acpi-1.14/dsdt.dsl
@@ -1051,24 +1051,30 @@ DefinitionBlock ("dsdt.aml", "DSDT", 1, "LENOVO", "TP-N11  ", 0x00001020)
                 If (\_OSI ("Windows 2012"))
                 {
                     \WIN8 = 0x01
                     OSYS = 0x07DC
                 }

                 If (\_OSI ("Windows 2013"))
                 {
                     \WIN8 = 0x01
                     OSYS = 0x07DD
                 }

+                If (\_OSI ("Windows 2015"))
+                {
+                    \WIN8 = 0x01
+                    OSYS = 0x07DF
+                }
+
                 If (\_OSI ("Linux"))
                 {
                     \LNUX = 0x01
                     OSYS = 0x03E8
                 }

                 If (\_OSI ("FreeBSD"))
                 {
                     \LNUX = 0x01
                     OSYS = 0x03E8
                 }
             }
@@ -6774,32 +6770,36 @@ DefinitionBlock ("dsdt.aml", "DSDT", 1, "LENOVO", "TP-N11  ", 0x00001020)
                         {
                             GPOF (0x00)
                         }
                     }

                     Method (GPON, 1, NotSerialized)
                     {
                         If (ISOP ())
                         {
                             If (DGOS)
                             {
                                 \VHYB (0x02, 0x00)
-                                Sleep (0x64)
+                                Sleep (0x14)
                                 If ((ToInteger (Arg0) == 0x00)) {}
                                 \VHYB (0x00, 0x01)
-                                Local0 = 0x00
-                                While ((Local0 < 0x5A))
+                                Sleep (0x14)
+                                Local2 = \VHYB (0x0E, 0x00)
+                                While ((Local2 != 0x0F))
                                 {
-                                    Local0 += One
-                                    Stall (0x64)
+                                    \VHYB (0x00, 0x00)
+                                    Sleep (0x14)
+                                    \VHYB (0x00, 0x01)
+                                    Sleep (0x0A)
+                                    Local2 = \VHYB (0x0E, 0x00)
                                 }

                                 \VHYB (0x02, 0x01)
                                 Sleep (0x01)
                                 \VHYB (0x08, 0x01)
                                 Local0 = 0x0A
                                 Local1 = 0x32
                                 LREN = LTRS /* \_SB_.PCI0.PEG_.LTRS */
                                 CEDR = One
                                 While (Local1)
                                 {
                                     Sleep (Local0)
@@ -6851,31 +6851,25 @@ DefinitionBlock ("dsdt.aml", "DSDT", 1, "LENOVO", "TP-N11  ", 0x00001020)

                     Method (GPOF, 1, NotSerialized)
                     {
                         If (ISOP ())
                         {
                             If ((VMSH || (\_SB.PCI0.PEG.VID.OMPR == 0x03)))
                             {
                                 LTRS = LREN /* \_SB_.PCI0.PEG_.LREN */
                                 \SWTT (0x00)
                                 \VHYB (0x08, 0x00)
                                 \VHYB (0x08, 0x02)
                                 \VHYB (0x02, 0x00)
-                                Local0 = 0x00
-                                While ((Local0 < 0x1E))
-                                {
-                                    Local0 += One
-                                    Stall (0x64)
-                                }
-
+                                Sleep (0x09)
                                 \VHYB (0x00, 0x00)
                                 If ((ToInteger (Arg0) == 0x00)) {}
                                 DGOS = One
                                 \_SB.PCI0.PEG.VID.OMPR = 0x02
                             }
                         }
                     }

                     Method (_STA, 0, NotSerialized)  // _STA: Status
                     {
                         Return (0x0F)
                     }

The ACPI changes do not look very significant, it is mainly the timing that are changed. GPOF went from 30×100µs(=3ms) to 9ms. GPON is slightly more interesting. It changes the timings and adds a SMI call (unknown function). Maybe there were other non-ACPI tunings.

Anyway, maybe things get better when the power resources are used instead of DSM.

@Lekensteyn
Copy link
Member

Could someone try some patch series on top of v4.7 with nouveau? See #78 (comment)

@Lekensteyn
Copy link
Member

FYI, this has been fixed for the nouveau in Linux v4.8-rc1, bbswitch still needs an update though.

@BernardoGO
Copy link

@Lekensteyn
Does it fix the suspension problem for Clevos?
BBswitch currently does not support graphic switch using nouveau, right?

@Lekensteyn
Copy link
Member

@BernardoGO What suspend problem? System sleep or runtime suspend?
With nouveau, you do not need bbswitch as it is able to handle PM.

@klebed
Copy link

klebed commented Nov 4, 2016

Just to leave another footprint in this epic issue.

If somebody using ubuntu 16.04 (and probably other distros with >4.4.X), and used nvidia-361, it was force-replaced with nvidia-367 (you install 361, but apt gives you 367 with 361 simultaneously), so you could experience all problems again. First of all, use up to date bumblebee and primus from bumblebee/testing ppa, install nvidia-367. And then, after it started to work, check bbswitch, since it probably stopped working properly.
The solution is to edit /etc/default/grub , adding acpi_osi=Linux to GRUB_CMDLINE_LINUX parameter, and then do: sudo update-grub .

Worked with Lenovo T440s.

@RoadToDream
Copy link

Thanks to @smunaut and @klebed . Worked for me.

@Lacrymology
Copy link

just an update, on a ThinkPad T450s, the card is constantly on and the grub fix above doesn't work (plasma never finishes loading and a bunch of error messages show up in the logs).

@wuqso
Copy link

wuqso commented Apr 26, 2019 via email

github-actions bot pushed a commit to NixOS/nixpkgs that referenced this issue Aug 5, 2022
Switch to the development branch, as it's basically stable at
this point, and pinch Arch's 5.18 compat patch.

Also remove existing patches:
- PR 102 was rejected upstream, the actual issue is
  Bumblebee-Project/bbswitch#112,
  and can be worked around via acpi_osi=Linux
- PR 196 is applied upstream.

(cherry picked from commit e1c59ea)
winterqt pushed a commit to NixOS/nixpkgs that referenced this issue Aug 6, 2022
Switch to the development branch, as it's basically stable at
this point, and pinch Arch's 5.18 compat patch.

Also remove existing patches:
- PR 102 was rejected upstream, the actual issue is
  Bumblebee-Project/bbswitch#112,
  and can be worked around via acpi_osi=Linux
- PR 196 is applied upstream.

(cherry picked from commit e1c59ea)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests