xref: /linux/tools/power/cpupower/cpupower.sh (revision 9270102a00aabbe4d1bbb6890d514b01f1c42989)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (C) 2012, Sébastien Luttringer
4# Copyright (C) 2024, Francesco Poli <invernomuto@paranoici.org>
5
6ESTATUS=0
7
8# apply CPU clock frequency options
9if test -n "$FREQ"
10then
11    cpupower frequency-set -f "$FREQ" > /dev/null || ESTATUS=1
12elif test -n "${GOVERNOR}${MIN_FREQ}${MAX_FREQ}"
13then
14    cpupower frequency-set \
15      ${GOVERNOR:+ -g "$GOVERNOR"} \
16      ${MIN_FREQ:+ -d "$MIN_FREQ"} ${MAX_FREQ:+ -u "$MAX_FREQ"} \
17      > /dev/null || ESTATUS=1
18fi
19
20# apply CPU policy options
21if test -n "$PERF_BIAS"
22then
23    cpupower set -b "$PERF_BIAS" > /dev/null || ESTATUS=1
24fi
25
26# apply Energy Performance Preference
27if test -n "$EPP"
28then
29    cpupower set -e "$EPP" > /dev/null || ESTATUS=1
30fi
31
32exit $ESTATUS
33