From patchwork Mon Jul 21 07:02:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 4593531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 710A0C0514 for ; Mon, 21 Jul 2014 07:05:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30DA92009C for ; Mon, 21 Jul 2014 07:05:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1B9820107 for ; Mon, 21 Jul 2014 07:05:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X97dU-0002w1-FA; Mon, 21 Jul 2014 07:03:48 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X97dQ-0002kv-FE for linux-arm-kernel@lists.infradead.org; Mon, 21 Jul 2014 07:03:45 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N9100LFPVLIUM70@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 21 Jul 2014 16:03:18 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-1a-53ccbb36fe42 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 23.78.04943.63BBCC35; Mon, 21 Jul 2014 16:03:18 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N91008ZAVKDOGC0@mmp1.samsung.com>; Mon, 21 Jul 2014 16:03:18 +0900 (KST) From: Lukasz Majewski To: Viresh Kumar , "Rafael J. Wysocki" Subject: [PATCH v2] cpufreq: tests: Providing cpufreq regression test Date: Mon, 21 Jul 2014 09:02:34 +0200 Message-id: <1405926154-27214-1-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1405678985-21677-1-git-send-email-l.majewski@samsung.com> References: <1405678985-21677-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrELMWRmVeSWpSXmKPExsVy+t9jAV2z3WeCDc4sErF42vSD3eLNI26L Nw83M1psenyN1eJz7xFGixnn9zFZnDl9idWi5es5Fov1M16zWGyesJHNomMZo8XGrx4OPB47 Z91l97hzbQ+bx+Yl9R7rpr1l9thytZ3Fo2/LKkaPz5vkAtijuGxSUnMyy1KL9O0SuDIO/vzO VHDUsGLV+tvsDYyrNboYOTkkBEwkzs7vY4KwxSQu3FvP1sXIxSEksIhRYsqTu0wQTheTxKO/ K8Cq2AT0JD7ffQpmiwiEShyd+pUdxGYW+MEsselUNogtLOAq8ebfdzYQm0VAVeJ07zVWEJtX wE3iUcdVdohtihLdzyaA1XAKuEs0NPxn6WLkAFrmJrGpx2gCI+8CRoZVjKKpBckFxUnpuYZ6 xYm5xaV56XrJ+bmbGMEh+UxqB+PKBotDjAIcjEo8vB6MZ4KFWBPLiitzDzFKcDArifCeyAAK 8aYkVlalFuXHF5XmpBYfYpTmYFES5z3Qah0oJJCeWJKanZpakFoEk2Xi4JRqYPSXe7He4OPJ bPGZd1jU+NjOX1fnnL9pyUfT/3stqhYkLL9ufInD1jYpezrv8ezHM94JeJ/bpBbw6eyVuKeL ub66R72uVd9sEztht5fbw8dmrv2MxxSYOjLKzi97n34neY1Z9VyVo8WPFacwzv/C83NN3Nv2 tHUP2nL7PDwPKSvtf39GfA/zezElluKMREMt5qLiRAD3aStqRQIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140721_000344_754339_4CA609F2 X-CRM114-Status: GOOD ( 15.47 ) X-Spam-Score: -5.0 (-----) Cc: Lukasz Majewski , "linux-samsung-soc@vger.kernel.org" , Thomas Abraham , Linux PM list , Lukasz Majewski , "cpufreq@vger.kernel.org" , "thomas.ab@samsung.com" , Sachin Kamat , Tomasz Figa , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit adds first regression test "cpufreq_freq_test.sh" for the cpufreq subsystem. Signed-off-by: Lukasz Majewski --- Changes for v2: - Replace *_PATCH with *_PATH for variables names - Corrected mistakes in the README file - Providing detailed explanation of the patch in the README file --- drivers/cpufreq/tests/README | 33 +++++++ drivers/cpufreq/tests/cpufreq_freq_test.sh | 149 +++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 drivers/cpufreq/tests/README create mode 100755 drivers/cpufreq/tests/cpufreq_freq_test.sh diff --git a/drivers/cpufreq/tests/README b/drivers/cpufreq/tests/README new file mode 100644 index 0000000..3e9cd80 --- /dev/null +++ b/drivers/cpufreq/tests/README @@ -0,0 +1,33 @@ +This file contains list of cpufreq's available regression tests with a short +usage description. + +1. cpufreq_freq_test.sh + +Description: +------------ +This script is supposed to test if cpufreq attributes exported by sysfs are +exposing correct values. + +To achieve this goal it saves the current governor and changes it to +"performance". Afterwards, it reads the "scaling_available_frequencies" +property. With the list of supported frequencies it is able to enforce each of +them by writing to "scaling_max_freq" attribute. To make the test more reliable +a superfluous load with gzip is created to be sure that we are running with +highest possible frequency. This high load is regulated with the 'sleep' +duration. After this time the "cpufreq_cur_freq" is read and compared with the +original value. As the last step the original governor is restored. + +This script can work with or without BOOST enabled and helps in spotting errors +related to cpufreq and common clock framework. + +Used attributes: +---------------- +- "scaling_available_frequencies" +- "cpuinfo_cur_freq" +- "scaling_governor" +- "scaling_max_freq" + +Target devices: +--------------- + +All devices which exports mentioned above sysfs attributes. \ No newline at end of file diff --git a/drivers/cpufreq/tests/cpufreq_freq_test.sh b/drivers/cpufreq/tests/cpufreq_freq_test.sh new file mode 100755 index 0000000..c25f05c --- /dev/null +++ b/drivers/cpufreq/tests/cpufreq_freq_test.sh @@ -0,0 +1,149 @@ +#!/bin/bash +# +# This file provides a simple mean to test if all declared freqs at +# "scaling_available_frequencies" can be set and if "cpuinfo_cur_freq" +# returns this value. +# +# Usage: ./cpufreq_freq_test.sh +# Requisite: Compiled in "performance" governor +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you can access it online at +# http://www.gnu.org/licenses/gpl-2.0.html. +# +# Copyright (C) Samsung Electronics, 2014 +# +# Author: Lukasz Majewski + +set +x + +COLOUR_RED="\33[31m" +COLOUR_BLUE="\33[34m" +COLOUR_GREEN="\33[32m" +COLOUR_DEFAULT="\33[0m" + +T_PATH=/sys/devices/system/cpu/cpu0/cpufreq +BOOST_PATH=/sys/devices/system/cpu/cpufreq + +if [ ! -d "$T_PATH" ]; then + printf " $COLOUR_RED No path to CPUFREQ $COLOUR_DEFAULT\n" + exit 1 +fi + +ERRORS=0 + +OLD_GOV=`cat $T_PATH/scaling_governor` +echo "CURRENT GOVERNOR: $OLD_GOV" +echo "SET GOVERNOR: performance" +echo "performance" > $T_PATH/scaling_governor + +function test_freqs1 { + FREQS=`cat $1` + for I in $FREQS; do + cpufreq_set_freq $I + if [ "$2" ]; then + printf "$COLOUR_BLUE BOOST $COLOUR_DEFAULT" $I + fi + cpufreq_test_freq $I + done +} + +function test_freqs2 { + FREQ=`cat $1` + FREQS_ARRAY=($FREQ) + + for freq in ${FREQS_ARRAY[@]} + do + echo "REFERENCE FREQ: $freq" + for f in ${FREQS_ARRAY[@]} + do + cpufreq_set_freq $freq + echo -n "----> " + cpufreq_set_freq $f + cpufreq_test_freq $f + done + done +} + +function restore { + if [ -f $BOOST_PATH/boost ]; then + cpufreq_boost_state $BOOST_STATE + fi + + echo "SET GOVERNOR: $OLD_GOV" + echo $OLD_GOV > $T_PATH/scaling_governor +} + +function die { + printf " $COLOUR_RED FAILED $COLOUR_DEFAULT\n" + restore_gov + exit 1 +} + +function cpufreq_test_freq { + gzip < /dev/urandom > /dev/null & + pid=$! + sleep 0.1 + CURR_FREQ=`cat $T_PATH/cpuinfo_cur_freq` + if [ $1 -eq $CURR_FREQ ]; then + printf "\t$COLOUR_GREEN OK $COLOUR_DEFAULT\n" + else + printf "$COLOUR_RED CURRENT $CURR_FREQ $COLOUR_DEFAULT\n" + ERRORS=`expr $ERRORS + 1` + #die + fi + kill -9 $pid + wait $! 2>/dev/null +} + +function cpufreq_set_freq { + echo $1 > $T_PATH/scaling_max_freq || die $? + printf "FREQ:$COLOUR_GREEN %s $COLOUR_DEFAULT" $1 +} + +function cpufreq_boost_state { + echo $1 > $BOOST_PATH/boost +} + +function cpufreq_boost_status { + cat $BOOST_PATH/boost +} + +if [ -f $BOOST_PATH/boost ]; then + echo "######################################" + echo "TEST BOOST OPERATION" + echo "######################################" + + BOOST_STATE=$(cpufreq_boost_status) + if [ $BOOST_STATE -eq 0 ]; then + cpufreq_boost_state 1 + fi + test_freqs1 $T_PATH/scaling_boost_frequencies 1 +fi + +echo "######################################" +echo "TEST AVAILABLE FREQS" +echo "######################################" +test_freqs1 $T_PATH/scaling_available_frequencies + +echo "######################################" +echo "TEST FREQS SWITCHING" +echo "######################################" +test_freqs2 $T_PATH/scaling_available_frequencies + +echo "######################################" +echo "ERRORS: $ERRORS" +echo "######################################" + +restore +exit 0