X-Git-Url: https://gitweb.dragonflybsd.org/ikiwiki.git/blobdiff_plain/8b2a55bf973451879e6880de2ffe25a4b4b93b63..HEAD:/docs/user/Powersave.mdwn
diff --git a/docs/user/Powersave.mdwn b/docs/user/Powersave.mdwn
index 6015dd36..d81112a3 100644
--- a/docs/user/Powersave.mdwn
+++ b/docs/user/Powersave.mdwn
@@ -1,57 +1,73 @@
-## Powersaving with DragonFly laptop
-
+# Powersaving with DragonFly laptop
+[[!toc levels=2]]
Here are some hints to make DragonFly laptop suck less power and therefore run longer and cooler.
-
-
At first general note - just blow dust out of your laptop. Due to nature of cooling used in laptops this might make huge difference in temperature. I've seen laptops where temperature dropped ~20°C after 5 seconds blowing session.
-### CPU
-
-* Let CPU(s) switch to lower C-states than default C1. In DragonFly this can be controlled by ***hw.acpi.cpu.cx_lowest*** or ***hw.cpu[NUM].cx_lowest*** [sysctl(8)](http://leaf.dragonflybsd.org/cgi/web-man/?command#sysctl§ion8). CPU(s) have to support lower states. With ***hw.acpi.cpu.cx_lowest*** you can control all CPUs (cores) at once, with ***hw.cpu[NUM].cx_lowest*** every CPU individually. ***hw.cpu[NUM].cx_supported*** gives to you the list of supported C-states and latencies of each supported state (how long it takes to switch from Cx to C0). ***hw.cpu[NUM].cx_usage*** gives to you some statistics.
-
- In my Lenovo Thinkpad X61s relevant sysctl's look like this:
-
-
- $ sysctl hw.acpi.cpu.cx_lowest
- hw.acpi.cpu.cx_lowest: C3
-
- $ sysctl -a | grep ^hw.cpu
- hw.cpu0.cx_supported: C1/1 C2/1 C3/17
- hw.cpu0.cx_lowest: C3
- hw.cpu0.cx_usage: 0.00% 0.80% 99.19%
- hw.cpu1.cx_supported: C1/1 C2/1 C3/17
- hw.cpu1.cx_lowest: C3
- hw.cpu1.cx_usage: 0.00% 0.48% 99.51%
-
- On my idle laptop switching lowest to C3 from C1 makes ~2.5W difference in power consumption and 10°C difference in temperature.
-
+## CPU C states
-* ACPI supports only states up to C3, but modern mobile CPU's support C-states up to C6. CPU's can be forced to enter these lower states, but it's not really recommended. If you really want to experiment with this, you have to consult the manual of chipset you are using.
+Let CPU(s) switch to lower C-states than default C1. In DragonFly this can be controlled by *hw.acpi.cpu.cx_lowest* or *hw.cpu[NUM].cx_lowest* [sysctl(8)](http://leaf.dragonflybsd.org/cgi/web-man/?command#sysctl§ion8). CPU(s) have to support lower states. With *hw.acpi.cpu.cx_lowest* you can control all CPUs (cores) at once, with *hw.cpu[NUM].cx_lowest* every CPU individually. *hw.cpu[NUM].cx_supported* gives to you the list of supported C-states and latencies of each supported state (how long it takes to switch from Cx to C0). *hw.cpu[NUM].cx_usage* gives to you some statistics.
- My brief experience shows that there is no difference in power consumption whether you are using C4 or lowering a voltage with [est(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command#est§ion4). C5 and C6 can make sense in tickless system only (DragonFly isn't such).
+You will generally want to control all the CPUs at once:
-You can find more general info about processor C-states [here](http://www.techarp.com/showarticle.aspx?artno#420&pgno5).
+ # sysctl hw.acpi.cpu.cx_lowest=C3
+Additionaly, this enables deep C-states:
-* Use [est(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command#est§ion4). The one currently in the DragonFly kernel doesn't support modern multicore CPU's. I'm using the one written by Michal Belczyk you can get from [here](http://bsd.krakow.pl/df/est_core.tgz).
+ # sysctl machdep.mwait.CX.idle=AUTODEEP
- In my Lenovo Thinkpad X61s relevant sysctl's look like this:
+(Note that you can add the sysctl commands to */etc/sysctl.conf* so they are called automatically at boot-time.)
- $ sysctl machdep.est
- machdep.est.frequency.available: 1200 1400 1600
- machdep.est.frequency.current: 1200
- machdep.est.frequency.target: 1200
- machdep.est.voltage.available: 940 956 972 988 1004 1020 1036 1052 1068 1084 1100 1116
- machdep.est.voltage.current: 940
- machdep.est.voltage.target: 940
+Relevant sysctl's then look like this:
-
- Switching to minimums (frequency really doesn't matter in idle machine though) makes ~1.7W difference in power consumption in my idle laptop.
-
-### Backlight
+ $ sysctl hw.acpi | grep cx
+ hw.acpi.cpu.cx_lowest: C3
+ hw.acpi.cpu.cx_lowest_use: C3
+ hw.acpi.cpu0.cx_supported: C1/1 C2/1 C3/57
+ hw.acpi.cpu0.cx_lowest: C3
+ hw.acpi.cpu0.cx_lowest_use: C3
+ hw.acpi.cpu0.cx_usage: 3.54% 57.09% 39.36% last 9us
+ hw.acpi.cpu1.cx_supported: C1/1 C2/1 C3/57
+ hw.acpi.cpu1.cx_lowest: C3
+ hw.acpi.cpu1.cx_lowest_use: C3
+ hw.acpi.cpu1.cx_usage: 0.00% 9.09% 90.90% last 804us
+
+You may need to add these lines to */boot/loader.conf* (for example if you get a "No such file or directory" error and a "no suitable intr cputimer found" message in dmesg when calling sysctl with the above parameters):
+
+ # Use i8254 as interrupt cputimer
+ hw.i8254.intr_disable="0"
+ # Get proper deep C-states
+ machdep.cpu.mwait.bm_sts="0"
+
+On my idle laptop (Lenovo Thinkpad X61s) switching lowest to C3 from C1 makes ~2.5W difference in power consumption and 10°C difference in temperature.
+
+ACPI supports only states up to C3, but modern mobile CPU's support C-states up to C6. CPU's can be forced to enter these lower states, but it's not really recommended. If you really want to experiment with this, you have to consult the manual of chipset you are using.
+Note that C5 and C6 can make sense in tickless system only (DragonFly isn't such).
+
+You can find more general info about processor C-states [here](http://www.techarp.com/showarticle.aspx?artno=420&pgno=5).
+
+## Frequency scaling
+
+Use [powerd(8)](http://leaf.dragonflybsd.org/cgi/web-man/?command=powerd§ion=8) for frequency scaling by adding `powerd_enable="YES"` to */etc/rc.conf*. You can then observe the frequency values in sysctl (example from the leaf.dragonflybsd.org machine):
+
+ $ sysctl hw.acpi.cpu | grep px
+ hw.acpi.cpu.px_dom3.available: 2600 1300
+ hw.acpi.cpu.px_dom3.members: cpu3(2600)
+ hw.acpi.cpu.px_dom3.select: 2600
+ hw.acpi.cpu.px_dom2.available: 2600 1300
+ hw.acpi.cpu.px_dom2.members: cpu2(2600)
+ hw.acpi.cpu.px_dom2.select: 2600
+ hw.acpi.cpu.px_dom1.available: 2600 1300
+ hw.acpi.cpu.px_dom1.members: cpu1(2600)
+ hw.acpi.cpu.px_dom1.select: 2600
+ hw.acpi.cpu.px_dom0.available: 2600 1300
+ hw.acpi.cpu.px_dom0.members: cpu0(2600)
+ hw.acpi.cpu.px_dom0.select: 2600
+ hw.acpi.cpu.px_global: 2600
+
+## Backlight
Switch backlight to (usable) minimum. There might be several ways to do it, you have to find the one which works for you.
@@ -64,22 +80,38 @@ Things you can look at:
Switching backlight brightness from 100% to 20% (still completely usable) with acpi_video(4) makes ~2.6W difference in power consumption in my X61s.
-### Other devices
+## Network interfaces down
+
+Put network interfaces not in use to down (ifconfig if[NUM] down). This can make huge difference in both power consumption and temperature especially with wireless devices.
+
+It makes ~2.5W difference in power consumption and 10°C difference (according to [acpi_thinkpad(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command#acpi_thinkpad§ion4) sensors) in my X61s with [ath(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command=ath§ion=4) card.
-* Put network interfaces not in use to down (ifconfig if[NUM] down). This can make huge difference in both power consumption and temperature especially with wireless devices.
+## Unused devices
- It makes ~2.5W difference in power consumption and 10°C difference (according to [acpi_thinkpad(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command#acpi_thinkpad§ion4) sensors) in my X61s with [ath(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command=ath§ion=4) card.
-* DragonFly let you put devices not in use (no driver attached to it) to the D3 (power off) state. By default no device is put into D3, but you can control it with hw.pci.do_power_nodriver tunable (set it to 3 if you don't have good reason not to do it). You can switch devices into D3 at runtime via unloading module (ie. making a device "not in use"). Please note that unloading/loading modules is not well tested and it's common that unloading module (or loading it after unloading) makes device unusable or even panics a system.<
><
>
+DragonFly lets you put devices not in use (no driver attached to it) to the D3 (power off) state. By default no device is put into D3, but you can control it with hw.pci.do_power_nodriver tunable (set it to 3 if you don't have good reason not to do it). You can switch devices into D3 at runtime via unloading module (ie. making a device "not in use"). Please note that unloading/loading modules is not well tested and it's common that unloading module (or loading it after unloading) makes device unusable or even panics a system.
- Savings highly depend on hardware. There are some numbers from my X61s:
+Savings highly depend on hardware. There are some numbers from my X61s:
* [em(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command#em§ion4) - no difference
* [ath(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command#ath§ion4) - ~0.2W
* [snd_hda(4)](http://leaf.dragonflybsd.org/cgi/web-man/?command#snd_hda§ion4) - ~0.3W
- [Here](http://www.techarp.com/showarticle.aspx?artno#420&pgno4) you can find more general info about devices' D-states.
+[Here](http://www.techarp.com/showarticle.aspx?artno=420&pgno=4) you can find more general info about devices' D-states.
+
+## AHCI
+
+Some AHCI host bus adapters have link power management support.
+This feature can be controlled with a per-port sysctl, for example to activate agressive power management on ports 0 and 1:
+
+ # sysctl hw.ahci0.0.link_pwr_mgmt=2
+ # sysctl hw.ahci0.1.link_pwr_mgmt=2
+
+Enabling AHCI link power management can save ~0.8W.
+## Other resources
+If you are using a compatible Intel CPU, the corepower(4) kernel module can, once loaded, report power usage through either of these two commands
-***More to come ...***
+ sysctl hw.sensors
+ systat -sensors