pmaports/device/testing/device-pine64-pinebookpro/nvme-powersave.initd
Clayton Craft 55dc5819e4
pine64-pinebookpro: add service for setting low power state on boot (MR 2306)
This adds a very basic openrc runscript that sets the power state on
/dev/nvme0 to level 2, which seems(?) to be the lowest operational power
state based on some cursory internet searching (and querying the nvme
drives I have, Samsung EVO and Pro)

The drive path is hard coded, but could be made configurable later on. I
basically wanted to get something in pmaports quickly, since this power
stuff is a major source of instability for me and probably others too
who add nvme drives to this device.
2021-07-04 13:42:43 -07:00

26 lines
519 B
Text

#!/sbin/openrc-run
name="NVMe power state config"
description="Set NVMe power state to lowest operational level"
nvme_command="/usr/sbin/nvme"
nvme_opts="-f 2 -v 2"
depend() {
need localmount
}
start() {
ebegin "Setting low power state for NVMe drive"
if [ ! -e /dev/nvme0 ]; then
einfo "No NVMe drive found at /dev/nvme0"
eend 0
return 0
fi
if ! ${nvme_command} set-feature /dev/nvme0 ${nvme_opts}; then
eerror "Error setting PM state."
eend 1
return 1
fi
eend 0
}