ACPI Testing

Patrick C. F. Ernzer pcfe at pcfe.net
Sat Jun 19 10:45:07 UTC 2004


Hiho,

On Jun 19, 2004, at 4:08, D. D. Brierton wrote:

> I'm posting this here as opposed to fedora-list as this is a call to
> arms for any and all of us Fedora users who are trying to get ACPI to
[...]
My Hardware:
   IBM X31, Type 2672 (Cisco WLAN, no Bluetooth)

My Software:
   FC2,
   kernel 2.6.6-1.435,
   acpid-1.0.2-6,
   no FAT partition for S2D,
   using supplied radeon kernel module for video,
   linuxant driverloader-1.71 for WLAN,
   radeontool-1.5

What works:
   - suspend to RAM works by simply closing lid.
   - laptop_mode works.

Caveats:
   this setup requires pressing the power button (2-3 sec) to wake the 
machine up. Be careful not to press it too long, lest you execute 
/etc/acpi/events/sample.conf. Remove the latter if you do not want that 
risk.

What does not work:
   - suspend to disk does not work, no surprise as I do not have the 
necessary FAT partition for the BIOS to handle it, and 
CONFIG_SOFTWARE_SUSPEND and CONFIG_PM_DISK are not set. (search the 
list if you want to enable one of the latter)
   - So far I've only once had video corruption on wake from suspend2ram 
(both X and vt), this was cured by a further suspend cycle.

What is not tested:
   - the lightwatch tool from radeontool, I just close the lid when I 
want to save power.
   - test runs to see if removing the USB modules is still necessary, I 
just did not bother, adapt /etc/acpi/actions/suspend2ram.sh if you want 
to test


URLs that were helpful when setting this up: (as the instructions are 
for Debian at php.co.co and not necessarily for FC2 at the other URLs, 
use common sense when following them, not all things apply the same 
way)
   - http://www.php.co.ba/X31/
   - All X31 pages at http://www.linux-on-laptops.com/ibm.html

The files:
[/etc/acpi/events/lid]
event=button/lid.*
action=/etc/acpi/actions/lid.sh
[end]

[/etc/acpi/events/ac_adapter]
event=ac_adapter.*
action=/etc/acpi/actions/battery.sh
[end]

[/etc/acpi/events/sample.conf unmodified file from acppid-1.0.2-6]
# This is a sample ACPID configuration

event=button/power.*
action=/sbin/shutdown -h now
[end]

[/etc/acpi/actions/lid.sh]
#!/bin/sh

# lid event handler

status=`awk '/^state: / { print $2 }' /proc/acpi/button/lid/LID/state`

case $status in
         "closed")
                 echo "Bringing down vpnc"
                 /usr/share/doc/vpnc-0.2rm+zomb.1/vpnc-disconnect
                 echo "Suspending"
                 # suspend2ram works on X31
                 # with kernel 2.6.6-1.435
                 # pcfe, 2004-06-17
                 /etc/acpi/actions/suspend2ram.sh
                 exit 0
         ;;
         *)
                 echo "Lid event $status not handeled"
         ;;
esac
[end]

[/etc/acpi/actions/suspend2ram.sh as you can see it is still crawling 
with echo statements for debug, once you feel confident sleep works as 
you want it, comment the echo lines out]
#!/bin/sh

# adaptation of:
############################
## Author: mirza          ##
## /etc/scripts/standby   ##
##                        ##
## TestEnvironment:       ##
## - IBM X31              ##
## - X-driver=VESA        ##
## - kernel 2.6.5         ##
############################

# Changes made for Fedora Core 2 use by pcfe on 2004-06-17

############################
## start SUSPEND TO RAM   ##
############################
# change to VT8
chvt 8

# Unmount any NFS or SMB filesystems:
echo "unmounting NFS and SMB filesystems"
umount -a -r -t nfs,smbfs

# bluetooth off
# just left in here in case I plug a Bluetooth dongle in and use it
echo "bluetooth off"
hciconfig hci0 down

# remove modules
echo "remove modules"
#rmmod ipw2100    ## WLAN
dldrstop        ## stop linuxant driverloader
#rmmod psmouse    ## mouse
rmmod ehci-hcd   ## USB module
rmmod uhci-hcd   ##  -||-
#rmmod ohci-hcd   ##  -||-

# update the disk super block
echo "sync"
sync

# wait a second
sleep 1

# turn the LCD off
echo "backlight off"
radeontool light off

# suspend to ram
echo "suspend to ram"
echo -n mem > /sys/power/state


############################
## resume from SUSPEND    ##
############################
# wait 2 seconds to avoid double
# or longe pressing of power button
sleep 2

# set system time to hardware clock
echo "set system time to hardware clock"
hwclock --hctosys

# load modules
#modprobe psmouse    # mouse module

# don't load ipw2100. I'll load
# it manually if I need it
# modprobe ipw2100   # WLAN module
# this would be driverloader in my case anyway

# turn the LCD on
echo "turn the LCD on"
radeontool light on

# go back to VT7 (X)
echo "back to VT7"
chvt 7

