cpufreq: amd-pstate: Add guided mode control support via sysfs
authorWyes Karny <wyes.karny@amd.com>
Tue, 7 Mar 2023 11:27:39 +0000 (11:27 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 17 Mar 2023 18:06:23 +0000 (19:06 +0100)
commit3ca7bc818d8ccf399cb0366d8d9a915c04a446f9
treed9edcb41f1e25c889269789539f66538df4c709b
parent2dd6d0ebf74049256160a3d03dabbd92fe0b8599
cpufreq: amd-pstate: Add guided mode control support via sysfs

amd_pstate driver's `status` sysfs entry helps to control the driver's
mode dynamically by user. After the addition of guided mode the
combinations of mode transitions have been increased (16 combinations).
Therefore optimise the amd_pstate_update_status function by implementing
a state transition table.

There are 4 states amd_pstate supports, namely: 'disable', 'passive',
'active', and 'guided'.  The transition from any state to any other
state is possible after this change.

Sysfs interface:

To disable amd_pstate driver:
 # echo disable > /sys/devices/system/cpu/amd_pstate/status

To enable passive mode:
 # echo passive > /sys/devices/system/cpu/amd_pstate/status

To change mode to active:
 # echo active > /sys/devices/system/cpu/amd_pstate/status

To change mode to guided:
 # echo guided > /sys/devices/system/cpu/amd_pstate/status

Acked-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Wyes Karny <wyes.karny@amd.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/amd-pstate.c