Save battery on Intel Linux

tux_compYou’ll find several threads on how Linux drains your battery on Google. While many of the issues might be hardware specific, there are some ways to enhance your battery life in addition to the standard TLP and powertop utilities. This article deals with some advanced mechanisms and utilities to go deeper into power management.

Hardware

  • Intel i5 processor
  • i915 integrated graphics
  • Centrino Advanced-N 6235 wifi card (driver: iwlwifi)

Software

  • Ubuntu 14.04.3 x86_64
  • systool: shows system device information by bus, class, and topology. It can also probe inserted kernel modules. It shows module attributes, parameters with values and information on the module related structures and memory layout in the kernel.
    To install on Ubuntu, run:

    $ sudo apt-get install sysfsutils
  • iasl: ACPI (Advanced Configuration and Power Interface) source language compiler/decompiler. We will use it to decipher any anomalies in GPE (General Purpose Events).
    To install on Ubuntu, run:

    $ sudo apt-get install iasl
  • powertop: well-known utility in Linuxland (from Intel). To install on Ubuntu, run:
    $ sudo apt-get install powertop

i915 tweaks

i915 is a very common Intel Graphics driver for integrated graphics cards. Earlier, there was a parameter powersave which is removed in the latest version of the driver. However, there are 3 parameters which can reduce the power consumption of the graphics subsystem.

enable_fbc: enable frame buffer compression for power savings (default: -1 [disabled])
enable_rc6: enable power-saving render C-state 6 (bitmask values 0, 1, 2, 4 [s 7 enables everything])
lvds_downclock: Use panel (LVDS/eDP) downclocking for power savings (default: false [disabled])

Before modifying, note down the values in use:

$ sudo systool -m i915 -av

To enable powersaving using these values, append the following to the line starting with GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub:

i915.enable_fbc=1 i915.enable_rc6=7 i915.lvds_downclock=1

Then run:

$ sudo update-grub2

and reboot.

iwlwifi tweaks

There are two parameters of interest in iwlwifi:

power_save: self explanatory (default: disabled)
power_level: ranges from 1 to 5 (level 2 seems to be unused from iwlwifi code)

Before modifying, note down the values in use:

$ sudo systool -m iwlwifi -av

To permanently enable these, add the following in /etc/default/grub (like we did for i915 above):

iwlwifi.power_save=Y iwlwifi.power_level=3

Note that I have used power_level 3. Some users reported wifi connection drop. However, I did not face any issues with power_level set to 1 or 3.

Apply:

$ sudo update-grub2

and reboot.

GPE tweaks

This section doesn’t necessarily apply to Intel and may not be useful for pure Intel boards. A Macbook user reported huge power savings with this tweak and hence I am leaving it in this article. Unhandled GPEs (ref: sysfs firmware acpi) can cause issues on Linux if there are too many of those, for example, in the order of millions. To check the number of GPE interrupts, run:

$ grep . -r /sys/firmware/acpi/interrupts/
/sys/firmware/acpi/interrupts/sci:    2661
/sys/firmware/acpi/interrupts/error:       0
/sys/firmware/acpi/interrupts/gpe00:       0   invalid
...
/sys/firmware/acpi/interrupts/gpe17:    2658   enabled
...
/sys/firmware/acpi/interrupts/gpe3F:       0   invalid
/sys/firmware/acpi/interrupts/sci_not:       4
/sys/firmware/acpi/interrupts/ff_pmtimer:       0   invalid
/sys/firmware/acpi/interrupts/ff_rt_clk:       0   disabled
/sys/firmware/acpi/interrupts/gpe_all:    2661
/sys/firmware/acpi/interrupts/ff_gbl_lock:       0   enabled
/sys/firmware/acpi/interrupts/ff_pwr_btn:       0   invalid
/sys/firmware/acpi/interrupts/ff_slp_btn:       0   invalid

Otherwise, to show only the lines with non-zero values, run:

$ grep 0 -rv /sys/firmware/acpi/interrupts/
/sys/firmware/acpi/interrupts/gpe06:       3   enabled
/sys/firmware/acpi/interrupts/gpe17:   2658   enabled
/sys/firmware/acpi/interrupts/sci_not:      4

As you can see, in my system gpe17 interrupts are high in number. Turned out, it is the brightness and monitor power control interrupt so I left it untouched. Also the number is quite less.

However, it can be turned off by running:

$ echo "disable"|sudo tee /sys/firmware/acpi/interrupts/gpe17
disable

However, if this is too high for you for a particular GPE, try to figure out what it is by pressing the brightness, volume, monitor power buttons and see if those are still working.

If everything works fine, you can disable the GPE in a startup script.

If there are issues, to enable again:

$ echo "enable"|sudo tee /sys/firmware/acpi/interrupts/gpe17
enable

Another way to check is to disassemble the acpi source. Run:

$ sudo cat /sys/firmware/acpi/tables/DSDT > ~/dsdt.dat
$ iasl -d dsdt.dat

The last command generates dsdt.dsl. Open dsdt.dsl in an editor and search for the GPE. I looked for GPE 17 and found that it is being handled:

Name (_GPE, 0x17) // _GPE: General Purpose Events

powertop quicky

There’s a quick powertop way to tweak stuff. However, it’s also potentially dangerous because you do not know what it is going to do and what it will affect. However, here it is:

$ sudo powertop --calibrate
$ sudo powertop --auto-tune

Disable Wakeup events

Flash videos running in your browser can wakeup the CPU from idle state even if you aren’t watching them. Consider disabling flash or removing it from your system.

A blinking cursor in gnome-terminal does the same too. To disable, run:

$ gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_blink_mode off

Brightness

Brightness is a great factor in power usage. Using a lower brightness is also good for your eyes. Check if you can lower your current brightness preference. It hardly takes a day for the eyes to adjust to it.

Got some interesting tips on power saving on Linux? Share with us!

One thought on “Save battery on Intel Linux”

Leave a Reply

Your email address will not be published. Required fields are marked *