amd-pstate.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2022 Advanced Micro Devices, Inc.
  4. *
  5. * Author: Meng Li <li.meng@amd.com>
  6. */
  7. #ifndef _LINUX_AMD_PSTATE_H
  8. #define _LINUX_AMD_PSTATE_H
  9. #include <linux/pm_qos.h>
  10. /*********************************************************************
  11. * AMD P-state INTERFACE *
  12. *********************************************************************/
  13. /**
  14. * struct amd_aperf_mperf
  15. * @aperf: actual performance frequency clock count
  16. * @mperf: maximum performance frequency clock count
  17. * @tsc: time stamp counter
  18. */
  19. struct amd_aperf_mperf {
  20. u64 aperf;
  21. u64 mperf;
  22. u64 tsc;
  23. };
  24. /**
  25. * struct amd_cpudata - private CPU data for AMD P-State
  26. * @cpu: CPU number
  27. * @req: constraint request to apply
  28. * @cppc_req_cached: cached performance request hints
  29. * @highest_perf: the maximum performance an individual processor may reach,
  30. * assuming ideal conditions
  31. * For platforms that do not support the preferred core feature, the
  32. * highest_pef may be configured with 166 or 255, to avoid max frequency
  33. * calculated wrongly. we take the fixed value as the highest_perf.
  34. * @nominal_perf: the maximum sustained performance level of the processor,
  35. * assuming ideal operating conditions
  36. * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power
  37. * savings are achieved
  38. * @lowest_perf: the absolute lowest performance level of the processor
  39. * @prefcore_ranking: the preferred core ranking, the higher value indicates a higher
  40. * priority.
  41. * @min_limit_perf: Cached value of the performance corresponding to policy->min
  42. * @max_limit_perf: Cached value of the performance corresponding to policy->max
  43. * @min_limit_freq: Cached value of policy->min (in khz)
  44. * @max_limit_freq: Cached value of policy->max (in khz)
  45. * @max_freq: the frequency (in khz) that mapped to highest_perf
  46. * @min_freq: the frequency (in khz) that mapped to lowest_perf
  47. * @nominal_freq: the frequency (in khz) that mapped to nominal_perf
  48. * @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf
  49. * @cur: Difference of Aperf/Mperf/tsc count between last and current sample
  50. * @prev: Last Aperf/Mperf/tsc count value read from register
  51. * @freq: current cpu frequency value (in khz)
  52. * @boost_supported: check whether the Processor or SBIOS supports boost mode
  53. * @hw_prefcore: check whether HW supports preferred core featue.
  54. * Only when hw_prefcore and early prefcore param are true,
  55. * AMD P-State driver supports preferred core featue.
  56. * @epp_policy: Last saved policy used to set energy-performance preference
  57. * @epp_cached: Cached CPPC energy-performance preference value
  58. * @policy: Cpufreq policy value
  59. * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value
  60. *
  61. * The amd_cpudata is key private data for each CPU thread in AMD P-State, and
  62. * represents all the attributes and goals that AMD P-State requests at runtime.
  63. */
  64. struct amd_cpudata {
  65. int cpu;
  66. struct freq_qos_request req[2];
  67. u64 cppc_req_cached;
  68. u32 highest_perf;
  69. u32 nominal_perf;
  70. u32 lowest_nonlinear_perf;
  71. u32 lowest_perf;
  72. u32 prefcore_ranking;
  73. u32 min_limit_perf;
  74. u32 max_limit_perf;
  75. u32 min_limit_freq;
  76. u32 max_limit_freq;
  77. u32 max_freq;
  78. u32 min_freq;
  79. u32 nominal_freq;
  80. u32 lowest_nonlinear_freq;
  81. struct amd_aperf_mperf cur;
  82. struct amd_aperf_mperf prev;
  83. u64 freq;
  84. bool boost_supported;
  85. bool hw_prefcore;
  86. /* EPP feature related attributes*/
  87. s16 epp_policy;
  88. s16 epp_cached;
  89. u32 policy;
  90. u64 cppc_cap1_cached;
  91. bool suspended;
  92. s16 epp_default;
  93. bool boost_state;
  94. };
  95. /*
  96. * enum amd_pstate_mode - driver working mode of amd pstate
  97. */
  98. enum amd_pstate_mode {
  99. AMD_PSTATE_UNDEFINED = 0,
  100. AMD_PSTATE_DISABLE,
  101. AMD_PSTATE_PASSIVE,
  102. AMD_PSTATE_ACTIVE,
  103. AMD_PSTATE_GUIDED,
  104. AMD_PSTATE_MAX,
  105. };
  106. const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode);
  107. int amd_pstate_update_status(const char *buf, size_t size);
  108. #endif /* _LINUX_AMD_PSTATE_H */