Commit Graph

107 Commits

Author SHA1 Message Date
fe3f58c15f bbswitch_dev: disable runtime PM on removal
Call pm_runtime_forbid() to balance it with pm_runtime_allow(), this
ensures that the runtime usage counter before loading and after
unloading match.
2016-05-27 02:56:24 +02:00
fb3d5a614a bbswitch_dev: use autosuspend to avoid sleeping too fast 2016-05-23 19:50:37 +02:00
fd774b1f5e bbswitch_dev: remove artificial delays
These delays were added as attempt to rule out the possibility that the
hardware was accessed too fast, but it does not seem to help. Remove it.
2016-05-23 19:49:21 +02:00
daa6411911 [DO NOT MERGE] [WIP] Add PCI driver
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
2016-05-19 15:54:23 +02:00
915413ab92 Disable DSM if power resources are in use
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
2016-05-13 21:35:54 +02:00
0c38f97c3a Update to version 0.8, update NEWS v0.8 2013-12-05 00:22:06 +01:00
417a592331 Linux 3.13 compatibility
Reported by ArchangeGabriel, original patch by tuxoko (Issue
Bumblebee-Project/bbswitch#75)
2013-12-05 00:17:10 +01:00
9eb2e0d3fd Merge pull request #71 from TimothyGu/master
README.md: fix indentation of upstart script for enabling graphics on shutdown
2013-08-29 15:06:23 -07:00
4a029bc0ce README.md: Fix Markdown 2013-08-29 14:44:37 -07:00
ee0591b9b8 Clarify why Buffer is used instead of Package 2013-07-31 21:33:45 +02:00
c166b27e68 Change license to GPLv2+
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.
2013-06-25 15:30:56 +02:00
c7dbd6babb Update to version 0.7, update NEWS v0.7 2013-05-28 19:49:26 +02:00
2822d1630c README: mention kmod, workaround for T410 (Fixes GH-58) 2013-05-28 19:40:57 +02:00
c665a74def Fix WARNING on Linux 3.9 (Closes GH-55)
Patch by amonakov. This stops the following error:

    bbswitch: disabling discrete graphics
    ------------[ cut here ]------------
    WARNING: at drivers/pci/pci.c:1393 pci_disable_device+0x84/0x90()
    Hardware name: B7130
    [44B blob data]
    Modules linked in:
     bbswitch(O+) ip_set_hash_ip xt_set ip_set nfnetlink ipt_REJECT xt_recent xt_tcpudp xt_owner nf_conntrack_ipv6 nf_defrag
    Pid: 2653, comm: modprobe Tainted: G           O 3.9.1-1-custom #1
    Call Trace:
     [<ffffffff8103fe60>] warn_slowpath_common+0x70/0xa0
     [<ffffffff8103fedc>] warn_slowpath_fmt+0x4c/0x50
     [<ffffffff8130712c>] ? pci_bus_write_config_word+0x1c/0x20
     [<ffffffff8130d794>] pci_disable_device+0x84/0x90
     [<ffffffffa05b21f6>] bbswitch_off+0xa6/0x1d0 [bbswitch]
     [<ffffffffa0104248>] bbswitch_init+0x248/0x1000 [bbswitch]
     [<ffffffffa0104000>] ? 0xffffffffa0103fff
     [<ffffffff810002da>] do_one_initcall+0x10a/0x160
     [<ffffffff810a8720>] load_module+0x1d40/0x24a0
     [<ffffffff810a4410>] ? store_uevent+0x40/0x40
     [<ffffffff810a8fce>] sys_finit_module+0x7e/0x80
     [<ffffffff815afcc6>] system_call_fastpath+0x1a/0x1f
    ---[ end trace 1b312a60aa1b0ed6 ]---
    pci 0000:01:00.0: Refused to change power state, currently in D0
2013-05-10 19:18:34 +02:00
e21cdd7b3f Update REAMDE.md
Closes GH-28
2013-04-26 19:12:42 +02:00
f982a09546 Print path to DSM method on execution failure 2013-04-02 17:44:30 +02:00
3e50c7b118 Do not check for nvidia DSM on igd handle
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.
2013-04-02 17:40:38 +02:00
91814c63f1 Add copyright header (GH-50) 2013-03-22 10:24:06 +01:00
7361046b24 Update to version 0.6, update NEWS v0.6 2013-03-19 18:49:19 +01:00
2808cf520e README: update module options help 2013-03-19 18:49:19 +01:00
d90350ced1 Clarify license (GPLv3+) 2013-03-19 18:30:37 +01:00
a36a216439 grsec compatibility (GH-48)
The notifier_call member of struct notifier_block cannot be modified on
grsec-patched kernels. Set the pointer on compile-time instead.
2013-03-02 11:34:12 +01:00
5593d95193 Linux 3.8 compatibility hack
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>
2013-01-30 18:57:56 +01:00
fc2f2aa9c7 Add option to disable Optimus DSM (GH-14)
Necessary for one (some?) older laptops like the Lenovo T410s. Usage: put
"options bbswitch skip_optimus_dsm=1" in your modprobe.conf
2013-01-30 18:20:08 +01:00
cdb79257f2 .gitignore: ignore tar.gz and vim 2013-01-22 16:43:36 +01:00
b12b017f3a Update to version 0.5, update NEWS v0.5 2012-10-22 17:03:33 +02:00
2adcb24207 Merge branch 'master' into develop 2012-10-22 17:03:19 +02:00
8beb9e3f88 Add missing 'static' keyword 2012-10-22 16:43:40 +02:00
da55a70331 Add modeline for vim 2012-10-19 17:32:16 +02:00
7f9fb7adf9 Power on the PCIe port before accessing PCI config space (#35)
Fixes regression in Linux 3.6 when run-time power management is enabled. See
https://bugzilla.kernel.org/show_bug.cgi?id=48981 for a discussion.
2012-10-19 17:28:59 +02:00
b8a6029692 Convert printk to pr_... macros
For pr_debug outputs on _DSM results, use "make DEBUG=1"
2012-10-19 16:58:43 +02:00
aeff596524 Makefile: fix clean and install target
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.
2012-10-14 11:34:52 +02:00
dbf8aaf8e2 Use D3cold instead of D3hot to reflect real device state 2012-10-14 11:31:47 +02:00
d54dd454b6 Merge pull request #31 from wzzrd/develop
Add install and uninstall targets to Makefile
2012-08-26 06:52:27 -07:00
5f2db6c26a Add install and uninstall targets to Makefile
For if you do not want to or are unable to use dkms
2012-08-26 15:40:05 +02:00
8ada8849f2 Compatibility with older DKMS versions (GH-25) 2012-07-07 20:01:33 +02:00
979fbcf552 Merge branch 'develop' v0.4.2 2012-04-26 12:59:41 +02:00
d12ce73a0d Update to version 0.4.2, update NEWS 2012-04-26 12:56:47 +02:00
0d1429e8bb Fix documentation error (Closes GH-16) 2012-04-26 12:49:14 +02:00
af91008deb Fix formatting of arguments on case of ACPI failure (GH-12) 2012-03-01 21:53:52 +01:00
e13e6ffc54 Fix null deref when ACPI method call failed (GH-12) 2012-03-01 13:18:24 +01:00
f034252a13 Don't share buffer for muid/args, it'll be overwritten 2012-02-29 00:49:34 +01:00
647e3dddea Buffer overflow by one byte 2012-02-29 00:30:14 +01:00
804773eb22 Fix misuse of sizeof which trims arguments/muid (GH-12) 2012-02-29 00:10:32 +01:00
7c30e38bd1 Revert "Add support for WMMX method"
This reverts commit 11ddd3469f.
2012-01-28 10:57:04 +01:00
e321debb5b Revert "Support Optimus machines through WMMX (GH-2)"
This reverts commit 0ec41fa2da.
2012-01-28 10:57:03 +01:00
f4c2fadaf5 Revert "Load module dependency on make load: wmi"
This reverts commit fd74ba5bd8.
2012-01-28 10:56:58 +01:00
fd74ba5bd8 Load module dependency on make load: wmi 2012-01-24 14:33:21 +01:00
0ec41fa2da Support Optimus machines through WMMX (GH-2)
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.
2012-01-24 14:30:53 +01:00
7fd02221b2 Print version on load 2012-01-24 00:04:41 +01:00