Skip to content

Commit

Permalink
Merge branch 'master' into debian-test
Browse files Browse the repository at this point in the history
* master:
  Revert "Add support for NAND (SSD / Flash) device"
  Release lock descriptors in start-stop-programs module
  Update manpage about AC97 annoying click sound
  Add manpage for setting DISABLE_BATTERY_ALARM_CHECK
  Add option to disable alarm level check
  Re-order the check because HAL is deprecated
  Better check for SSD device
  Add support for NAND (SSD / Flash) device
  Check for external helper application's presence. And if not available, handle it.
  add $LIB_D so it can give the possibility to install udev/system files in different location
  Added PCIe ASPM module.
  Added PCIe ASPM module.
  Do not ship the board-specific/ folder in default installs
  • Loading branch information
rickysarraf committed Mar 16, 2013
2 parents 5ce776d + d4dfa88 commit d66d01b
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 32 deletions.
28 changes: 28 additions & 0 deletions etc/laptop-mode/conf.d/pcie-aspm.conf
@@ -0,0 +1,28 @@
#
# Configuration file for Laptop Mode Tools module pcie-aspm
#
# For more information, consult the laptop-mode.conf(8) manual page.
#

###############################################################################
# PCIe Activate State Power Management enable/disable switch
# --------------------------------------------------------------------------
#
# If you enable this setting, laptop mode tools will automatically configure
# PCIe ASPM to save power while running on battery mode.
#
# This laptop mode module may require that the following kernel option is
# enabled:
#
# pcie_aspm=force
#
###############################################################################

# Enable debug mode for this module
# Set to 1 if you want to debug this module
DEBUG=0

# Control PCIe ASPM tunables?
# Set to 0 to disable
CONTROL_PCIE_ASPM="auto"

8 changes: 8 additions & 0 deletions etc/laptop-mode/laptop-mode.conf
Expand Up @@ -117,6 +117,7 @@ ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=0
# intel-hda-powersave
# intel-sata-powermgmt
# nmi-watchdog
# pcie-aspm
# runtime-pm
# sched-mc-power-savings
# sched-smt-power-savings
Expand Down Expand Up @@ -176,6 +177,13 @@ MINIMUM_BATTERY_CHARGE_PERCENT=3
DISABLE_LAPTOP_MODE_ON_CRITICAL_BATTERY_LEVEL=1


#
# Ignore the alarm value reported by your batteries. In some instances a
# a battery will report an abnormally high alarm value, resulting in data-loss
# sensitive features being disabled prematurely.
#
DISABLE_BATTERY_ALARM_CHECK=0


###############################################################################
# Controlled hard drives and partitions
Expand Down
6 changes: 3 additions & 3 deletions etc/rules/99-laptop-mode.rules
@@ -1,3 +1,3 @@
ACTION=="change", SUBSYSTEM=="power_supply", RUN+="/lib/udev/lmt-udev auto"
ACTION=="add|remove", SUBSYSTEM=="machinecheck", RUN+="/lib/udev/lmt-udev auto"
ACTION=="add", SUBSYSTEM=="usb", RUN+="/lib/udev/lmt-udev force modules=usb-autosuspend devices=%k"
ACTION=="change", SUBSYSTEM=="power_supply", RUN+="@LIB_D@/udev/lmt-udev auto"
ACTION=="add|remove", SUBSYSTEM=="machinecheck", RUN+="@LIB_D@/udev/lmt-udev auto"
ACTION=="add", SUBSYSTEM=="usb", RUN+="@LIB_D@/udev/lmt-udev force modules=usb-autosuspend devices=%k"
16 changes: 9 additions & 7 deletions install.sh
Expand Up @@ -28,6 +28,7 @@
#

[ -z "$MAN_D" ] && MAN_D="/usr/man"
[ -z "$LIB_D" ] && LIB_D="/lib"

