1cb93a386Sopenharmony_ci# Copyright 2016 Google Inc. 2cb93a386Sopenharmony_ci# 3cb93a386Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 4cb93a386Sopenharmony_ci# found in the LICENSE file. 5cb93a386Sopenharmony_ci 6cb93a386Sopenharmony_cifrom _hardware import HardwareException, Expectation 7cb93a386Sopenharmony_cifrom _hardware_android import HardwareAndroid 8cb93a386Sopenharmony_ci 9cb93a386Sopenharmony_ciCPU_CLOCK_RATE = 1728000 10cb93a386Sopenharmony_ciGPU_CLOCK_RATE = 510000000 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ciclass HardwareNexus6P(HardwareAndroid): 13cb93a386Sopenharmony_ci def __init__(self, adb): 14cb93a386Sopenharmony_ci HardwareAndroid.__init__(self, adb) 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_ci def __enter__(self): 17cb93a386Sopenharmony_ci HardwareAndroid.__enter__(self) 18cb93a386Sopenharmony_ci if not self._adb.is_root(): 19cb93a386Sopenharmony_ci return self 20cb93a386Sopenharmony_ci 21cb93a386Sopenharmony_ci # enable and lock 3 of 4 big cores. 22cb93a386Sopenharmony_ci self._adb.shell('''\ 23cb93a386Sopenharmony_ci for N in 4 5 6; do 24cb93a386Sopenharmony_ci echo 1 > /sys/devices/system/cpu/cpu$N/online 25cb93a386Sopenharmony_ci echo userspace > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_governor 26cb93a386Sopenharmony_ci echo %i > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_max_freq 27cb93a386Sopenharmony_ci echo %i > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_min_freq 28cb93a386Sopenharmony_ci echo %i > /sys/devices/system/cpu/cpu$N/cpufreq/scaling_setspeed 29cb93a386Sopenharmony_ci done''' % tuple(CPU_CLOCK_RATE for _ in range(3))) 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ci # turn off all other cores 32cb93a386Sopenharmony_ci self._adb.shell('''\ 33cb93a386Sopenharmony_ci for N in 0 1 2 3 7; do 34cb93a386Sopenharmony_ci echo 0 > /sys/devices/system/cpu/cpu$N/online 35cb93a386Sopenharmony_ci done''') 36cb93a386Sopenharmony_ci 37cb93a386Sopenharmony_ci # gpu/ddr perf commands from 38cb93a386Sopenharmony_ci # https://developer.qualcomm.com/qfile/28823/lm80-p0436-11_adb_commands.pdf 39cb93a386Sopenharmony_ci self._adb.shell('''\ 40cb93a386Sopenharmony_ci echo 0 > /sys/class/kgsl/kgsl-3d0/bus_split 41cb93a386Sopenharmony_ci echo 1 > /sys/class/kgsl/kgsl-3d0/force_bus_on 42cb93a386Sopenharmony_ci echo 1 > /sys/class/kgsl/kgsl-3d0/force_rail_on 43cb93a386Sopenharmony_ci echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on 44cb93a386Sopenharmony_ci echo 1000000 > /sys/class/kgsl/kgsl-3d0/idle_timer 45cb93a386Sopenharmony_ci echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor 46cb93a386Sopenharmony_ci echo %i > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq 47cb93a386Sopenharmony_ci echo %i > /sys/class/kgsl/kgsl-3d0/devfreq/min_freq 48cb93a386Sopenharmony_ci echo %i > /sys/class/kgsl/kgsl-3d0/gpuclk''' % 49cb93a386Sopenharmony_ci tuple(GPU_CLOCK_RATE for _ in range(3))) 50cb93a386Sopenharmony_ci 51cb93a386Sopenharmony_ci # ddr perf commands from 52cb93a386Sopenharmony_ci # https://developer.qualcomm.com/qfile/28823/lm80-p0436-11_adb_commands.pdf 53cb93a386Sopenharmony_ci self._adb.shell('''\ 54cb93a386Sopenharmony_ci echo performance > /sys/class/devfreq/qcom,cpubw.32/governor 55cb93a386Sopenharmony_ci echo 9887 > /sys/class/devfreq/qcom,cpubw.32/max_freq 56cb93a386Sopenharmony_ci echo 9887 > /sys/class/devfreq/qcom,cpubw.32/min_freq 57cb93a386Sopenharmony_ci echo performance > /sys/class/devfreq/qcom,gpubw.70/governor 58cb93a386Sopenharmony_ci echo 9887 > /sys/class/devfreq/qcom,gpubw.70/max_freq 59cb93a386Sopenharmony_ci echo 9887 > /sys/class/devfreq/qcom,gpubw.70/min_freq''') 60cb93a386Sopenharmony_ci 61cb93a386Sopenharmony_ci return self 62cb93a386Sopenharmony_ci 63cb93a386Sopenharmony_ci def sanity_check(self): 64cb93a386Sopenharmony_ci HardwareAndroid.sanity_check(self) 65cb93a386Sopenharmony_ci 66cb93a386Sopenharmony_ci if not self._adb.is_root(): 67cb93a386Sopenharmony_ci return 68cb93a386Sopenharmony_ci 69cb93a386Sopenharmony_ci result = self._adb.check('''\ 70cb93a386Sopenharmony_ci cat /sys/class/power_supply/battery/capacity \ 71cb93a386Sopenharmony_ci /sys/devices/system/cpu/online \ 72cb93a386Sopenharmony_ci /sys/class/thermal/thermal_zone14/temp \ 73cb93a386Sopenharmony_ci /sys/class/thermal/thermal_zone15/temp \ 74cb93a386Sopenharmony_ci /sys/kernel/debug/clk/oxili_gfx3d_clk/measure \ 75cb93a386Sopenharmony_ci /sys/kernel/debug/clk/bimc_clk/measure 76cb93a386Sopenharmony_ci for N in 4 5 6; do 77cb93a386Sopenharmony_ci cat /sys/devices/system/cpu/cpu$N/cpufreq/scaling_cur_freq 78cb93a386Sopenharmony_ci done''') 79cb93a386Sopenharmony_ci 80cb93a386Sopenharmony_ci expectations = \ 81cb93a386Sopenharmony_ci [Expectation(int, min_value=30, name='battery', sleeptime=30*60), 82cb93a386Sopenharmony_ci Expectation(str, exact_value='4-6', name='online cpus'), 83cb93a386Sopenharmony_ci Expectation(int, max_value=88, name='tsens_tz_sensor13'), 84cb93a386Sopenharmony_ci Expectation(int, max_value=88, name='tsens_tz_sensor14'), 85cb93a386Sopenharmony_ci Expectation(long, min_value=(GPU_CLOCK_RATE - 5000), 86cb93a386Sopenharmony_ci max_value=(GPU_CLOCK_RATE + 5000), name='gpu clock rate'), 87cb93a386Sopenharmony_ci Expectation(long, min_value=647995000, max_value=648007500, 88cb93a386Sopenharmony_ci name='ddr clock rate', sleeptime=10)] + \ 89cb93a386Sopenharmony_ci [Expectation(int, exact_value=CPU_CLOCK_RATE, name='cpu_%i clock rate' %i) 90cb93a386Sopenharmony_ci for i in range(4, 7)] 91cb93a386Sopenharmony_ci 92cb93a386Sopenharmony_ci Expectation.check_all(expectations, result.splitlines()) 93