You are not logged in.

#1 2012-10-05 13:57:37

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 684

[SOLVED] Resume from suspend hdparm values are wrong

Hi

I have systemd and KDE up to date. Until recent systemd 191 or 192 my laptop-mode-tools worked flawlessly. Because LMD didn't work i have created a script for /etc/pm/power.d which works great beside one annoying issue. When i wake up computer from suspend my hdparm value isn't 254 but 128 which i use when i am on battery. Now, i have tried to put a script in /etc/pm/sleep.d under resume hook to address the issue but no avail. Weird thing is that if i suspend computer with pm-suspend command there is no problem. What am i missing?

My /etc/pm/power.d script:

#!/bin/sh
# A script to enable laptop power saving features for #! & Debian GNU+linux.
# http://crunchbanglinux.org/forums/topic/11954

# List of modules to unload, space seperated. Edit depending on your hardware and preferences.
#modlist="uvcvideo"
# Bus list for runtime pm. Probably shouldn't touch this.
#buslist="pci spi i2c"

case "$1" in
    true)
    hdparm -B 128 /dev/sda
    echo 2 > /sys/class/backlight/acpi_video0/brightness
    hdparm -S 100 /dev/sda
   #echo 5 > /proc/sys/vm/laptop_mode

## ###################

        # Intel power saving
    echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
    echo 1 > /sys/module/snd_hda_intel/parameters/power_save

   # SATA power saving
    for i in /sys/class/scsi_host/host*/link_power_management_policy; do
            echo min_power > $i
        done 
    ;;
    false)
    hdparm -B 254 /dev/sda   
    echo 13 > /sys/class/backlight/acpi_video0/brightness
    hdparm -S 0 /dev/sda
   #echo 0 > /proc/sys/vm/laptop_mode

########################### iz skripte

   echo N > /sys/module/snd_hda_intel/parameters/power_save_controller
   echo 0 > /sys/module/snd_hda_intel/parameters/power_save

    for i in /sys/class/scsi_host/host*/link_power_management_policy
            do echo max_performance > $i
        done
    ;;
esac

exit 0

Nothing strange in pm-powersave.log file.

Thanks for any help

Last edited by Shark (2012-10-05 17:49:44)


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#2 2012-10-05 15:53:19

bwat47
Member
Registered: 2009-10-07
Posts: 638

Re: [SOLVED] Resume from suspend hdparm values are wrong

If you are using systemd, the latest upower update now uses systemd to suspend instead of pm-suspend, which could explain why it works with pm-suspend, but not otherwise. Try using a systemd sleep hook instead of a pm-utils one and see if it works.

On my machine I've stopped using pm-utils for power management stuff, I masked all the default scripts and disabled pm-powersave in UPpower.conf. I use a script similar to yours, but instead of using pm-utils to call it, I use a udev rule (found the idea in this thread: https://bbs.archlinux.org/viewtopic.php?id=148210&p=1)

You could easily adapt your script to that method if you wanted smile.

For example, my script: http://pastie.org/4915370
And my systemd sleep hook to make sure it applies correctly on resume: http://pastie.org/4915373

Last edited by bwat47 (2012-10-05 15:59:11)

Offline

#3 2012-10-05 16:15:28

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Resume from suspend hdparm values are wrong

Check out /usr/lib/systemd/system-sleep as anything in that directory is run before and after suspend/hibernate.  So if you check out man 8 systemd-sleep, you can easily convert the necessary pm-utils files to work with that. 

I have also come across a package in the AUR that takes care of setting advanced power management on boot and after suspend. 

https://aur.archlinux.org/packages.php?ID=63119

It works, but you will likely have to remove anything that takes care of apm that you already have set up.  Personally, I would try to create my own so that I gain a better understanding of what is going on.  But it is up to you.

Offline

#4 2012-10-05 17:14:18

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 684

Re: [SOLVED] Resume from suspend hdparm values are wrong

bwat47 wrote:

If you are using systemd, the latest upower update now uses systemd to suspend instead of pm-suspend, which could explain why it works with pm-suspend, but not otherwise. Try using a systemd sleep hook instead of a pm-utils one and see if it works.

On my machine I've stopped using pm-utils for power management stuff, I masked all the default scripts and disabled pm-powersave in UPpower.conf. I use a script similar to yours, but instead of using pm-utils to call it, I use a udev rule (found the idea in this thread: https://bbs.archlinux.org/viewtopic.php?id=148210&p=1)

