blob: e905af4b176215a51f47861a19d1fc2d06e90f48 [file] [log] [blame]
#!/bin/sh
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This script configures link power management for sata devices. It is executed
# at boot time when a scsi controller is found.
#
# Return success if it is ok to use min_power link power management setting.
. /usr/share/misc/chromeos-common.sh
. /usr/sbin/write_gpt.sh
load_base_vars
device="$1"
drive="$(get_fixed_dst_drive)"
if [ -z "${drive}" ]; then
# Root device could not be located."
exit 0
fi
dev_sysfs="/sys/block/${drive##*/}"
dev_sysfs_full_path="/sys/block/$(readlink "${dev_sysfs}")"
link_pm_path_glob="$(echo "${dev_sysfs_full_path}" | \
sed 's|target.*|scsi_host/host*/link_power_management_policy|')"
# No "" inside, link_pm_path_glob has wildcard.
link_pm_path="$(echo ${link_pm_path_glob})"
if ! echo "${link_pm_path}" | grep -qF "${device}"; then
# Disable unused link, we don't expect hot-plug.
exit 0
elif grep -q "TS.*MTS400" "${dev_sysfs}/device/model"; then
# Transcend SSD have issues with DLPM: b:115398975
exit 1
else
exit 0
fi