if [ -z "$ACPI" ] ; then
ACPI=auto
Expand Down Expand Up @@ -112,11 +113,10 @@ $INSTALL -d -m 755 "$DESTDIR/usr/share/laptop-mode-tools/modules"
$INSTALL -d -m 755 "$DESTDIR/usr/share/laptop-mode-tools/module-helpers"
$INSTALL -d -m 755 "$DESTDIR/usr/lib/tmpfiles.d"
$INSTALL -d -m 755 "$DESTDIR/etc/laptop-mode/conf.d"
$INSTALL -d -m 755 "$DESTDIR/etc/laptop-mode/conf.d/board-specific"
$INSTALL -d -m 755 "$DESTDIR/etc/laptop-mode/modules"
$INSTALL -d -m 755 "$DESTDIR/usr/sbin"
$INSTALL -d -m 755 "$DESTDIR/lib/udev"
$INSTALL -d -m 755 "$DESTDIR/lib/systemd/system"
$INSTALL -d -m 755 "$DESTDIR/$LIB_D/udev"
$INSTALL -d -m 755 "$DESTDIR/$LIB_D/systemd/system"
$INSTALL -d -m 755 "$DESTDIR/$MAN_D/man8"

ALREADY_EXISTED=0
Expand Down Expand Up @@ -201,16 +201,18 @@ fi
if ( ! $INSTALL -D -m 644 etc/rules/99-laptop-mode.rules "$DESTDIR/etc/udev/rules.d/99-laptop-mode.rules" ) ; then
echo "$0: Failed to install udev rule into /etc/udev/rules.d/ Installation failed."
exit 23
else
sed -i -e "s|@LIB_D@|$LIB_D|g" $DESTDIR/etc/udev/rules.d/99-laptop-mode.rules >/dev/null 2>&1
fi

# udev helper tool
if ( ! $INSTALL -D -m 755 etc/rules/lmt-udev "$DESTDIR/lib/udev/lmt-udev" ) ; then
echo "$0: Failed to install udev helper tool into /lib/udev/ Installation failed."
if ( ! $INSTALL -D -m 755 etc/rules/lmt-udev "$DESTDIR/$LIB_D/udev/lmt-udev" ) ; then
echo "$0: Failed to install udev helper tool into $LIB_D/udev Installation failed."
fi

# systemd service
if ( ! $INSTALL -D -m 644 etc/systemd/laptop-mode.service "$DESTDIR/lib/systemd/system/laptop-mode.service" ) ; then
echo "$0: Failed to install systemd service into /lib/systemd/system/ Installation failed."
if ( ! $INSTALL -D -m 644 etc/systemd/laptop-mode.service "$DESTDIR/$LIB_D/systemd/system/laptop-mode.service" ) ; then
echo "$0: Failed to install systemd service into $LIB_D/systemd/system/ Installation failed."
fi

# and systemd's tmpfiles.d
Expand Down
19 changes: 18 additions & 1 deletion man/laptop-mode.conf.8
Expand Up @@ -98,6 +98,10 @@ If this option is enabled, the data loss sensitive features of laptop mode are
disabled when the battery reports its state as "critical". This option is only
supported on ACPI.

.IP "\fBDISABLE_BATTERY_ALARM_CHECK\fP" 10
If this option is enabled, the alarm values are ignored from the battery. This
is helpful if you have a broken battery which is reporting false alarms.

.IP "\fBHD\fP" 10
The hard drives which laptop mode should operate upon. If you have multiple
hard drives, you should list them all in this option, separated by spaces, for
Expand Down Expand Up @@ -528,6 +532,8 @@ power saving mode.
If this option is enabled, laptop mode tools will automatically enable the
AC97 power saving settings. The power saving settings are always enabled, not
only on battery power.
Note: On some machines it has been reported that the AC97 power savings triggers
the annoying click sound during power state transitions


