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