Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bugzilla DB migration completed. Please report issues to Infra team via email via infra@gentoo.org or IRC
Bug 362387 - sys-power/pm-utils: hdparm settings overwritten by pm-utils when switching to BATTERY
Summary: sys-power/pm-utils: hdparm settings overwritten by pm-utils when switching to...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Freedesktop bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-07 04:47 UTC by Viacheslav Gagara
Modified: 2013-01-15 11:01 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge_info,4.99 KB, text/plain)
2011-04-07 04:50 UTC, Viacheslav Gagara
Details
.config (config,74.03 KB, text/plain)
2011-04-07 04:52 UTC, Viacheslav Gagara
Details
kernel config (config,67.77 KB, text/plain)
2012-04-25 08:46 UTC, Alex
Details
emerge --info (emerge--info,4.37 KB, text/plain)
2012-04-25 08:54 UTC, Alex
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Viacheslav Gagara 2011-04-07 04:47:59 UTC
hdparm settings configured in laptop-mode being overwritten by some kernel api (almost) every time when switching to BATTERY state and never become actual.
kernel 2.6.38-r1  

Reproducible: Sometimes

Steps to Reproduce:
1. configure laptop-mode (/etc/laptop-mode/laptop-mode.conf):
ENABLE_LAPTOP_MODE_TOOLS=1
VERBOSE_OUTPUT=1
ENABLE_LAPTOP_MODE_ON_BATTERY=1
CONTROL_HD_POWERMGMT="auto"
BATT_HD_POWERMGMT=128

2. check current hdparm settings:
hdparm -B /dev/sda

/dev/sda:
 APM_level      = 254

3. unplug AC (switch to battery)
Actual Results:  
# hdparm -B /dev/sda

/dev/sda:
 APM_level      = 1


Expected Results:  
# hdparm -B /dev/sda

/dev/sda:
 APM_level      = 128


tail -f /var/log/messages

Apr  7 07:23:37 localhost logger: ACPI event unhandled: ac_adapter AC 00000080 00000000
Apr  7 07:23:37 localhost laptop-mode: Determining power state from /sys/class/power_supply/AC/online.
Apr  7 07:23:37 localhost laptop-mode: Not trying other options, already found a power supply.
Apr  7 07:23:37 localhost laptop-mode: On battery power: Activating, because ENABLE_LAPTOP_MODE_ON_BATTERY is set.
.........................................................
........................................................
Apr  7 07:23:39 localhost laptop-mode: Invoking module /usr/share/laptop-mode-tools/modules/hdparm.
Apr  7 07:23:39 localhost laptop-mode: Setting powermanagement on drives to 128.
Apr  7 07:23:39 localhost laptop-mode: Querying /dev/sda media type using udevinfo: 
Apr  7 07:23:39 localhost laptop-mode: type 'disk' on bus 'ata' detected
Apr  7 07:23:39 localhost laptop-mode: Querying /dev/sda media type using udevinfo: 
Apr  7 07:23:39 localhost laptop-mode: type 'disk' on bus 'ata' detected
Apr  7 07:23:39 localhost laptop-mode: Executing: hdparm -B 128 /dev/sda
Apr  7 07:23:39 localhost laptop-mode: 
Apr  7 07:23:39 localhost /dev/sda:
Apr  7 07:23:39 localhost setting Advanced Power Management level to 0x80 (128)
Apr  7 07:23:39 localhost APM_level     = 128
............................................
............................................
Apr  7 07:23:41 localhost kernel: ata1.00: configured for UDMA/133                                                                                
Apr  7 07:23:41 localhost kernel: ata1: EH complete                                                                                               
Apr  7 07:23:41 localhost kernel: sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
...........................................


===================================================================================

Quick & dirty FIX which actually works for me is to add sleep in laptop-mode exec-command.conf in order to give kernel to do its work first:
/etc/laptop-mode/conf.d/exec-commands.conf:
BATT_EXEC_COMMAND_0="sleep 3" # Enable power saving feature 0 here
enable modules in main config:
ENABLE_AUTO_MODULES=1

