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