• Welcome to Valhalla Legends Archive.
 

FreeBSD configurations for laptops

Started by nslay, August 30, 2005, 08:07 AM

Previous topic - Next topic

nslay

Note: This will work for FreeBSD 5.4
If you run FreeBSD on a laptop with ACPI, you should be aware that FreeBSD is fully capable of not only suspending and resuming, but also CPU throttling for power saving.  There are various sysctl variables that allow you to even tune the CPU's speed.

To get suspend and resume to work with X, be sure to commend out glx in the appropriate X conf.  For some reason glx causes X to hang on resume and requires a hard reboot.  You probably don't use glx anyways, unless you play the various (but few) OpenGL games such as FlightGear or Quake III.  Now review your hw.acpi sysctl variables with

# sysctl hw.acpi

This will dump all your ACPI variables but you want to pay attention particularly to hw.acpi.supported_sleep_state as this tells you what sleep states your system supports.  You may review what each one does in the man pages.

# man acpiconf

Lets assume mine are supported; my hw.acpi.supported_sleep_state is:

hw.acpi.supported_sleep_state: S3 S4 S5

Now I personally use S3, all it does is stop the CPU clock and preserve the memory, where as S4 dumps the memory contents to the drive and S5 is soft off.

You should be able to put your system in sleep state S3 with

# acpiconf -s 3

Now you might want FreeBSD to react to your lid for convenience.  Luckily there is another sysctl variable that allows you to specify the sleep state to enter when the lid is closed.
If you haven't set it do so already, you'll notice this sysctl variable

hw.acpi.lid_switch_state: NONE

simply change the state by

# sysctl hw.acpi.lid_switch_state=S3

Be sure to add hw.acpi.lid_switch_state to your sysctl.conf

# cd /etc
# ee sysctl.conf

And add the line

hw.acpi.lid_switch_state=S3

Power saving is not a problem either and may be tuned in /etc/rc.conf as mentioned in the man pages

# man rc.conf

There are 4 variables in particular

performance_cx_lowest
performance_cpu_freq
economy_cx_lowest
economy_cpu_freq

where performance and economy distinguish what kind of power saving option you want for the corresponding power state.  These can be tuned by using "HIGH" for highest or "LOW" for lowest.
These are my settings:

performance_cx_lowest="HIGH"
performance_cpu_freq="HIGH"
economy_cx_lowest="LOW"
economy_cpu_freq="HIGH"

You might wonder what the cx_lowest does, all this does is distinguish throttling.  For example when plugged in the wall, you probably don't want any throttling so "HIGH" eliminates throttling.
Now, it is a bad idea to set the economy_cpu_freq to "LOW" as it will render the computer unusable.  I imagine you may specify the desired frequency if the generalizations aren't sufficient for your needs.

Edit: The power_profile thing is already in devd.conf, I didn't see it beforehand.  Everything below isn't really useful.

Next you will want to fix /etc/devd.conf as it tries to call /etc/acpi_ac which doesn't exist.
At the very bottom, observe:

notify 10 {
       match "system"          "ACPI";
       match "subsystem"       "ACAD";
       action                  "/etc/acpi_ac $notify";
};

and change "/etc/acpi_ac $notify"; to "/etc/rc.d/power_profile $notify"; and you're all set, now plugging and unplugging the the AC adapter changes CPU state as specified in rc.conf

Edit: To set a specific CPU frequency, be sure to check dev.cpu.0.freq_levels, you may specify one of these, and/or one of the cx variables in rc.conf instead of "HIGH" or "LOW"...you may also specify "NONE" for no change.