This is work in progress, I intend to merge the bbswitch_dev code into
the main module. Some comments in README and bbswitch.c might be stale.
Create a PCI driver such that runtime PM works. Without a bound driver,
the kernel assumes that the device is D0 state during suspend (which
therefore needs the notifier hack in bbswitch) but more importantly, it
will prevent the PCIe port from going to sleep in Linux v4.7.
Currently I use this to debug an infinite loop on my Clevo P651RA
laptop, it can be loaded as follows:
make modname=bbswitch_dev
insmod bbswitch_dev.ko
echo > /sys/bus/pci/drivers/bbswitch/new_id 10de 13d9
Needs Mika's pci/pm series ("PCI: Put PCIe ports into D3 during
suspend"), qeued for v4.7 via
https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=pci/pm
The Optimus _DSM function would prepare a device to be put in D3cold
state when _PS3 is called. Newer laptops should not use this since
Windows 8 introduced a new method to put devices in D3cold state[1].
Hopefully this fixes an infinite loop on a Clevo P651RA. Actually
putting the parent device (PCIe port) is not done in this patch.
[1]: https://msdn.microsoft.com/windows/hardware/drivers/bringup/firmware-requirements-for-d3cold
The Linux kernel is licensed under GPLv2. As GPLv3 and GPLv2 are incompatible in
some way, just license bbswitch as GPL 2.0 or (at your choice) any latter
version. Note: I wrote all code of bbswith.c, so I am entitled to change the
license and do not need permission from other authors (as there are not any).
Request made by Ludwig Nussel.
Just in case the integrated video ACPI handle cannot be found. This is a safety
net for those who try bbswitch on an incompatible machine. I do not know any of
such machinees, but it looks good.
Since the following commit, the device would not turn off because the power
state is unknown. Until a fix is released in Linux (or until I know what
better to do), I just assume the power state D0.
commit ddc150f7a33ae0c9cb16eaac3641abc00f56316f
Author: Lv Zheng <lv.zheng@intel.com>
Date: Fri Nov 16 02:46:28 2012 +0100
ACPI / PM: Add check preventing transitioning to non-D0 state from D3.
No power transitioning from D3 state up to a non-D0 state is allowed
so make acpi_device_set_power() fail and complain if such a transition
is attempted.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
clean: do not try to wipe /usr/src/linux-...
load: rmmod and insmod do not have to be in /sbin (for example, /usr/bin
on Arch Linux). Assume that the user has a sane PATH.
This should finally support machines like the Lenovo Y570. WMMX methods should
be more reliable than direct DSM probing so let's try that before calling DSM
directly.