# /tmp/standby_state file will be created to be able
# to avoid catching "LOCK" state by lightwatch.pl
# see lightwatch.pl for details. if /tmp/standby_state
# exists, lightwatch.pl will not react on this command
touch /tmp/standby_state
xscreensaver-command -lock 2> /dev/null 1> /dev/null
rm /tmp/standby_state

# start laptop mode if ac-adapter was
# plugged out during the suspend mode
# although linux should also do this
# during standby mode
#. /etc/acpi/acpi_handler.sh battery BAT0 2> /dev/null 1> /dev/null
. /etc/acpi/actions/battery.sh 2> /dev/null 1> /dev/null

########### END ###########
[end]

[/etc/acpi/actions/battery.sh]
#!/bin/sh

# cpu throttling
# cat /proc/acpi/processor/CPU0/throttling for more info
ACAD_THR=0
BATT_THR=2

# spindown time for HD (man hdparm for valid values)
# I prefer 2 hours for acad and 60 seconds for batt
ACAD_HD=244
BATT_HD=12

# Power management level
# 255 (off) on AC
# 128 (medium on batt
ACAD_PM=255
BATT_PM=64

# ac/battery event handler

status=`awk '/^state: / { print $2 }' /proc/acpi/ac_adapter/AC/state`

case $status in
         "on-line")
                 echo "Setting HD spindown for AC mode."
                 /sbin/laptop_mode stop
                 /sbin/hdparm -S $ACAD_HD /dev/hda > /dev/null 2>&1
                 /sbin/hdparm -B $ACAD_PM /dev/hda > /dev/null 2>&1
                 #echo -n $ACAD_CPU:$ACAD_THR > 
/proc/acpi/processor/CPU0/limit
                 exit 0
         ;;
         "off-line")
                 echo "Setting HD spindown for battery mode."
                 /sbin/laptop_mode start
                 /sbin/hdparm -S $BATT_HD /dev/hda > /dev/null 2>&1
                 /sbin/hdparm -B $BATT_PM /dev/hda > /dev/null 2>&1
                 #echo -n $BATT_CPU:$BATT_THR > 
/proc/acpi/processor/CPU0/limit
                 exit 0
         ;;
esac
[end]

[add at the bottom of /etc/rc.local]
# we run the detect AC on or off and detect laptop mode scrip once at 
boot
# acpid will do this for us on AC changes
/etc/acpi/actions/battery.sh
[end]

Plus you must set up the scripts you can extract from the file 
laptop-mode.txt in either the kernel doc RPM or the kernel source. Be 
sure to use the latest version.

> Some questions:
>
> 1. At the moment, both APM and ACPI start at boot. I didn't configure 
> it
> this way. This is a clean install of FC2 and this is what anaconda set
> up. It seems that both are started as services, although whilst apmd
> returns OK at boot it seems somewhat silent on its status:
[...]
> Do I actually want both running at the same time? I assume that for
> testing purposes I should disable APM, but I'd like to hear from 
> someone
> who knows what he's talking about.

That is normal, ACPI overrides APM. Both services can be on.
ACPI will only activate if the machine supports it.
APM will only activate if ACPI is not already on and the machine 
supports it.
No need to change anything.
>
> 2. I had read that 2.6 supports suspending to disk, and that it uses
> swap space for that and so I ensured that my swap partition is greater
> than the size of my RAM + VRAM. Is that correct?

The necessary patches are disabled (see above and search the list). If 
you decide to enable them, swap = ram should be enough as AFAIK the X31 
uses shared memory for video. On laptops that do not you must add up as 
you suggested. Given today's disk sizes, I set up my swap to be RAM*2 
on this machine anyway (1 Gig swap)
>
> 3. Does FC2 automatically go into "laptop" mode when I pull out the
> power cord, or do I have to do something manually? (I can't find now
> where I read about this, but I believe "laptop" mode is something new 
> in
> the 2.6 kernel which preserves battery life by slowing the CPU speed 
> and
> reducing disk activity.)

You'll need the scripts from above
>
> =====================================================================
>
> Personal (ideal world) goal for ACPI:
>
> What I guess I'd like ideally would be for both suspend to ram and
> suspend to disk to work (whether I'm in X or not), for closing and
> opening the lid of the laptop to trigger suspending to ram and resuming
> from ram, and for suspend to disk to happen automatically when battery
> level become critically low.

Set up as above for S2R, make a FAT partition and a suspend file in 
there with phdisk under DOS or lphdisk under linux. 
(http://www.procyon.com/~pda/lphdisk/), as stated above, I have not 
tested this personally.

RU

PCFE
-- 
---------------------- http://www.pcfe.net/ ----------------------
      Patrick C. F. Ernzer       |     e-mail: pcfe at pcfe.net
-go-and-make-your-own-disclaimer-+--------------------------------
Some people assert that many hackers have a mild form of autism or
Asperger's Syndrome, and are actually missing some of the brain
circuitry that lubricates `normal' human social interaction.
This may or may not be true.
  -- How To Ask Questions The Smart Way by Eric Steven Raymond





More information about the test mailing list