You could easily adapt your script to that method if you wanted smile.

For example, my script: http://pastie.org/4915370
And my systemd sleep hook to make sure it applies correctly on resume: http://pastie.org/4915373

Hello, hello!

I followed your excellent tip to use udev rules and everything works now - even my hdparm value after suspend. I haven't changed any hook in systemd or masked the pm-utils scripts - how can i mask the scripts? By blaklisting the hooks? I haven't changed UPower.cong either because everything works. Is it OK that i have named my udev rules with the number 50_power.rules or should i change to another number?
Thanks a lot. You saved my day!  smile

Ouh - and thanks for the script. I am using it right now smile

@Wonderwuffy
Thanks for your help too, didn't know for the scripts i will dive into it if there is any other good scripts too smile


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#5 2012-10-05 17:38:16

bwat47
Member
Registered: 2009-10-07
Posts: 638

Re: [SOLVED] Resume from suspend hdparm values are wrong

Shark wrote:
bwat47 wrote:

If you are using systemd, the latest upower update now uses systemd to suspend instead of pm-suspend, which could explain why it works with pm-suspend, but not otherwise. Try using a systemd sleep hook instead of a pm-utils one and see if it works.

On my machine I've stopped using pm-utils for power management stuff, I masked all the default scripts and disabled pm-powersave in UPpower.conf. I use a script similar to yours, but instead of using pm-utils to call it, I use a udev rule (found the idea in this thread: https://bbs.archlinux.org/viewtopic.php?id=148210&p=1)

You could easily adapt your script to that method if you wanted smile.

For example, my script: http://pastie.org/4915370
And my systemd sleep hook to make sure it applies correctly on resume: http://pastie.org/4915373

Hello, hello!

I followed your excellent tip to use udev rules and everything works now - even my hdparm value after suspend. I haven't changed any hook in systemd or masked the pm-utils scripts - how can i mask the scripts? By blaklisting the hooks? I haven't changed UPower.cong either because everything works. Is it OK that i have named my udev rules with the number 50_power.rules or should i change to another number?
Thanks a lot. You saved my day!  smile

Ouh - and thanks for the script. I am using it right now smile

@Wonderwuffy
Thanks for your help too, didn't know for the scripts i will dive into it if there is any other good scripts too smile

pm-utils has some powersave scripts that run by default in /usr/lib/pm-utils/power.d. They can potentially cause issues if you are using something other than pm-utils for these things, so I like to blacklist them (as is described on the wiki, create dummy files with the same names as those scripts in /etc/pm/power.d). Disabling the run pm-powersave option in UPower.conf removes the need to mask the scripts (Because they won't be called in the first place with that disabled), but the UPower.conf file can be overwritten on updates and I just like to be on the safe side smile

And yeah, 50_power.rules should be fine.

Last edited by bwat47 (2012-10-05 17:41:14)

Offline

#6 2012-10-05 17:42:49

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 684

Re: [SOLVED] Resume from suspend hdparm values are wrong

Ok. Thanks for the info. I will do dummy file. You were of great help!
Bye


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#7 2013-01-01 10:28:45

6xx
Package Maintainer (PM)
Registered: 2006-11-26
Posts: 22
Website

Re: [SOLVED] Resume from suspend hdparm values are wrong

Hey guys, this seems to be a systemd problem. I've reported it as a FS#33262, because it is cleanly a bug, suspend/wakeup cycle shouldn't change any settings. Feel free to post any additional information you have to the bug report.

Offline

#8 2013-01-01 12:11:13

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [SOLVED] Resume from suspend hdparm values are wrong

6xx wrote:

Hey guys, this seems to be a systemd problem. I've reported it as a FS#33262, because it is cleanly a bug, suspend/wakeup cycle shouldn't change any settings. Feel free to post any additional information you have to the bug report.

It's not as clear cut as you put it, when you suspend or hibernate you cut power to the hard disk. When you wake up the computer again, to the hard disk it's as if you are doing a cold boot so it loads all the defaults from its firmware.

Systemd, or anything else for that matter, has no business in changing that automatically behind the user's back. I wouldn't call it a bug since systemd had nothing to do in changing the apm setting.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#9 2013-03-09 10:46:52

renegat
Member
From: Europe
Registered: 2012-12-28
Posts: 88

Re: [SOLVED] Resume from suspend hdparm values are wrong

I got it...

Last edited by renegat (2013-03-09 12:22:15)

Offline

Board footer

Powered by FluxBB