2 # SPDX-License-Identifier: GPL-2.0
4 # amd-pstate-ut is a test module for testing the amd-pstate driver.
5 # It can only run on x86 architectures and current cpufreq driver
7 # (1) It can help all users to verify their processor support
8 # (SBIOS/Firmware or Hardware).
9 # (2) Kernel can have a basic function test to avoid the kernel
10 # regression during the update.
11 # (3) We can introduce more functional or performance tests to align
12 # the result together, it will benefit power and performance scale optimization.
14 # Kselftest framework requirement - SKIP code is 4.
17 # amd-pstate-ut only run on x86/x86_64 AMD systems.
18 ARCH=$(uname -m 2>/dev/null | sed -e 's/i.86/x86/' -e 's/x86_64/x86/')
19 VENDOR=$(cat /proc/cpuinfo | grep -m 1 'vendor_id' | awk '{print $NF}')
21 if ! echo "$ARCH" | grep -q x86; then
22 echo "$0 # Skipped: Test can only run on x86 architectures."
26 if ! echo "$VENDOR" | grep -iq amd; then
27 echo "$0 # Skipped: Test can only run on AMD CPU."
28 echo "$0 # Current cpu vendor is $VENDOR."
32 scaling_driver=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver)
33 if [ "$scaling_driver" != "amd-pstate" ]; then
34 echo "$0 # Skipped: Test can only run on amd-pstate driver."
35 echo "$0 # Current cpufreq scaling drvier is $scaling_driver."
40 if [ ! -w /dev ]; then
41 echo $msg please run this as root >&2
45 if ! /sbin/modprobe -q -n amd-pstate-ut; then
46 echo "amd-pstate-ut: module amd-pstate-ut is not found [SKIP]"
49 if /sbin/modprobe -q amd-pstate-ut; then
50 /sbin/modprobe -q -r amd-pstate-ut
51 echo "amd-pstate-ut: ok"
53 echo "amd-pstate-ut: [FAIL]"