Commit Graph

75 Commits (pm-rework)

Author SHA1 Message Date
Peter Wu e0c68599be Start handling audio devices via vga_switcheroo
This is an attempt to notify the audio driver (snd-hda-intel) that the
graphics card is being disabled to prevent access to a sleeping device.

TODO:
 - System suspend/resume is not really working properly with this.

Addresses https://github.com/Bumblebee-Project/bbswitch/issues/18
9 years ago
Peter Wu 5c7b3f53f2 Initial conversion to a PCI device using runtime PM
bbswitch will now bind a driver to the PCI device, this should remove
races that can occur when a PCI device is removed after bbswitch is
loaded.

Fixes:
 - Fixed a crash on some laptops that trigger a hotplug (a problem
   since Linux 3.12,
   https://github.com/Bumblebee-Project/bbswitch/issues/100)
 - As a driver is bound, you cannot "accidentally" load nouveau/nvidia
   anymore and confuse the power state.

Removed pci_set_master, there is no need for access to the PCI BARs.
pci_enable_device is removed too as the memory regions are not needed.

TODO:
 - Remove unload_state, it is a no-op.
 - Update load_state doc (assume ON by default).
 - System suspend/resume probably needs special treatment to ensure that
   the device is off again.
9 years ago
Peter Wu ca16c538fd Remove suspend/resume notifier
About to move to a PCI driver model where the device does not have to
be resumed, let's remove this code.
9 years ago
Peter Wu cca9882b46 Use cached dev_name
dis_dev might become invalid when the PCI device is removed from the
bus. There are more users, but this should be a start.
9 years ago
Peter Wu 2ccf2d7e31 Define ACPI_HANDLE macro for older versions
ACPI_HANDLE was added in Linux 3.8,
DEVICE_ACPI_HANDLE is gone in Linux 3.13. Move the definition a bit
higher, maybe we can reuse it later.
9 years ago
Peter Wu 0c38f97c3a Update to version 0.8, update NEWS 11 years ago
Peter Wu 417a592331 Linux 3.13 compatibility
Reported by ArchangeGabriel, original patch by tuxoko (Issue
Bumblebee-Project/bbswitch#75)
11 years ago
Peter Wu ee0591b9b8 Clarify why Buffer is used instead of Package 11 years ago
Peter Wu 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.
12 years ago
Peter Wu c7dbd6babb Update to version 0.7, update NEWS 12 years ago
Peter Wu 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
12 years ago
Peter Wu f982a09546 Print path to DSM method on execution failure 12 years ago
Peter Wu 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.
12 years ago
Peter Wu 91814c63f1 Add copyright header (GH-50) 12 years ago
Peter Wu 7361046b24 Update to version 0.6, update NEWS 12 years ago
Peter Wu d90350ced1 Clarify license (GPLv3+) 12 years ago
Peter Wu 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.
12 years ago
Peter Wu 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>
12 years ago
Peter Wu 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
12 years ago
Peter Wu b12b017f3a Update to version 0.5, update NEWS 12 years ago
Peter Wu 8beb9e3f88 Add missing 'static' keyword 12 years ago
Peter Wu da55a70331 Add modeline for vim 12 years ago
Peter Wu 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.
12 years ago
Peter Wu b8a6029692 Convert printk to pr_... macros
For pr_debug outputs on _DSM results, use "make DEBUG=1"
12 years ago
Peter Wu dbf8aaf8e2 Use D3cold instead of D3hot to reflect real device state 12 years ago
Lekensteyn d12ce73a0d Update to version 0.4.2, update NEWS 13 years ago
Lekensteyn af91008deb Fix formatting of arguments on case of ACPI failure (GH-12) 13 years ago
Lekensteyn e13e6ffc54 Fix null deref when ACPI method call failed (GH-12) 13 years ago
Lekensteyn f034252a13 Don't share buffer for muid/args, it'll be overwritten 13 years ago
Lekensteyn 647e3dddea Buffer overflow by one byte 13 years ago
Lekensteyn 804773eb22 Fix misuse of sizeof which trims arguments/muid (GH-12) 13 years ago
Lekensteyn 7c30e38bd1 Revert "Add support for WMMX method"
This reverts commit 11ddd3469f.
13 years ago
Lekensteyn e321debb5b Revert "Support Optimus machines through WMMX (GH-2)"
This reverts commit 0ec41fa2da.
13 years ago
Lekensteyn 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.
13 years ago
Lekensteyn 7fd02221b2 Print version on load 13 years ago
Lekensteyn 11ddd3469f Add support for WMMX method
This should support at least the Lenovo Ideapad Y470 and Y570. It probes the
WMMX method before calling the _DSM method directly since that method should
work for all machines that support the NVIDIA DSM.
13 years ago
Lekensteyn 8c0c5aa863 Allow everyone to get the status of the card (Closes GH-8) 13 years ago
Lekensteyn b0712e5185 Update to version 0.4.1, update NEWS 13 years ago
Lekensteyn 2d1effc903 Fix a harmless error message 13 years ago
Lekensteyn 8bd07d14af Bump to version 0.4, update NEWS 13 years ago
Lekensteyn ebf86f0617 Detect 3D controllers as gfx device too (GH-3) 13 years ago
Lekensteyn a904b442af Add debug message in case no ACPI handle is found 13 years ago
Lekensteyn c8b303c36c Add NEWS file, bump version to 0.3 13 years ago
Lekensteyn 358ce15bc1 Probe for nvidia DSM on Intel ACPI handle (GH-4) 13 years ago
Lekensteyn 62f9560821 Added module options to turn the card on/off on (un)load 13 years ago
Lekensteyn 7e792ef176 Bump module version to 0.2 13 years ago
Lekensteyn 73966cbddd Fix logic in Optimus DSM execution 13 years ago
Lekensteyn a62634d9fe Fix misleading warning, changed LOG_INFO -> LOG_DEBUG 13 years ago
Lekensteyn c10907b6b3 bbswitch: silently ignore large writes 13 years ago
Lekensteyn c6e50c9a37 bbswitch: Use seq_file instead of deprecated proc_read/proc_write
Now works with dd if=/proc/acpi/bbswitch bs=1 seek=N and if the size passed to
fread is larger than 1
13 years ago