power.sh should allow laptop_mode to do it's thing
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| acpi-support (Ubuntu) |
Undecided
|
Unassigned |
Bug Description
Binary package hint: acpi-support
In 6.06.1 LTS, /etc/acpi/power.sh explicitly calls
laptop_mode start
and
laptop_mode stop
This means that the preferences specified in /etc/laptop-
Instead, power.sh should simply call
laptop_mode auto
in both cases. That way the user's preferences as to when laptop mode will be used will be honoured.
The specific bug that was hitting me was that laptop mode was being disabled when AC power was reconnected, despite having set ENABLE_
Also, power.sh is explicitly changing the hard drive spindown and power management behaviour by calling hdparm (with fixed, uncofigurable values). It should leave this to laptop_mode, which already has completely configurable functionality to do this.
Patch against 6.06.1 LTS:
--- power.sh.orig 2006-12-04 14:54:44.000000000 +0000
+++ power.sh 2006-12-04 15:33:17.000000000 +0000
@@ -3,36 +3,6 @@
. /etc/default/
. /usr/share/
-function laptop_mode_enable {
- $LAPTOP_MODE start
-
- for x in /sys/bus/
- drive=$(basename $(readlink $x));
- $HDPARM -S 12 /dev/$drive 2>/dev/null
- $HDPARM -B 1 /dev/$drive 2>/dev/null
- done
-
- for x in /sys/bus/
- drive=$(basename $(readlink $x));
- $HDPARM -S 12 /dev/$drive 2>/dev/null
- $HDPARM -B 1 /dev/$drive 2>/dev/null
- done
-}
-
-function laptop_mode_disable {
- for x in /sys/bus/
- drive=$(basename $(readlink $x));
- $HDPARM -S 0 /dev/$drive 2>/dev/null
- $HDPARM -B 255 /dev/$drive 2>/dev/null
- done
- for x in /sys/bus/
- drive=$(basename $(readlink $x));
- $HDPARM -S 0 /dev/$drive 2>/dev/null
- $HDPARM -B 255 /dev/$drive 2>/dev/null
- done
- $LAPTOP_MODE stop
-}
-
getState;
checkStateChanged;
@@ -46,15 +16,12 @@
for SCRIPT in /etc/acpi/
. $SCRIPT
done
- if [ x$ENABLE_
- (sleep 5 && laptop_
- fi
else
for SCRIPT in /etc/acpi/
. $SCRIPT
done
- if [ x$ENABLE_
- (sleep 5 && laptop_
- fi
fi
-done
\ No newline at end of file
+ if [ x$ENABLE_
+ (sleep 5 && $LAPTOP_MODE auto)&
+ fi
+done
James Stembridge (jstembridge) wrote : | #1 |
Jason (jasonxh) wrote : | #2 |
Indeed! I was just about to report this bug and found this one. Current power.sh does not respect configurations in laptop-mode.conf on: when to enable, hdparm -B value, and hdparm -S value. Why no just leave decisions to laptop-mode.conf and make things NOT that ambiguous!
Jason (jasonxh) wrote : | #3 |
Forgot to mention that I'm using Feisty.
Tormod Volden (tormodvolden) wrote : | #4 |
AFAICS, this is the same in Hardy. I am not sure how much power.sh is in use, but it looks wrong as it is.
description: | updated |
Changed in acpi-support: | |
status: | New → Confirmed |
chourave (gaston72) wrote : | #5 |
I agree with Roy description.
Everything worked fine under Gutsy with kernel 2-6-22-14, I have just upgraded my kernel : installing 2-6-24-16.
It fixes my resume problem, but now laptop-mode is broken.
1. In order to control everything using laptop-mode.conf, I used to enable laptop-mode both on AC and battery. Now it's impossible.
2. after resume, the hdparm settings are overwritten and the hard disk problem comes back (Load_Cycle_Count issue)
I'm becoming crazy with the behaviour of power.sh :
- the laptop-mode setting are overwritten by power.sh because of the definition of laptop_mode_enable or laptop_mode_disable functions.
- if you use SCRIPT in /etc/acpi/ac.d/ or /etc/acpi/
The loop execute them, but their action will be cancelled by the call to laptop_mode_enable or laptop_
For the resume problem, the solution proposed here :
https:/
doesn't work because you always call power.sh, which sets wrong parameter values
As far as I understand, the solution proposed by Roy is the good one :
modifying power.sh : i.e. replacing the "laptop_
It could be implemented as follow :
- First : testing if laptop-mode is installed, and then applying parameter
getState;
checkStateChanged;
if laptop-mode is installed :
laptop-mode auto
if ac
loop on the script .../ac.d
elseif battery
loop on the script .../battery.d
end
else : laptop mode isn't installed : power.sh imposes the settings
if ac
ac default hdparm values
loop on the script .../ac.d
elseif battery
battery default hdparm values
loop on the script .../battery.d
end
end..
Could it be right ? Does somebody knows how to do it safely and properly ?
See also (to be continued..)
https:/
https:/
https:/
https:/
....
Tormod Volden (tormodvolden) wrote : | #6 |
Yes, this is horribly broken in Ubuntu 8.04. I guess it would help if power.sh does its settings _before_ it calls laptop_mode, so that laptop_mode's settings will prevail. Please test the patch and report whether it helps for you.
chourave (gaston72) wrote : | #7 |
Sorry Tormod, your script seems not be complete...
In fact power.sh doen't really call laptop mode, it call two functions defined at the beginning of the script: laptop_mode_enable and laptop_mode_disable
chourave (gaston72) wrote : Fixing hdparm parameter value and laptop-mode issue when switching power supply (AC/battery) | #8 |
Fixing hdparm parameter value and laptop-mode issue when switching power supply (AC/battery)
Bug feature : When plugging on and off the ac adapter the laptop-mode parameters are not taken into account.
- Even if the command "cat /proc/sys/
Consequence :
- the Load_Cycle_Count is not controled anymore by user settings (laptop-mode.conf)
- setting "ENABLE_LAPTOP_MODE = true" in "/etc/acpi/
- the setting "ENABLE_
Cause : The /etc/acpi/power.sh script is called at each power event notification (acpi event).
The hdparm parameters are overwritten by this script, which doesn't reload laptop-mode.conf settings.
Solution : Modification of power.sh : the solution 2 is the more efficient, it works for me
solution 1 :
- set the good values of hdparm -S and -B in power.sh, without any other modification
BUT : the boot values seems to be always controled by laptop-mode.conf and ENABLE_
solution 2 : see the first attachment power.sh
- "ENABLE_LAPTOP_MODE = true" call systematically laptop-mode : "/usr/sbin/
- "ENABLE_LAPTOP_MODE = false" means laptop-mode on battery and no laptop-mode on AC with the hdparm parameters are controled by power.sh. (it is OK for a laptop, but there is no way shutdown completely laptop mode)
solution 3 : not tested
If laptop-mode-tools are installed by default, the best solution could be to load laptop-mode.conf setting and to test ENABLE_
thus, "ENABLE_
1. if "ENABLE_
- by default laptop-mode is disabled on AC, and enabled on battery, using default setting present in power.sh
- if laptop-mode tools are intalled : power.sh reloads laptop-mode each time occurs an acpi event
2. if "ENABLE_
- just executing the script in /etc/acpi/ac.d or /etc/acpi/
BUT :
- I don't know if laptop-mode package is installed by default
- It would simpler to add hdparm settings in acpi-support...
- the solution 2 works well, it's enougth for me, I have no more time to do this...
Useful command : testing current hdparm setting
sudo hdparm -I /dev/sda | grep 'Advanced'
Fixing hdparm parameter value and laptop-mode issue on resume
Bug : when resuming from suspend laptop-mode.conf setting are not respected
Consequences : the same as in the previous case : laptop-mode.conf settings are not applied
Cause : nothing is done concerning laptop-mode during resume.
False solution ?? : I'm using pm-utils, and when I add SERVICES=
But, It seem to work (SERVICES=
-------------------
Real solutions :
With solution 1 and 2, you have to be carreful to the power.sh script, which has also to be modified.
With solution 3, nothing has to be done to power.sh (but see previous post...)
-------
Solution 1 : when using pm-utils, the following script can be added :
(proposed by Valentin : https:/
2. cd /usr/lib/
3. sudo gedit 99-power-
4. paste this:
#!/bin/bash
/usr/bin/
if [ "$?" -eq 0 ]; then
echo "BATTERY" > /var/lib/
/etc/acpi/power.sh ac_adapter
else
if [ "$?" -eq 1 ]; then
echo "AC" > /var/lib/
/etc/
fi
fi
5. save & close
6. sudo chmod 755 99-power-
-------------------
Solution 2 : using the default suspend of gnome (script /etc/apci/sleep.sh ?) :
Adding the same script in : /etc/acpi/resume.d/ (and maybe /etc/acpi/
-------------------
Solution 3 : using the default suspend of gnome (script /etc/apci/sleep.sh ?) :
Adding a script called (for example) "99-hdd-
/etc/acpi/start.d/
/etc/acpi/
/etc/acpi/resume.d/
which simply contains hdparm setting :
#!/bin/sh
hdparm -B 255 /dev/sda
BUT : with this solution no difference is done between AC and battery on resume (concerning hdparm setting)
-------------------
Solution 1 work fine for me combined with the power.sh script I proposed in the previous post.
Tormod Volden (tormodvolden) wrote : | #10 |
chourave, I didn't attach a new script, but a patch for it. A patch only includes the changes, and you have to apply it with:
sudo patch -i power.sh.patch /etc/apci/power.sh"
(or just hand-edit the power.ch yourself, and move "$LAPTOP_MODE start" to the bottom of the laptop_mode_enable function)
chourave (gaston72) wrote : | #11 |
ok Tormod, thank you for patching my linux knowledge !!
Your solution is simpler than mine : I have an additionnal logical condition evaluation to distinguish between the laptop-mode script and the laptop_mode_enable function
if [ x$ENABLE_
(sleep 5 && /usr/sbin/
else
(sleep 5 && laptop_
fi
But , with your patch, the hdparm settings are applied two times :
- first, the default setting :
$HDPARM -S $SPINDOWN_TIME /dev/$drive 2>/dev/null
$HDPARM -B 1 /dev/$drive 2>/dev/null
- and then, with the the call to $LAPTOP_MODE start, which use the laptop-mode.conf parameters
Tormod Volden (tormodvolden) wrote : | #12 |
Yes, they will be applied twice, but that shouldn't be a problem. If we want to have this changed in Hardy (StableReleaseU
Tormod Volden (tormodvolden) wrote : | #13 |
Never mind, it was pm-utils I had upgraded, and not acpi-support. Please also see bug #89269, I wonder if this bug is a duplicate of that one.
Tormod Volden (tormodvolden) wrote : | #14 |
Daniel Hahler, you worked on this AFAICS: Doesn't it make sense to call $LAPTOP_MODE start _after_ the hdparm settings in /etc/acpi/power.sh?
Roy Badami (roy-gnomon) wrote : | #15 |
AFAICS you should *never* call $LAPTOP_MODE start (or stop). You should always use $LAPTOP_MODE auto (which will then honour the config file preferences).
-roy
Tormod Volden (tormodvolden) wrote : | #16 |
Yes, upstream went away from using start/stop to only use "auto" some time ago. But a patch was kept in the Ubuntu version to retain the start/stop options, probably because of interactions with acpi-support. I am not sure if this patch is needed any longer. Testing would be welcome, as well as comments from for instance Matthew who I think was pretty involved in these changes.
Jason (jasonxh) wrote : | #17 |
Seems this old bug has regained a lot of attention these days. I'm just wondering why the original patch by Roy is kept back, for so long. The logic is crystal clear and It works perfectly well. And this bug still doesn't have an assignee?
Alexey Borzenkov (snaury) wrote : | #18 |
I was applying a similar patch for a while now and didn't have any problems (of course you'd have to apply my patch from bug #239419). I was going to finally report it, but found this bug. It is shocking that this wasn't fixed for 1.5 years. O.o
Oh well, if developers don't care I guess we'll have to continue to patch it ourselves.
Joss Winn (josswinn) wrote : | #19 |
Running Hardy on a Dell D430.
I've installed the laptop-mode-tools upstream deb package from the maintainer's website on his suggestion. It's seems to be widely acknowledged that good laptop power management in Ubuntu is broken.
With the upstream Debian package, things appear to be working but I'm unsure what power.sh should now look like when using laptop-mode for power management. Most people suggest commenting out/removing the hdparm commands and changing $LAPTOP_MODE to auto.
Can anyone confirm that all that is needed is:
function laptop_mode_enable {
$LAPTOP_MODE auto
}
Thank you
Joss
Tormod Volden (tormodvolden) wrote : | #20 |
acpi-support (0.110) intrepid; urgency=low
* Let laptop-mode-tools run properly (closes LP: #250938)
- power.sh: remove laptop-mode invocations, should be handled by pm-utils
- acpi-support: remove SPINDOWN_TIME, should be controlled by laptop-mode
Changed in acpi-support: | |
status: | Confirmed → Fix Released |
Both of these issues still exist in Feisty. Is there anything blocking the supplied path being applied?