.SS "\fI/etc/laptop-mode/conf.d/nmi-watchdog.conf\fP"
Expand All @@ -538,7 +544,18 @@ Enabling this module lowers down one hw-pmu counter.
.IP "\fBCONTROL_NMI_WATCHDOG\fP" 10
If this option is enabled, laptop mode tools will automatically disable the
NMI Watchdog timer when on battery. This module is part of auto modules. Thus enabling
auto modules setting will activate this module automatically
auto modules setting will activate this module automatically.

.SS "\fI/etc/laptop-mode/conf.d/pci-aspm.conf\fP"

The pcie-aspm module allows you to enable the PCI Express (PCIe) Active State
Power Management (ASPM).

.IP "\fBCONTROL_PCI_ASPM\fP" 10
If this option is enabled, laptop mode tools will enable PCI ASPM powersave
mode when on battery. This module is part of auto modules. Thus enabling
auto modules setting will activate this module automatically. PCIe ASPM may
require that the pcie_aspm=force kernel option is enabled.

.SS "\fI/etc/laptop-mode/conf.d/runtime-pm.conf\fP"

Expand Down
22 changes: 11 additions & 11 deletions usr/sbin/laptop_mode
Expand Up @@ -670,20 +670,20 @@ lmt_main_function ()
fi

if [ "$ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED" -ne 0 -a "$ACTIVATE" -eq 0 ] ; then
if [ -x "`which hal-find-by-property`" ] ; then
HAL_LID_BUTTON=$(hal-find-by-property --key "button.type" --string "lid")
fi
if [ "$HAL_LID_BUTTON" != "" ] ; then
HAL_LID_BUTTON_STATE=$(hal-get-property --udi $(hal-find-by-property --key "button.type" --string "lid") --key "button.state.value")
if [ "$HAL_LID_BUTTON_STATE" = "true" ] ; then
log "VERBOSE" "Setting action to \"start\" because the lid is closed (says HAL)."
ACTIVATE=1
fi
elif [ -f /proc/acpi/button/lid/*/state ] ; then
if [ -f /proc/acpi/button/lid/*/state ] ; then
if ( grep -q "closed" /proc/acpi/button/lid/*/state ) ; then
log "VERBOSE" 'Setting action to "start" because the lid is closed (says /proc/acpi/button/lid/*/state).'
ACTIVATE=1
fi
elif ( which hal-find-by-property >/dev/null ) ; then
HAL_LID_BUTTON=$($HAL_FIND_BY_PROPERTY --key "button.type" --string "lid")
if [ "$HAL_LID_BUTTON" != "" ] ; then
HAL_LID_BUTTON_STATE=$(hal-get-property --udi $(hal-find-by-property --key "button.type" --string "lid") --key "button.state.value")
if [ "$HAL_LID_BUTTON_STATE" = "true" ] ; then
log "VERBOSE" "Setting action to \"start\" because the lid is closed (says HAL)."
ACTIVATE=1
fi
fi
else
log "MSG" "Warning: ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED is set, but there is no file"
log "MSG" "/proc/acpi/button/lid/.../state, and hal information is not available either!"
Expand Down Expand Up @@ -823,7 +823,7 @@ lmt_main_function ()
ENOUGH_CHARGE=1
fi

if [ "$ALARM_LEVEL" -ne 0 ] ; then
if [ "$ALARM_LEVEL" -ne 0 ] && [ "$DISABLE_BATTERY_ALARM_CHECK" -ne 1 ]; then
if [ "$REMAINING" -le "$ALARM_LEVEL" ] ; then
# Restore the state we had before checking this battery, so that
# this battery does not count as having enough charge.
Expand Down
29 changes: 25 additions & 4 deletions usr/share/laptop-mode-tools/modules/ethernet
Expand Up @@ -4,6 +4,27 @@
#

if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHERNET = xauto ]; then

# Let's check the binaries firts
if [ -x /sbin/ethtool ]; then
ETHTOOL=/sbin/ethtool
elif [ -x /usr/sbin/ethtool ]; then
ETHTOOL=/usr/sbin/ethtool
else
log "VERBOSE" "ethtool is not installed"
ETHTOOL=/bin/false
fi

