kgsl_pwrscale.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2010-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __KGSL_PWRSCALE_H
  7. #define __KGSL_PWRSCALE_H
  8. #include "governor.h"
  9. #include "kgsl_pwrctrl.h"
  10. #include "msm_adreno_devfreq.h"
  11. /* devfreq governor call window in usec */
  12. #define KGSL_GOVERNOR_CALL_INTERVAL 10000
  13. struct kgsl_power_stats {
  14. u64 busy_time;
  15. u64 ram_time;
  16. u64 ram_wait;
  17. };
  18. /**
  19. * struct kgsl_pwrscale - Power scaling settings for a KGSL device
  20. * @devfreqptr - Pointer to the devfreq device
  21. * @gpu_profile - GPU profile data for the devfreq device
  22. * @bus_profile - Bus specific data for the bus devfreq device
  23. * @freq_table - GPU frequencies for the DCVS algorithm
  24. * @last_governor - Prior devfreq governor
  25. * @accum_stats - Accumulated statistics for various frequency calculations
  26. * @enabled - Whether or not power scaling is enabled
  27. * @time - Last submitted sample timestamp
  28. * @on_time - Timestamp when gpu busy begins
  29. * @devfreq_wq - Main devfreq workqueue
  30. * @devfreq_suspend_ws - Pass device suspension to devfreq
  31. * @devfreq_resume_ws - Pass device resume to devfreq
  32. * @devfreq_notify_ws - Notify devfreq to update sampling
  33. * @next_governor_call - Timestamp after which the governor may be notified of
  34. * a new sample
  35. * @cooling_dev - Thermal cooling device handle
  36. * @ctxt_aware_enable - Whether or not ctxt aware DCVS feature is enabled
  37. * @ctxt_aware_busy_penalty - The time in microseconds required to trigger
  38. * ctxt aware power level jump
  39. * @ctxt_aware_target_pwrlevel - pwrlevel to jump on in case of ctxt aware
  40. * power level jump
  41. */
  42. struct kgsl_pwrscale {
  43. struct devfreq *devfreqptr;
  44. struct msm_adreno_extended_profile gpu_profile;
  45. struct msm_busmon_extended_profile bus_profile;
  46. unsigned long freq_table[KGSL_MAX_PWRLEVELS];
  47. char last_governor[DEVFREQ_NAME_LEN];
  48. struct kgsl_power_stats accum_stats;
  49. bool enabled;
  50. ktime_t time;
  51. s64 on_time;
  52. struct workqueue_struct *devfreq_wq;
  53. struct work_struct devfreq_suspend_ws;
  54. struct work_struct devfreq_resume_ws;
  55. struct work_struct devfreq_notify_ws;
  56. ktime_t next_governor_call;
  57. struct thermal_cooling_device *cooling_dev;
  58. bool ctxt_aware_enable;
  59. unsigned int ctxt_aware_target_pwrlevel;
  60. unsigned int ctxt_aware_busy_penalty;
  61. /** @busmondev: A child device for the busmon governor */
  62. struct device busmondev;
  63. /** @bus_devfreq: Pointer to the bus devfreq device */
  64. struct devfreq *bus_devfreq;
  65. /** @devfreq_enabled: Whether or not devfreq is enabled */
  66. bool devfreq_enabled;
  67. };
  68. /**
  69. * kgsl_pwrscale_init - Initialize the pwrscale subsystem
  70. * @device: A GPU device handle
  71. * @pdev: A pointer to the GPU platform device
  72. * @governor: default devfreq governor to use for GPU frequency scaling
  73. *
  74. * Return: 0 on success or negative on failure
  75. */
  76. int kgsl_pwrscale_init(struct kgsl_device *device, struct platform_device *pdev,
  77. const char *governor);
  78. void kgsl_pwrscale_close(struct kgsl_device *device);
  79. void kgsl_pwrscale_update(struct kgsl_device *device);
  80. void kgsl_pwrscale_update_stats(struct kgsl_device *device);
  81. void kgsl_pwrscale_busy(struct kgsl_device *device);
  82. void kgsl_pwrscale_sleep(struct kgsl_device *device);
  83. void kgsl_pwrscale_wake(struct kgsl_device *device);
  84. void kgsl_pwrscale_enable(struct kgsl_device *device);
  85. void kgsl_pwrscale_disable(struct kgsl_device *device, bool turbo);
  86. int kgsl_devfreq_target(struct device *dev, unsigned long *freq, u32 flags);
  87. int kgsl_devfreq_get_dev_status(struct device *dev,
  88. struct devfreq_dev_status *stat);
  89. int kgsl_devfreq_get_cur_freq(struct device *dev, unsigned long *freq);
  90. int kgsl_busmon_target(struct device *dev, unsigned long *freq, u32 flags);
  91. int kgsl_busmon_get_dev_status(struct device *dev,
  92. struct devfreq_dev_status *stat);
  93. int kgsl_busmon_get_cur_freq(struct device *dev, unsigned long *freq);
  94. int msm_adreno_tz_init(void);
  95. int msm_adreno_tz_reinit(struct devfreq *devfreq);
  96. void msm_adreno_tz_exit(void);
  97. int devfreq_gpubw_init(void);
  98. void devfreq_gpubw_exit(void);
  99. void kgsl_pwrscale_fast_bus_hint(bool on);
  100. #endif