_hardware_pixel2.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # Copyright 2018 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. from _hardware import Expectation
  6. from _hardware_android import HardwareAndroid
  7. CPU_CLOCK_RATE = 2035200
  8. MEM_CLOCK_RATE = 13763
  9. GPU_CLOCK_RATE = 670000000
  10. GPU_POWER_LEVEL = 1 # lower is faster, minimum is 0
  11. class HardwarePixel2(HardwareAndroid):
  12. def __init__(self, adb):
  13. HardwareAndroid.__init__(self, adb)
  14. def __enter__(self):
  15. HardwareAndroid.__enter__(self)
  16. if not self._adb.is_root():
  17. return self
  18. self._adb.shell('\n'.join([
  19. '''
  20. stop thermal-engine
  21. stop perfd''',
  22. # turn off the slow cores and one fast core
  23. '''
  24. for N in 0 1 2 3 7; do
  25. echo 0 > /sys/devices/system/cpu/cpu$N/online
  26. done''',
  27. # lock 3 fast cores: two for Skia and one for the OS
  28. '''
  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. # Set GPU bus and idle timer
  37. '''
  38. echo 0 > /sys/class/kgsl/kgsl-3d0/bus_split''',
  39. # csmartdalton, 4-26-2018: this line hangs my device
  40. # echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on
  41. '''
  42. echo 10000 > /sys/class/kgsl/kgsl-3d0/idle_timer''',
  43. # Set mem frequency to max
  44. '''
  45. echo %i > /sys/class/devfreq/soc\:qcom,gpubw/min_freq
  46. echo %i > /sys/class/devfreq/soc\:qcom,gpubw/max_freq
  47. echo %i > /sys/class/devfreq/soc\:qcom,cpubw/min_freq
  48. echo %i > /sys/class/devfreq/soc\:qcom,cpubw/max_freq
  49. echo %i > /sys/class/devfreq/soc\:qcom,mincpubw/min_freq
  50. echo %i > /sys/class/devfreq/soc\:qcom,mincpubw/max_freq
  51. echo %i > /sys/class/devfreq/soc\:qcom,memlat-cpu0/min_freq
  52. echo %i > /sys/class/devfreq/soc\:qcom,memlat-cpu0/max_freq''' %
  53. tuple(MEM_CLOCK_RATE for _ in range(8)),
  54. # Set GPU to performance mode
  55. '''
  56. echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor
  57. echo %i > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq
  58. echo %i > /sys/class/kgsl/kgsl-3d0/devfreq/min_freq''' %
  59. tuple(GPU_CLOCK_RATE for _ in range(2)),
  60. # Set GPU power level
  61. '''
  62. echo %i > /sys/class/kgsl/kgsl-3d0/max_pwrlevel
  63. echo %i > /sys/class/kgsl/kgsl-3d0/min_pwrlevel''' %
  64. tuple(GPU_POWER_LEVEL for _ in range(2))]))
  65. assert('msm_therm' == self._adb.check(\
  66. 'cat /sys/class/thermal/thermal_zone10/type').strip())
  67. assert('pm8998_tz' == self._adb.check(\
  68. 'cat /sys/class/thermal/thermal_zone7/type').strip())
  69. return self
  70. def sanity_check(self):
  71. HardwareAndroid.sanity_check(self)
  72. if not self._adb.is_root():
  73. return
  74. result = self._adb.check(' '.join(
  75. ['cat',
  76. '/sys/class/power_supply/battery/capacity',
  77. '/sys/devices/system/cpu/online'] + \
  78. ['/sys/devices/system/cpu/cpu%i/cpufreq/scaling_cur_freq' % i
  79. for i in range(4, 7)] + \
  80. # Unfortunately we can't monitor the gpu clock:
  81. #
  82. # /sys/class/kgsl/kgsl-3d0/devfreq/cur_freq
  83. #
  84. # It doesn't respect the min_freq/max_freq values when not under load.
  85. ['/sys/kernel/debug/clk/bimc_clk/measure',
  86. '/sys/class/kgsl/kgsl-3d0/temp',
  87. '/sys/class/kgsl/kgsl-3d0/throttling',
  88. '/sys/class/thermal/thermal_zone10/temp',
  89. '/sys/class/thermal/thermal_zone7/temp']))
  90. expectations = \
  91. [Expectation(int, min_value=30, name='battery', sleeptime=30*60),
  92. Expectation(str, exact_value='4-6', name='online cpus')] + \
  93. [Expectation(int, exact_value=CPU_CLOCK_RATE, name='cpu_%i clock rate' %i)
  94. for i in range(4, 7)] + \
  95. [Expectation(long, min_value=902390000, max_value=902409999,
  96. name='measured ddr clock', sleeptime=10),
  97. Expectation(int, max_value=750, name='gpu temperature'),
  98. Expectation(int, exact_value=1, name='gpu throttling'),
  99. Expectation(int, max_value=75, name='msm_therm temperature'),
  100. Expectation(int, max_value=75000, name='pm8998_tz temperature')]
  101. Expectation.check_all(expectations, result.splitlines())