OPNsense Forum

English Forums => Development and Code Review => Topic started by: Werner Fischer on June 22, 2023, 11:18:08 am

Title: Support SATA Link Power Management - savings of ~1 watt
Post by: Werner Fischer on June 22, 2023, 11:18:08 am
I happened to notice that FreeBSD has SATA Link Power Management disabled by default.

This is also the case with the Linux vanilla Kernel so far. However, numerous Linux distributions (e.g. Ubuntu as of Linux kernel 5.15) enable this for mobile/embedded chipsets using "SATA_LPM_POLICY=3".

For the upstream Linux kernel "SATA_LPM_POLICY=3" was also already under discussion: https://www.spinics.net/lists/linux-ide/msg62918.html Due to a hot-plug problem with AMD-based systems (there the SATA controller is identical for EPYC and Ryzen - thus it can't be determined via the PCIe IDs of the SATA controller whether it is a mobile/embedded chipset) this has not been implemented yet.

What are the advantages of enabled SATA Link Power Management?


What are the disadvantages of enabled SATA Link Power Management?

Under FreeBSD there are several SATA link power management options available - see https://man.freebsd.org/cgi/man.cgi?ahci(4)

However, a combination of DIPM+HIPM would be ideal. This would achieve the highest energy savings. Linux has offered this since kernel 4.15 - see https://hansdegoede.livejournal.com/18412.html and https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f4ac6476945ff62939420bcf8266e39f8d5d54bd. This emulates the functionality of the Intel RST driver from Windows, which is explained in detail in this PDF: https://www-ssl.intel.com/content/dam/doc/reference-guide/sata-devices-implementation-recommendations.pdf. In the mid and long term, it would be ideal to implement this functionality (combination of DIPM+HIPM) in FreeBSD as well. However, this is beyond my qualifications. For now, it would already bring a lot to support DIPM.

Currently it is possible to enable DIPM for a SSD via Tuneable: hint.ahcich.0.pm_level = 1 (Attention: a system can have multiple SATA ports - if in doubt set the value for all of them). I have documented all details about this: https://www.thomas-krenn.com/en/wiki/Activate_SATA_Link_Power_Management_in_OPNsense

My questions to you in the OPNsense development:

What do you think?
Best regards, Werner
Title: Re: Support SATA Link Power Management - savings of ~1 watt
Post by: Werner Fischer on July 18, 2023, 08:20:16 am
Franco has changed "unsupported" to "environment"
https://github.com/opnsense/core/commit/b1e270957c800

Thank you for this Franco :)
Title: Re: Support SATA Link Power Management - savings of ~1 watt
Post by: thatso on August 19, 2023, 01:56:00 am
Sorry to ask: is this option already implemented?
I'm on OPNsense 23.7.1_3-amd64 and don't see it in tunables. The linked TK wiki article reads as if it was introduced in 23.1.9. What gives?
Title: Re: Support SATA Link Power Management - savings of ~1 watt
Post by: thatso on September 15, 2023, 06:28:00 pm
Any updates on this?
Title: Re: Support SATA Link Power Management - savings of ~1 watt
Post by: Patrick M. Hausen on September 15, 2023, 08:26:05 pm
Just add the tunable if you so desire, it does not need to be predefined by OPNsense. There's a small (+) in the UI.
Title: Re: Support SATA Link Power Management - savings of ~1 watt
Post by: thatso on September 16, 2023, 12:16:23 am
Thanks, I know that tunables can be added manually. However, https://www.thomas-krenn.com/en/wiki/Activate_SATA_Link_Power_Management_in_OPNsense (https://www.thomas-krenn.com/en/wiki/Activate_SATA_Link_Power_Management_in_OPNsense) reads as if this entry should be available as predefined. I was hoping @Werner Fischer could clarify this.
Title: Re: Support SATA Link Power Management - savings of ~1 watt
Post by: Patrick M. Hausen on September 16, 2023, 08:13:00 am
"A new tunable can be set" == you create a new tunable.
Title: Re: Support SATA Link Power Management - savings of ~1 watt
Post by: thatso on September 18, 2023, 03:41:42 pm
"A new tunable can be set" == you create a new tunable.

I see. That's one way to read it. As said, I had the impression it should be predefined. ;)
Thanks for clarification.