One more attempt at SATA power management
Apr. 17th, 2016 07:05 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Around a year ago I wrote some patches in an attempt to improve power management on Haswell and Broadwell systems by configuring Serial ATA power management appropriately. I got a couple of reports of them triggering SATA errors for some users, couldn't reproduce them myself and so didn't have a lot of confidence in them. Time passed.
I've been working on power management stuff again this week, so it seemed like a good opportunity to revisit these. I've made a few changes and pushed a couple of trees - one against master and one against 4.5.
First, these probably only have relevance to users of mobile Intel parts in the U or S range (/proc/cpuinfo will tell you - you're looking for a four-digit number that starts with 4 (Haswell), 5 (Broadwell) or 6 (Skylake) and ends with U or S), and won't do anything unless you have SATA drives (including PCI-based SATA). To test them, first disable anything like TLP that might alter your SATA link power management policy. Then check powertop - you should only be getting to PC3 at best. Build a kernel with these patches and boot it. /sys/class/scsi_host/*/link_power_management_policy should read "firmware". Check powertop and see whether you're getting into deeper PC states. Now run your system for a while and check the kernel log for any SATA errors that you didn't see before.
Let me know if you see SATA errors and are willing to help debug this, and leave a comment if you don't see any improvement in PC states.
I've been working on power management stuff again this week, so it seemed like a good opportunity to revisit these. I've made a few changes and pushed a couple of trees - one against master and one against 4.5.
First, these probably only have relevance to users of mobile Intel parts in the U or S range (/proc/cpuinfo will tell you - you're looking for a four-digit number that starts with 4 (Haswell), 5 (Broadwell) or 6 (Skylake) and ends with U or S), and won't do anything unless you have SATA drives (including PCI-based SATA). To test them, first disable anything like TLP that might alter your SATA link power management policy. Then check powertop - you should only be getting to PC3 at best. Build a kernel with these patches and boot it. /sys/class/scsi_host/*/link_power_management_policy should read "firmware". Check powertop and see whether you're getting into deeper PC states. Now run your system for a while and check the kernel log for any SATA errors that you didn't see before.
Let me know if you see SATA errors and are willing to help debug this, and leave a comment if you don't see any improvement in PC states.
Awesome!
Date: 2016-04-18 04:01 am (UTC)Re: Awesome!
Date: 2016-04-18 05:15 am (UTC)just tried...
Date: 2016-04-18 10:10 am (UTC)- cat /sys/class/scsi_host/*/link_power_management_policy
firmware
firmware
firmware
firmware
- powertop indicates non-zero values only for pc2 and pc3.
Last patch might want to be more restrictive
Date: 2016-04-18 11:01 am (UTC)IMHO that patch is bound to cause issues on desktops and servers like my supermicro board, which are not sold as a complete system with storage. You can barely trust the firmware to keep things together... hopefully it defaults to alpm disabled, but I wouldn´t trust it that much: these boards never have up-to-date firmware components, from microcode to option ROMs.
SATA ALPM is not going to be nearly as important in non-mobile parts, or on older mobile parts. There is no reason to risk data loss by a *default* configuration change there...
the other patches in the series look good.
T440p
Date: 2016-04-18 11:07 am (UTC)Is your patch appropriate for M-series of mobile Haswell processors, like i5-4300M?
I succeeded in achieving pc7 on my T440p with i5-4300M by booting with i915.enable_psr=1 (which is going to be enabled by default in 4.6 kernel anyways) and setting link_power_management_policy to min_power. But currently video driver is unstable in this configuration: https://bugs.freedesktop.org/show_bug.cgi?id=94985
Re: T440p
Date: 2016-04-18 02:48 pm (UTC)Try to disable yout internal screen with arandr or xrandr.
Btw. even with no external screen connected I still get occasional short flicker on my laptop screen (ips) with psr enabled but only when idle. At least my system goes into its lowest possible pc7 state for hightly changing 10 or 20% :(
Re: T440p
From: (Anonymous) - Date: 2016-04-18 03:45 pm (UTC) - ExpandRe: T440p
From: (Anonymous) - Date: 2016-04-18 03:53 pm (UTC) - Expandno subject
Date: 2016-04-18 02:44 pm (UTC)no subject
Date: 2016-04-18 04:06 pm (UTC)Regarding HKEY patch
Date: 2016-04-18 07:32 pm (UTC)Thank you!
Re: Regarding HKEY patch
Date: 2016-04-18 08:46 pm (UTC)Re: Regarding HKEY patch
From: (Anonymous) - Date: 2016-04-18 10:22 pm (UTC) - ExpandRe: Regarding HKEY patch
From:Firmware mode doesn't help
Date: 2016-04-18 07:53 pm (UTC)Haven't seen SATA errors with the new medium_power mode, but those aren't easy to trigger (I definitely get errors once in a while using min_power, most of the time /dev/sda falling of the bus).
no subject
Date: 2016-04-18 08:01 pm (UTC)Thinkpad T540p i7-4700MQ didn't show any improvement
Date: 2016-04-19 07:25 am (UTC)I reconfigured tlp to use medium_power policy for SATA and started the daemon. The power consumption returned to my usual 14W. I see my usual 70% PC2 and 15% PC3 states.
I could see no change whatsoever, but I'm willing to help with debugging.
I see no SATA errors at all in my journal.
Re: Thinkpad T540p i7-4700MQ didn't show any improvement
Date: 2016-04-19 08:21 am (UTC)Re: Thinkpad T540p i7-4700MQ didn't show any improvement
From: (Anonymous) - Date: 2016-04-19 11:42 am (UTC) - ExpandRe: Thinkpad T540p i7-4700MQ didn't show any improvement
From: (Anonymous) - Date: 2016-04-19 01:44 pm (UTC) - ExpandRe: Thinkpad T540p i7-4700MQ didn't show any improvement
From: (Anonymous) - Date: 2016-04-19 02:07 pm (UTC) - ExpandNo deep C-states on 4.6-git
Date: 2016-04-19 12:32 pm (UTC)On 4.5 though, "firmware" does get C6. I personally haven't seen any SATA errors either before or now, even on min_power.
Re: No deep C-states on 4.6-git
Date: 2016-04-19 12:40 pm (UTC)https://bugzilla.kernel.org/show_bug.cgi?id=115771#c106
Re: No deep C-states on 4.6-git
From: (Anonymous) - Date: 2016-04-19 11:19 pm (UTC) - ExpandRe: No deep C-states on 4.6-git
From: (Anonymous) - Date: 2016-04-20 03:30 am (UTC) - ExpandRe: No deep C-states on 4.6-git
From:Re: No deep C-states on 4.6-git
From: (Anonymous) - Date: 2016-04-20 11:24 am (UTC) - ExpandLenovo T550 - i5-5200U
Date: 2016-04-19 07:18 pm (UTC)Switching to min_power allows me to reach PC7.
Maybe Lenovo is very conservative on this setting in their BIOSes?
Re: Lenovo T550 - i5-5200U
Date: 2016-04-19 07:51 pm (UTC)Re: Lenovo T550 - i5-5200U
From: (Anonymous) - Date: 2016-04-20 05:54 pm (UTC) - ExpandRe: Lenovo T550 - i5-5200U
From: (Anonymous) - Date: 2016-04-24 09:01 am (UTC) - ExpandRe: Lenovo T550 - i5-5200U
From: (Anonymous) - Date: 2016-04-24 11:32 am (UTC) - ExpandRe: Lenovo T550 - i5-5200U
From: (Anonymous) - Date: 2016-04-20 06:12 pm (UTC) - ExpandNUC results
Date: 2016-04-19 07:38 pm (UTC)Only reaching package C3
Date: 2016-04-20 07:33 pm (UTC)could you give a little advice? Haswell system here (T540p), every "experimental" power-saving knob that I know of is turned on (incl. pcie_aspm=powersave, link_power_management_policy=min_power, etc), but I'm not getting any deeper than package C3 state. Yet all cores are in C7 (as reported by powertop).
How can I detect the "offending" device?
Re: Only reaching package C3
Date: 2016-04-20 08:48 pm (UTC)Re: Only reaching package C3
From: (Anonymous) - Date: 2016-04-21 11:15 pm (UTC) - ExpandRe: Only reaching package C3
From: (Anonymous) - Date: 2016-04-21 11:34 pm (UTC) - ExpandRe: Only reaching package C3
From: (Anonymous) - Date: 2016-04-22 01:02 am (UTC) - Expandno subject
Date: 2016-04-20 11:06 pm (UTC)After booting up mjg59-4.6-rc3 my /sys/class/scsi_host/*/link_power_management_policy reads min_power. If I 'echo -n firmware | sudo tee */link_power_management_policy', it does not complain, and catting the files shows that the driver is switched.
While previously before I have been able to enter pc6, I can now only maximally enter pc2.
If I switch them back to min_power, the machine will resume going into pc6 state. This seems broken to me. I'm going to go back to my rc kernels until these issues are fixed.
Please let me know if you'd like more information, or you'd like me to pull and run additional changes.
----
bkero
no subject
Date: 2016-04-20 11:17 pm (UTC)(no subject)
From: (Anonymous) - Date: 2016-04-22 07:12 am (UTC) - Expand(no subject)
From: (Anonymous) - Date: 2016-04-28 08:30 am (UTC) - Expandno difference for me
Date: 2016-04-21 10:48 pm (UTC)One thing that drives me a bit crazy on this system is that the actual power consumption drops significantly following a suspend/resume cycle. After resume from hibernate, the best power consumption will be ~3.5-4W, but if I then do a suspend/resume, that will drop to ~2.5W. This seems to happen with or without the patches. It looks like the firmware is tweaking some knob that powertop doesn't know about. Any ideas on how to find that knob would be appreciated.
Re: no difference for me
Date: 2017-05-01 10:09 am (UTC)NVMe?
Date: 2016-04-22 01:31 am (UTC)Re: NVMe?
Date: 2016-04-22 02:27 am (UTC)Broadwell X1 Carbon
Date: 2016-04-22 01:32 pm (UTC)I've been running these patches for most of this week, and haven't seen any SATA errors in dmesg.
I've got an X1 Carbon with a i7-5600U.
I've run `powertop --auto-tune`, and when /sys/class/scsi_host/*/link_power_management_policy is set to firmware, I don't see the package drop below C2. If I set link_power_management_policy to medium_power, I do see significant time spent in C6 and (mostly) C7.
i5-6200U, no success
Date: 2016-04-25 09:37 am (UTC)I'm using LG Gram 14 with Linux 4.5.2.
Using "min_power" allowed me to enter pc3, but after the patch and echoing "firmware", it goes no higher than pc2.
:(
Lenovo X250 i7-5600U, Samsung 850 Evo
Date: 2016-04-25 11:34 am (UTC)Kernel Version Linux version 4.5.2-custom+
System Name LENOVO20CLS06D00ThinkPad X250
CPU Information 4 Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
Thanks for your effort!
Nitpick
Date: 2016-04-27 02:58 pm (UTC)http://ark.intel.com/products/codename/42174/Haswell
http://ark.intel.com/products/codename/38530/Broadwell
http://ark.intel.com/products/codename/37572/Skylake
Thank you for all your work!
PC6
Date: 2016-04-29 08:45 pm (UTC)I patched your changes into arch linux's linux-ck version package 4.5.2.
With /sys/class/scsi_host/*/link_power_management_policy = firmware I get down to PC6.
With /sys/class/scsi_host/*/link_power_management_policy = min_power I get down to PC7
nothing on t460s, i5-6200U
Date: 2016-05-30 08:36 pm (UTC)Tell me if I can test anything or if you need more infos.
Re: nothing on t460s, i5-6200U
Date: 2016-08-29 04:32 pm (UTC)Macbook Pro continuous errors
Date: 2016-09-21 02:06 am (UTC)i'm tied to using 3.16 at the moment due to having a rootfs partition that's overgrown to the point where literally nothing will fit (certainly not another linux kernel) - i have to do a total OS wipe and reformat which i'm putting off.
macbook pros are known for having continuous (once per second) errors like this:
[915140.664521] ata1: SError: { PHYRdyChg }
[915140.664524] ata1: hard resetting link
[915141.387232] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[915141.387657] ata1.00: unexpected _GTF length (8)
[915141.388159] ata1.00: unexpected _GTF length (8)
[915141.388203] ata1.00: configured for UDMA/33
[915141.388275] ata1: EH complete
[915141.488383] ata1: exception Emask 0x10 SAct 0x0 SErr 0x10000 action 0xe frozen
[915141.488388] ata1: irq_stat 0x00400000, PHY RDY changed
[915141.488390] ata1: SError: { PHYRdyChg }
[915141.488393] ata1: hard resetting link
[915142.211871] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[915142.212285] ata1.00: unexpected _GTF length (8)
[915142.212786] ata1.00: unexpected _GTF length (8)
[915142.212831] ata1.00: configured for UDMA/33
[915142.212897] ata1: EH complete
[915142.313041] ata1: exception Emask 0x10 SAct 0x0 SErr 0x10000 action 0xe frozen
[915142.313044] ata1: irq_stat 0x00400000, PHY RDY changed
[915142.313045] ata1: SError: { PHYRdyChg }
[915142.313048] ata1: hard resetting link
[915143.036521] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[915143.036921] ata1.00: unexpected _GTF length (8)
[915143.037424] ata1.00: unexpected _GTF length (8)
[915143.037507] ata1.00: configured for UDMA/33
[915143.037570] ata1: EH complete
[915250.985136] ata1.00: exception Emask 0x10 SAct 0x1e000000 SErr 0x4040000 action 0xe frozen
[915250.985140] ata1.00: irq_stat 0x80000040, connection status changed
[915250.985142] ata1: SError: { CommWake DevExch }
[915250.985145] ata1.00: failed command: WRITE FPDMA QUEUED
[915250.985150] ata1.00: cmd 61/00:c8:d0:ff:53/04:00:0b:00:00/40 tag 25 ncq 524288 out
res 40/00:c4:70:6c:52/00:00:07:00:00/40 Emask 0x10 (ATA bus error)
[915250.985152] ata1.00: status: { DRDY }
[915250.985154] ata1.00: failed command: WRITE FPDMA QUEUED
[915250.985157] ata1.00: cmd 61/00:d0:d0:03:54/04:00:0b:00:00/40 tag 26 ncq 524288 out
res 40/00:c4:70:6c:52/00:00:07:00:00/40 Emask 0x10 (ATA bus error)
[915250.985159] ata1.00: status: { DRDY }
[915250.985161] ata1.00: failed command: WRITE FPDMA QUEUED
[915250.985164] ata1.00: cmd 61/00:d8:d0:07:54/04:00:0b:00:00/40 tag 27 ncq 524288 out
res 40/00:c4:70:6c:52/00:00:07:00:00/40 Emask 0x10 (ATA bus error)
[915250.985166] ata1.00: status: { DRDY }
[915250.985167] ata1.00: failed command: WRITE FPDMA QUEUED
[915250.985170] ata1.00: cmd 61/e8:e0:d0:0b:54/03:00:0b:00:00/40 tag 28 ncq 512000 out
res 40/00:c4:70:6c:52/00:00:07:00:00/40 Emask 0x10 (ATA bus error)
[915250.985171] ata1.00: status: { DRDY }
[915250.985175] ata1: hard resetting link
[915251.709502] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
pretty soon /var/log/syslog is a couple of gigabytes in length.
this is "solved" by running:
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
*however*....
the problem is that any kind of suspend/resume, or even removal of the power cord, or insertion of the power cord, or removal of a USB device, or insertion of a USB device, or basically *anything* event-driven... results in the policy being changed without authorisation.
what i've had to do is to add a cron script which simply sets that policy to min_power literally every minute.
it's a fairly ridiculous situation.