1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3 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 6# must be amd-pstate. 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. 13 14# Kselftest framework requirement - SKIP code is 4. 15ksft_skip=4 16 17# amd-pstate-ut only run on x86/x86_64 AMD systems. 18ARCH=$(uname -m 2>/dev/null | sed -e 's/i.86/x86/' -e 's/x86_64/x86/') 19VENDOR=$(cat /proc/cpuinfo | grep -m 1 'vendor_id' | awk '{print $NF}') 20 21if ! echo "$ARCH" | grep -q x86; then 22 echo "$0 # Skipped: Test can only run on x86 architectures." 23 exit $ksft_skip 24fi 25 26if ! 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." 29 exit $ksft_skip 30fi 31 32scaling_driver=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver) 33if [ "$scaling_driver" != "amd-pstate" ]; then 34 echo "$0 # Skipped: Test can only run on amd-pstate driver." 35 echo "$0 # Please set X86_AMD_PSTATE enabled." 36 echo "$0 # Current cpufreq scaling drvier is $scaling_driver." 37 exit $ksft_skip 38fi 39 40msg="Skip all tests:" 41if [ ! -w /dev ]; then 42 echo $msg please run this as root >&2 43 exit $ksft_skip 44fi 45 46if ! /sbin/modprobe -q -n amd-pstate-ut; then 47 echo "amd-pstate-ut: module amd-pstate-ut is not found [SKIP]" 48 exit $ksft_skip 49fi 50if /sbin/modprobe -q amd-pstate-ut; then 51 /sbin/modprobe -q -r amd-pstate-ut 52 echo "amd-pstate-ut: ok" 53else 54 echo "amd-pstate-ut: [FAIL]" 55 exit 1 56fi 57