if [ -x /sbin/mii-tool ]; then
MIITOOL=/sbin/mii-tool
elif [ -x /usr/sbin/mii-tool ]; then
MIITOOL=/usr/sbin/mii-tool
else
log "VERBOSE" "mii-tool is not installed"
MIITOOL=/bin/false
fi


if [ $ON_AC -eq 1 ]; then
if [ "$ACTIVATE" -eq 1 ]; then
THROTTLE_ETHERNET="$LM_AC_THROTTLE_ETHERNET"
Expand Down Expand Up @@ -71,7 +92,7 @@ if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHE

# Wakeup-on-LAN handling
if [ x$DISABLE_WAKEUP_ON_LAN = x1 ] ; then
ret=`ethtool -s $DEVICE wol d 2>&1`
ret=`$ETHTOOL -s $DEVICE wol d 2>&1`
exit_status=$?;
log "VERBOSE" "$ret"
if [ $exit_status -eq 0 ]; then
Expand All @@ -82,7 +103,7 @@ if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHE
fi

# Determine speed
speed=`mii-tool -v $DEVICE 2>/dev/null | grep capabilities | tr ' ' '\n' |\
speed=`$MIITOOL -v $DEVICE 2>/dev/null | grep capabilities | tr ' ' '\n' |\
sort -n | sed -ne '/^1.*/p' | cut -d "b" -f1`
if [ -z "$speed" ]; then
speed=0;
Expand Down Expand Up @@ -112,7 +133,7 @@ if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHE
# Handle throttling
if [ x$THROTTLE_ETHERNET = x1 ] ; then
# Handle Speed Throttling
ret=`ethtool -s $DEVICE speed $THROTTLE_SPEED 2>&1`
ret=`$ETHTOOL -s $DEVICE speed $THROTTLE_SPEED 2>&1`
exit_status=$?;
log "VERBOSE" "$ret";
if [ $exit_status -eq 0 ]; then
Expand All @@ -122,7 +143,7 @@ if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHE
fi
else
# Handle Speed Throttling
ret=`ethtool -s $DEVICE speed $MAX_SPEED 2>&1`
ret=`$ETHTOOL -s $DEVICE speed $MAX_SPEED 2>&1`
exit_status=$?;
log "VERBOSE" "$ret";
if [ $exit_status -eq 0 ]; then
Expand Down
19 changes: 13 additions & 6 deletions usr/share/laptop-mode-tools/modules/hdparm
Expand Up @@ -22,12 +22,19 @@ is_capable() {
return 1;
fi

if [ -n "$(hdparm -I $1 | grep SSD)" ]; then
# If the device is a SSD, it is not capable of power management.
if [ "$2" = "POWERMGMT" ]; then
log "VERBOSE" "$1 is a SSD, not capable of power management"
return 1
fi
# If the disk is an SSD, we skip any of the power mgmt features, for now.
SYSFS_DEV=/sys/block/$dev
if [ -f $SYSFS_DEV/queue/rotational ]; then
IS_ROTATIONAL=`cat $SYSFS_DEV/queue/rotational`
else
log "VERBOSE" "Disk $THISHD does not support the rotational interface"
# We'll apply the traditional drive assumptions here.
IS_ROTATIONAL=1
fi

if [ "$IS_ROTATIONAL" -eq 0 ]; then
log "VERBOSE" "Disk $THISHD is a NAND (SSD / Flash) Device. Not apply power management savings"
return 1
fi

# If we are running udev, this is the most portable way
Expand Down
35 changes: 35 additions & 0 deletions usr/share/laptop-mode-tools/modules/pcie-aspm
@@ -0,0 +1,35 @@
#! /bin/sh
#
# Laptop mode tools module: PCIe Active State Power Management
#

if [ x$CONTROL_PCIE_ASPM = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_PCIE_ASPM = xauto ]; then
if [ $ON_AC -eq 1 ]; then
log "VERBOSE" "On AC power: setting pcie_aspm to default"
if [ -f /sys/module/pcie_aspm/parameters/policy ]; then
echo default > /sys/module/pcie_aspm/parameters/policy
if [ $? -eq 0 ]; then
log "VERBOSE" "PCIe ASPM set to 'default'"
else
log "VERBOSE" "PCIe ASPM tweaking is prohibited by the kernel"
fi
else
log "VERBOSE" "PCIe ASPM is not available"
fi
else
log "VERBOSE" "On battery: setting pcie_aspm to powersave"
if [ -f /sys/module/pcie_aspm/parameters/policy ]; then
echo powersave > /sys/module/pcie_aspm/parameters/policy
if [ $? -eq 0 ]; then
log "VERBOSE" "PCIe ASPM set to 'powersave'"
else
log "VERBOSE" "PCIe ASPM tweaking is prohibited by the kernel"
fi
else
log "VERBOSE" "PCIe ASPM is not available"
fi
fi
else
log "VERBOSE" "PCIe ASPM power savings module is disabled"
fi

16 changes: 16 additions & 0 deletions usr/share/laptop-mode-tools/modules/start-stop-programs
Expand Up @@ -4,6 +4,22 @@
#

if [ x$CONTROL_START_STOP = x1 ] ; then


#
# Release the locks. The global locks of LMT get inherited by all sub-processes
# which, further, gets inherited by all programs that are run as part of this
# module, including daemon. By releasing the lock for this shell process, we ensure
# that the daemons will not hold lock to the LMT locks.
#

# TODO: Variablize the lock descriptors and then use them instead
log "VERBOSE" "Prepare to release locks for descriptors 8 & 9"
exec 8>&-
exec 9>&-
log "VERBOSE" "Released locks for descriptors 8 & 9"


#
# Undo the previous state.
#
Expand Down
2 changes: 2 additions & 0 deletions usr/share/laptop-mode-tools/modules/wireless-ipw-power
Expand Up @@ -27,13 +27,15 @@ if [ x$CONTROL_IPW_POWER = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_IPW
IWPRIV=/usr/sbin/iwpriv
else
log "VERBOSE" "iwpriv is not installed"
IWPRIV=/bin/false
fi
if [ -x /sbin/iwconfig ] ; then
IWCONFIG=/sbin/iwconfig
elif [ -x /usr/sbin/iwconfig ] ; then
IWCONFIG=/usr/sbin/iwconfig
else
log "VERBOSE" "iwconfig is not installed"
IWCONFIG=/bin/false
fi

SET_I3945_AC_PARMS="set_power $IPW3945_AC_POWER"
Expand Down
2 changes: 2 additions & 0 deletions usr/share/laptop-mode-tools/modules/wireless-iwl-power
Expand Up @@ -63,13 +63,15 @@ if [ x$CONTROL_IWL_POWER = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_IWL
IWPRIV=/usr/sbin/iwpriv
else
log "VERBOSE" "iwpriv is not installed"
IWPRIV=/bin/false
fi
if [ -x /sbin/iwconfig ] ; then
IWCONFIG=/sbin/iwconfig
elif [ -x /usr/sbin/iwconfig ] ; then
IWCONFIG=/usr/sbin/iwconfig
else
log "VERBOSE" "iwconfig is not installed"
IWCONFIG=/bin/false
fi

WIFI_IFNAMES=""
Expand Down
1 change: 1 addition & 0 deletions usr/share/laptop-mode-tools/modules/wireless-power
Expand Up @@ -62,6 +62,7 @@ if [ x$CONTROL_WIRELESS_POWER_SAVING = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x
IWCONFIG=/usr/sbin/iwconfig
else
log "VERBOSE" "iwconfig is not installed"
IWCONFIG=/bin/false
fi

# Translate 1 => on, 0 => off
Expand Down

0 comments on commit d66d01b

Please sign in to comment.