In this case:
pr  7 07:36:15 localhost logger: ACPI event unhandled: ac_adapter AC 00000080 00000000                                      
Apr  7 07:36:15 localhost laptop-mode: Determining power state from /sys/class/power_supply/AC/online.                                            
Apr  7 07:36:15 localhost laptop-mode: Not trying other options, already found a power supply.                                                    
Apr  7 07:36:15 localhost laptop-mode: On battery power: Activating, because ENABLE_LAPTOP_MODE_ON_BATTERY is set.                                
.................................................
..................................................
Apr  7 07:36:16 localhost laptop-mode: Invoking module /usr/share/laptop-mode-tools/modules/exec-commands.                                        
Apr  7 07:36:16 localhost laptop-mode: Executing comand sleep 3                                                                                   
Apr  7 07:36:16 localhost kernel: ata1.00: configured for UDMA/133                                                                                
Apr  7 07:36:16 localhost kernel: ata1: EH complete                                                                                               
Apr  7 07:36:16 localhost kernel: sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA                        
Apr  7 07:36:17 localhost kernel: sd 2:0:0:0: [sdb] No Caching mode page present                                                                  
Apr  7 07:36:17 localhost kernel: sd 2:0:0:0: [sdb] Assuming drive cache: write through                                                           
....................................................
....................................................
Apr  7 07:36:19 localhost laptop-mode: Invoking module /usr/share/laptop-mode-tools/modules/hdparm.                                               
Apr  7 07:36:19 localhost laptop-mode: Setting powermanagement on drives to 128.                                                                  
Apr  7 07:36:19 localhost laptop-mode: Querying /dev/sda media type using udevinfo:                                                               
Apr  7 07:36:19 localhost laptop-mode: type 'disk' on bus 'ata' detected                                                                          
Apr  7 07:36:19 localhost laptop-mode: Querying /dev/sda media type using udevinfo:                                                               
Apr  7 07:36:19 localhost laptop-mode: type 'disk' on bus 'ata' detected                                                                          
Apr  7 07:36:19 localhost laptop-mode: Executing: hdparm -B 128 /dev/sda                                                                          
Apr  7 07:36:19 localhost laptop-mode:                                                                                                            
Apr  7 07:36:19 localhost /dev/sda:                                                                                                               
Apr  7 07:36:19 localhost setting Advanced Power Management level to 0x80 (128)                                                                   
Apr  7 07:36:19 localhost APM_level     = 128                                             
.......................................................

Hope there is more reliable solution.
Comment 1 Viacheslav Gagara 2011-04-07 04:50:56 UTC
Created attachment 268803 [details]
emerge --info
Comment 2 Viacheslav Gagara 2011-04-07 04:52:56 UTC
Created attachment 268805 [details]
.config

Linux/x86_64 2.6.38-gentoo-r1 Kernel Configuration
Comment 3 Alex 2012-04-25 08:46:29 UTC
Created attachment 309997 [details]
kernel config
Comment 4 Alex 2012-04-25 08:54:11 UTC
Created attachment 309999 [details]
emerge --info

I had the same problem.
Thank Viacheslav Gagara. Your solution works.
Comment 5 Alex 2012-05-06 16:18:07 UTC
Your solution works when the notebook is turned on and connect/disconnect the power cord. But when the laptop is switched on without the power cord (battery mode), this solution does not work.
Another solution is to disable the kernel option "ATA_ACPI" (Device Drivers -> SATA PATA Drivers -> ATA ACPI Support) or add a boot option to the kernel "libata.noacpi=1".
I added a boot option to the kernel. It works for me.
Comment 6 Alex 2012-05-06 17:57:55 UTC
(In reply to comment #5)
> Your solution works when the notebook is turned on and connect/disconnect
> the power cord. But when the laptop is switched on without the power cord
> (battery mode), this solution does not work.
> Another solution is to disable the kernel option "ATA_ACPI" (Device Drivers
> -> SATA PATA Drivers -> ATA ACPI Support) or add a boot option to the kernel
> "libata.noacpi=1".
> I added a boot option to the kernel. It works for me.

Sorry, it is not work.
Comment 7 Alex 2012-05-10 14:35:59 UTC
Probably not kernel rewrites settings. I think it makes pm-utils. I looked to /usr/lib/pm-utils/power.d/harddrive and rewrite two options to the following form:
DRIVE_SPINDOWN_VALUE_BAT="${DRIVE_SPINDOWN_VALUE_BAT:-0}"
DRIVE_POWER_MGMT_BAT="${DRIVE_POWER_MGMT_BAT:-254}"
For me it works.
Comment 8 Pacho Ramos gentoo-dev 2012-11-18 13:44:48 UTC
(In reply to comment #7)
> Probably not kernel rewrites settings. I think it makes pm-utils. I looked
> to /usr/lib/pm-utils/power.d/harddrive and rewrite two options to the
> following form:
> DRIVE_SPINDOWN_VALUE_BAT="${DRIVE_SPINDOWN_VALUE_BAT:-0}"
> DRIVE_POWER_MGMT_BAT="${DRIVE_POWER_MGMT_BAT:-254}"
> For me it works.

Not sure if both as supposed to work together
Comment 9 Alex 2012-11-18 17:05:43 UTC
(In reply to comment #8)
> Not sure if both as supposed to work together
These options work for me for six months. And I do not use 'laptop-mode-tools'.