amd_powerplay.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #include "pp_debug.h"
  24. #include <linux/types.h>
  25. #include <linux/kernel.h>
  26. #include <linux/gfp.h>
  27. #include <linux/slab.h>
  28. #include <linux/firmware.h>
  29. #include "amd_shared.h"
  30. #include "amd_powerplay.h"
  31. #include "power_state.h"
  32. #include "amdgpu.h"
  33. #include "hwmgr.h"
  34. static const struct amd_pm_funcs pp_dpm_funcs;
  35. static int amd_powerplay_create(struct amdgpu_device *adev)
  36. {
  37. struct pp_hwmgr *hwmgr;
  38. if (adev == NULL)
  39. return -EINVAL;
  40. hwmgr = kzalloc(sizeof(struct pp_hwmgr), GFP_KERNEL);
  41. if (hwmgr == NULL)
  42. return -ENOMEM;
  43. hwmgr->adev = adev;
  44. hwmgr->not_vf = !amdgpu_sriov_vf(adev);
  45. hwmgr->pm_en = (amdgpu_dpm && hwmgr->not_vf) ? true : false;
  46. hwmgr->device = amdgpu_cgs_create_device(adev);
  47. mutex_init(&hwmgr->smu_lock);
  48. hwmgr->chip_family = adev->family;
  49. hwmgr->chip_id = adev->asic_type;
  50. hwmgr->feature_mask = adev->powerplay.pp_feature;
  51. hwmgr->display_config = &adev->pm.pm_display_cfg;
  52. adev->powerplay.pp_handle = hwmgr;
  53. adev->powerplay.pp_funcs = &pp_dpm_funcs;
  54. return 0;
  55. }
  56. static void amd_powerplay_destroy(struct amdgpu_device *adev)
  57. {
  58. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  59. kfree(hwmgr->hardcode_pp_table);
  60. hwmgr->hardcode_pp_table = NULL;
  61. kfree(hwmgr);
  62. hwmgr = NULL;
  63. }
  64. static int pp_early_init(void *handle)
  65. {
  66. int ret;
  67. struct amdgpu_device *adev = handle;
  68. ret = amd_powerplay_create(adev);
  69. if (ret != 0)
  70. return ret;
  71. ret = hwmgr_early_init(adev->powerplay.pp_handle);
  72. if (ret)
  73. return -EINVAL;
  74. return 0;
  75. }
  76. static int pp_sw_init(void *handle)
  77. {
  78. struct amdgpu_device *adev = handle;
  79. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  80. int ret = 0;
  81. ret = hwmgr_sw_init(hwmgr);
  82. pr_debug("powerplay sw init %s\n", ret ? "failed" : "successfully");
  83. return ret;
  84. }
  85. static int pp_sw_fini(void *handle)
  86. {
  87. struct amdgpu_device *adev = handle;
  88. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  89. hwmgr_sw_fini(hwmgr);
  90. if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) {
  91. release_firmware(adev->pm.fw);
  92. adev->pm.fw = NULL;
  93. amdgpu_ucode_fini_bo(adev);
  94. }
  95. return 0;
  96. }
  97. static int pp_hw_init(void *handle)
  98. {
  99. int ret = 0;
  100. struct amdgpu_device *adev = handle;
  101. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  102. if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
  103. amdgpu_ucode_init_bo(adev);
  104. ret = hwmgr_hw_init(hwmgr);
  105. if (ret)
  106. pr_err("powerplay hw init failed\n");
  107. return ret;
  108. }
  109. static int pp_hw_fini(void *handle)
  110. {
  111. struct amdgpu_device *adev = handle;
  112. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  113. hwmgr_hw_fini(hwmgr);
  114. return 0;
  115. }
  116. static void pp_reserve_vram_for_smu(struct amdgpu_device *adev)
  117. {
  118. int r = -EINVAL;
  119. void *cpu_ptr = NULL;
  120. uint64_t gpu_addr;
  121. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  122. if (amdgpu_bo_create_kernel(adev, adev->pm.smu_prv_buffer_size,
  123. PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
  124. &adev->pm.smu_prv_buffer,
  125. &gpu_addr,
  126. &cpu_ptr)) {
  127. DRM_ERROR("amdgpu: failed to create smu prv buffer\n");
  128. return;
  129. }
  130. if (hwmgr->hwmgr_func->notify_cac_buffer_info)
  131. r = hwmgr->hwmgr_func->notify_cac_buffer_info(hwmgr,
  132. lower_32_bits((unsigned long)cpu_ptr),
  133. upper_32_bits((unsigned long)cpu_ptr),
  134. lower_32_bits(gpu_addr),
  135. upper_32_bits(gpu_addr),
  136. adev->pm.smu_prv_buffer_size);
  137. if (r) {
  138. amdgpu_bo_free_kernel(&adev->pm.smu_prv_buffer, NULL, NULL);
  139. adev->pm.smu_prv_buffer = NULL;
  140. DRM_ERROR("amdgpu: failed to notify SMU buffer address\n");
  141. }
  142. }
  143. static int pp_late_init(void *handle)
  144. {
  145. struct amdgpu_device *adev = handle;
  146. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  147. if (hwmgr && hwmgr->pm_en) {
  148. mutex_lock(&hwmgr->smu_lock);
  149. hwmgr_handle_task(hwmgr,
  150. AMD_PP_TASK_COMPLETE_INIT, NULL);
  151. mutex_unlock(&hwmgr->smu_lock);
  152. }
  153. if (adev->pm.smu_prv_buffer_size != 0)
  154. pp_reserve_vram_for_smu(adev);
  155. return 0;
  156. }
  157. static void pp_late_fini(void *handle)
  158. {
  159. struct amdgpu_device *adev = handle;
  160. if (adev->pm.smu_prv_buffer)
  161. amdgpu_bo_free_kernel(&adev->pm.smu_prv_buffer, NULL, NULL);
  162. amd_powerplay_destroy(adev);
  163. }
  164. static bool pp_is_idle(void *handle)
  165. {
  166. return false;
  167. }
  168. static int pp_wait_for_idle(void *handle)
  169. {
  170. return 0;
  171. }
  172. static int pp_sw_reset(void *handle)
  173. {
  174. return 0;
  175. }
  176. static int pp_set_powergating_state(void *handle,
  177. enum amd_powergating_state state)
  178. {
  179. return 0;
  180. }
  181. static int pp_suspend(void *handle)
  182. {
  183. struct amdgpu_device *adev = handle;
  184. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  185. return hwmgr_suspend(hwmgr);
  186. }
  187. static int pp_resume(void *handle)
  188. {
  189. struct amdgpu_device *adev = handle;
  190. struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
  191. return hwmgr_resume(hwmgr);
  192. }
  193. static int pp_set_clockgating_state(void *handle,
  194. enum amd_clockgating_state state)
  195. {
  196. return 0;
  197. }
  198. static const struct amd_ip_funcs pp_ip_funcs = {
  199. .name = "powerplay",
  200. .early_init = pp_early_init,
  201. .late_init = pp_late_init,
  202. .sw_init = pp_sw_init,
  203. .sw_fini = pp_sw_fini,
  204. .hw_init = pp_hw_init,
  205. .hw_fini = pp_hw_fini,
  206. .late_fini = pp_late_fini,
  207. .suspend = pp_suspend,
  208. .resume = pp_resume,
  209. .is_idle = pp_is_idle,
  210. .wait_for_idle = pp_wait_for_idle,
  211. .soft_reset = pp_sw_reset,
  212. .set_clockgating_state = pp_set_clockgating_state,
  213. .set_powergating_state = pp_set_powergating_state,
  214. };
  215. const struct amdgpu_ip_block_version pp_smu_ip_block =
  216. {
  217. .type = AMD_IP_BLOCK_TYPE_SMC,
  218. .major = 1,
  219. .minor = 0,
  220. .rev = 0,
  221. .funcs = &pp_ip_funcs,
  222. };
  223. static int pp_dpm_load_fw(void *handle)
  224. {
  225. return 0;
  226. }
  227. static int pp_dpm_fw_loading_complete(void *handle)
  228. {
  229. return 0;
  230. }
  231. static int pp_set_clockgating_by_smu(void *handle, uint32_t msg_id)
  232. {
  233. struct pp_hwmgr *hwmgr = handle;
  234. if (!hwmgr || !hwmgr->pm_en)
  235. return -EINVAL;
  236. if (hwmgr->hwmgr_func->update_clock_gatings == NULL) {
  237. pr_info("%s was not implemented.\n", __func__);
  238. return 0;
  239. }
  240. return hwmgr->hwmgr_func->update_clock_gatings(hwmgr, &msg_id);
  241. }
  242. static void pp_dpm_en_umd_pstate(struct pp_hwmgr *hwmgr,
  243. enum amd_dpm_forced_level *level)
  244. {
  245. uint32_t profile_mode_mask = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD |
  246. AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK |
  247. AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK |
  248. AMD_DPM_FORCED_LEVEL_PROFILE_PEAK;
  249. if (!(hwmgr->dpm_level & profile_mode_mask)) {
  250. /* enter umd pstate, save current level, disable gfx cg*/
  251. if (*level & profile_mode_mask) {
  252. hwmgr->saved_dpm_level = hwmgr->dpm_level;
  253. hwmgr->en_umd_pstate = true;
  254. amdgpu_device_ip_set_clockgating_state(hwmgr->adev,
  255. AMD_IP_BLOCK_TYPE_GFX,
  256. AMD_CG_STATE_UNGATE);
  257. amdgpu_device_ip_set_powergating_state(hwmgr->adev,
  258. AMD_IP_BLOCK_TYPE_GFX,
  259. AMD_PG_STATE_UNGATE);
  260. }
  261. } else {
  262. /* exit umd pstate, restore level, enable gfx cg*/
  263. if (!(*level & profile_mode_mask)) {
  264. if (*level == AMD_DPM_FORCED_LEVEL_PROFILE_EXIT)
  265. *level = hwmgr->saved_dpm_level;
  266. hwmgr->en_umd_pstate = false;
  267. amdgpu_device_ip_set_clockgating_state(hwmgr->adev,
  268. AMD_IP_BLOCK_TYPE_GFX,
  269. AMD_CG_STATE_GATE);
  270. amdgpu_device_ip_set_powergating_state(hwmgr->adev,
  271. AMD_IP_BLOCK_TYPE_GFX,
  272. AMD_PG_STATE_GATE);
  273. }
  274. }
  275. }
  276. static int pp_dpm_force_performance_level(void *handle,
  277. enum amd_dpm_forced_level level)
  278. {
  279. struct pp_hwmgr *hwmgr = handle;
  280. if (!hwmgr || !hwmgr->pm_en)
  281. return -EINVAL;
  282. if (level == hwmgr->dpm_level)
  283. return 0;
  284. mutex_lock(&hwmgr->smu_lock);
  285. pp_dpm_en_umd_pstate(hwmgr, &level);
  286. hwmgr->request_dpm_level = level;
  287. hwmgr_handle_task(hwmgr, AMD_PP_TASK_READJUST_POWER_STATE, NULL);
  288. mutex_unlock(&hwmgr->smu_lock);
  289. return 0;
  290. }
  291. static enum amd_dpm_forced_level pp_dpm_get_performance_level(
  292. void *handle)
  293. {
  294. struct pp_hwmgr *hwmgr = handle;
  295. enum amd_dpm_forced_level level;
  296. if (!hwmgr || !hwmgr->pm_en)
  297. return -EINVAL;
  298. mutex_lock(&hwmgr->smu_lock);
  299. level = hwmgr->dpm_level;
  300. mutex_unlock(&hwmgr->smu_lock);
  301. return level;
  302. }
  303. static uint32_t pp_dpm_get_sclk(void *handle, bool low)
  304. {
  305. struct pp_hwmgr *hwmgr = handle;
  306. uint32_t clk = 0;
  307. if (!hwmgr || !hwmgr->pm_en)
  308. return 0;
  309. if (hwmgr->hwmgr_func->get_sclk == NULL) {
  310. pr_info("%s was not implemented.\n", __func__);
  311. return 0;
  312. }
  313. mutex_lock(&hwmgr->smu_lock);
  314. clk = hwmgr->hwmgr_func->get_sclk(hwmgr, low);
  315. mutex_unlock(&hwmgr->smu_lock);
  316. return clk;
  317. }
  318. static uint32_t pp_dpm_get_mclk(void *handle, bool low)
  319. {
  320. struct pp_hwmgr *hwmgr = handle;
  321. uint32_t clk = 0;
  322. if (!hwmgr || !hwmgr->pm_en)
  323. return 0;
  324. if (hwmgr->hwmgr_func->get_mclk == NULL) {
  325. pr_info("%s was not implemented.\n", __func__);
  326. return 0;
  327. }
  328. mutex_lock(&hwmgr->smu_lock);
  329. clk = hwmgr->hwmgr_func->get_mclk(hwmgr, low);
  330. mutex_unlock(&hwmgr->smu_lock);
  331. return clk;
  332. }
  333. static void pp_dpm_powergate_vce(void *handle, bool gate)
  334. {
  335. struct pp_hwmgr *hwmgr = handle;
  336. if (!hwmgr || !hwmgr->pm_en)
  337. return;
  338. if (hwmgr->hwmgr_func->powergate_vce == NULL) {
  339. pr_info("%s was not implemented.\n", __func__);
  340. return;
  341. }
  342. mutex_lock(&hwmgr->smu_lock);
  343. hwmgr->hwmgr_func->powergate_vce(hwmgr, gate);
  344. mutex_unlock(&hwmgr->smu_lock);
  345. }
  346. static void pp_dpm_powergate_uvd(void *handle, bool gate)
  347. {
  348. struct pp_hwmgr *hwmgr = handle;
  349. if (!hwmgr || !hwmgr->pm_en)
  350. return;
  351. if (hwmgr->hwmgr_func->powergate_uvd == NULL) {
  352. pr_info("%s was not implemented.\n", __func__);
  353. return;
  354. }
  355. mutex_lock(&hwmgr->smu_lock);
  356. hwmgr->hwmgr_func->powergate_uvd(hwmgr, gate);
  357. mutex_unlock(&hwmgr->smu_lock);
  358. }
  359. static int pp_dpm_dispatch_tasks(void *handle, enum amd_pp_task task_id,
  360. enum amd_pm_state_type *user_state)
  361. {
  362. int ret = 0;
  363. struct pp_hwmgr *hwmgr = handle;
  364. if (!hwmgr || !hwmgr->pm_en)
  365. return -EINVAL;
  366. mutex_lock(&hwmgr->smu_lock);
  367. ret = hwmgr_handle_task(hwmgr, task_id, user_state);
  368. mutex_unlock(&hwmgr->smu_lock);
  369. return ret;
  370. }
  371. static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)
  372. {
  373. struct pp_hwmgr *hwmgr = handle;
  374. struct pp_power_state *state;
  375. enum amd_pm_state_type pm_type;
  376. if (!hwmgr || !hwmgr->pm_en || !hwmgr->current_ps)
  377. return -EINVAL;
  378. mutex_lock(&hwmgr->smu_lock);
  379. state = hwmgr->current_ps;
  380. switch (state->classification.ui_label) {
  381. case PP_StateUILabel_Battery:
  382. pm_type = POWER_STATE_TYPE_BATTERY;
  383. break;
  384. case PP_StateUILabel_Balanced:
  385. pm_type = POWER_STATE_TYPE_BALANCED;
  386. break;
  387. case PP_StateUILabel_Performance:
  388. pm_type = POWER_STATE_TYPE_PERFORMANCE;
  389. break;
  390. default:
  391. if (state->classification.flags & PP_StateClassificationFlag_Boot)
  392. pm_type = POWER_STATE_TYPE_INTERNAL_BOOT;
  393. else
  394. pm_type = POWER_STATE_TYPE_DEFAULT;
  395. break;
  396. }
  397. mutex_unlock(&hwmgr->smu_lock);
  398. return pm_type;
  399. }
  400. static void pp_dpm_set_fan_control_mode(void *handle, uint32_t mode)
  401. {
  402. struct pp_hwmgr *hwmgr = handle;
  403. if (!hwmgr || !hwmgr->pm_en)
  404. return;
  405. if (hwmgr->hwmgr_func->set_fan_control_mode == NULL) {
  406. pr_info("%s was not implemented.\n", __func__);
  407. return;
  408. }
  409. mutex_lock(&hwmgr->smu_lock);
  410. hwmgr->hwmgr_func->set_fan_control_mode(hwmgr, mode);
  411. mutex_unlock(&hwmgr->smu_lock);
  412. }
  413. static uint32_t pp_dpm_get_fan_control_mode(void *handle)
  414. {
  415. struct pp_hwmgr *hwmgr = handle;
  416. uint32_t mode = 0;
  417. if (!hwmgr || !hwmgr->pm_en)
  418. return 0;
  419. if (hwmgr->hwmgr_func->get_fan_control_mode == NULL) {
  420. pr_info("%s was not implemented.\n", __func__);
  421. return 0;
  422. }
  423. mutex_lock(&hwmgr->smu_lock);
  424. mode = hwmgr->hwmgr_func->get_fan_control_mode(hwmgr);
  425. mutex_unlock(&hwmgr->smu_lock);
  426. return mode;
  427. }
  428. static int pp_dpm_set_fan_speed_percent(void *handle, uint32_t percent)
  429. {
  430. struct pp_hwmgr *hwmgr = handle;
  431. int ret = 0;
  432. if (!hwmgr || !hwmgr->pm_en)
  433. return -EINVAL;
  434. if (hwmgr->hwmgr_func->set_fan_speed_percent == NULL) {
  435. pr_info("%s was not implemented.\n", __func__);
  436. return 0;
  437. }
  438. mutex_lock(&hwmgr->smu_lock);
  439. ret = hwmgr->hwmgr_func->set_fan_speed_percent(hwmgr, percent);
  440. mutex_unlock(&hwmgr->smu_lock);
  441. return ret;
  442. }
  443. static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed)
  444. {
  445. struct pp_hwmgr *hwmgr = handle;
  446. int ret = 0;
  447. if (!hwmgr || !hwmgr->pm_en)
  448. return -EINVAL;
  449. if (hwmgr->hwmgr_func->get_fan_speed_percent == NULL) {
  450. pr_info("%s was not implemented.\n", __func__);
  451. return 0;
  452. }
  453. mutex_lock(&hwmgr->smu_lock);
  454. ret = hwmgr->hwmgr_func->get_fan_speed_percent(hwmgr, speed);
  455. mutex_unlock(&hwmgr->smu_lock);
  456. return ret;
  457. }
  458. static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm)
  459. {
  460. struct pp_hwmgr *hwmgr = handle;
  461. int ret = 0;
  462. if (!hwmgr || !hwmgr->pm_en)
  463. return -EINVAL;
  464. if (hwmgr->hwmgr_func->get_fan_speed_rpm == NULL)
  465. return -EINVAL;
  466. mutex_lock(&hwmgr->smu_lock);
  467. ret = hwmgr->hwmgr_func->get_fan_speed_rpm(hwmgr, rpm);
  468. mutex_unlock(&hwmgr->smu_lock);
  469. return ret;
  470. }
  471. static int pp_dpm_get_pp_num_states(void *handle,
  472. struct pp_states_info *data)
  473. {
  474. struct pp_hwmgr *hwmgr = handle;
  475. int i;
  476. memset(data, 0, sizeof(*data));
  477. if (!hwmgr || !hwmgr->pm_en ||!hwmgr->ps)
  478. return -EINVAL;
  479. mutex_lock(&hwmgr->smu_lock);
  480. data->nums = hwmgr->num_ps;
  481. for (i = 0; i < hwmgr->num_ps; i++) {
  482. struct pp_power_state *state = (struct pp_power_state *)
  483. ((unsigned long)hwmgr->ps + i * hwmgr->ps_size);
  484. switch (state->classification.ui_label) {
  485. case PP_StateUILabel_Battery:
  486. data->states[i] = POWER_STATE_TYPE_BATTERY;
  487. break;
  488. case PP_StateUILabel_Balanced:
  489. data->states[i] = POWER_STATE_TYPE_BALANCED;
  490. break;
  491. case PP_StateUILabel_Performance:
  492. data->states[i] = POWER_STATE_TYPE_PERFORMANCE;
  493. break;
  494. default:
  495. if (state->classification.flags & PP_StateClassificationFlag_Boot)
  496. data->states[i] = POWER_STATE_TYPE_INTERNAL_BOOT;
  497. else
  498. data->states[i] = POWER_STATE_TYPE_DEFAULT;
  499. }
  500. }
  501. mutex_unlock(&hwmgr->smu_lock);
  502. return 0;
  503. }
  504. static int pp_dpm_get_pp_table(void *handle, char **table)
  505. {
  506. struct pp_hwmgr *hwmgr = handle;
  507. int size = 0;
  508. if (!hwmgr || !hwmgr->pm_en ||!hwmgr->soft_pp_table)
  509. return -EINVAL;
  510. mutex_lock(&hwmgr->smu_lock);
  511. *table = (char *)hwmgr->soft_pp_table;
  512. size = hwmgr->soft_pp_table_size;
  513. mutex_unlock(&hwmgr->smu_lock);
  514. return size;
  515. }
  516. static int amd_powerplay_reset(void *handle)
  517. {
  518. struct pp_hwmgr *hwmgr = handle;
  519. int ret;
  520. ret = hwmgr_hw_fini(hwmgr);
  521. if (ret)
  522. return ret;
  523. ret = hwmgr_hw_init(hwmgr);
  524. if (ret)
  525. return ret;
  526. return hwmgr_handle_task(hwmgr, AMD_PP_TASK_COMPLETE_INIT, NULL);
  527. }
  528. static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size)
  529. {
  530. struct pp_hwmgr *hwmgr = handle;
  531. int ret = -ENOMEM;
  532. if (!hwmgr || !hwmgr->pm_en)
  533. return -EINVAL;
  534. mutex_lock(&hwmgr->smu_lock);
  535. if (!hwmgr->hardcode_pp_table) {
  536. hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table,
  537. hwmgr->soft_pp_table_size,
  538. GFP_KERNEL);
  539. if (!hwmgr->hardcode_pp_table)
  540. goto err;
  541. }
  542. memcpy(hwmgr->hardcode_pp_table, buf, size);
  543. hwmgr->soft_pp_table = hwmgr->hardcode_pp_table;
  544. ret = amd_powerplay_reset(handle);
  545. if (ret)
  546. goto err;
  547. if (hwmgr->hwmgr_func->avfs_control) {
  548. ret = hwmgr->hwmgr_func->avfs_control(hwmgr, false);
  549. if (ret)
  550. goto err;
  551. }
  552. mutex_unlock(&hwmgr->smu_lock);
  553. return 0;
  554. err:
  555. mutex_unlock(&hwmgr->smu_lock);
  556. return ret;
  557. }
  558. static int pp_dpm_force_clock_level(void *handle,
  559. enum pp_clock_type type, uint32_t mask)
  560. {
  561. struct pp_hwmgr *hwmgr = handle;
  562. int ret = 0;
  563. if (!hwmgr || !hwmgr->pm_en)
  564. return -EINVAL;
  565. if (hwmgr->hwmgr_func->force_clock_level == NULL) {
  566. pr_info("%s was not implemented.\n", __func__);
  567. return 0;
  568. }
  569. mutex_lock(&hwmgr->smu_lock);
  570. if (hwmgr->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL)
  571. ret = hwmgr->hwmgr_func->force_clock_level(hwmgr, type, mask);
  572. else
  573. ret = -EINVAL;
  574. mutex_unlock(&hwmgr->smu_lock);
  575. return ret;
  576. }
  577. static int pp_dpm_print_clock_levels(void *handle,
  578. enum pp_clock_type type, char *buf)
  579. {
  580. struct pp_hwmgr *hwmgr = handle;
  581. int ret = 0;
  582. if (!hwmgr || !hwmgr->pm_en)
  583. return -EINVAL;
  584. if (hwmgr->hwmgr_func->print_clock_levels == NULL) {
  585. pr_info("%s was not implemented.\n", __func__);
  586. return 0;
  587. }
  588. mutex_lock(&hwmgr->smu_lock);
  589. ret = hwmgr->hwmgr_func->print_clock_levels(hwmgr, type, buf);
  590. mutex_unlock(&hwmgr->smu_lock);
  591. return ret;
  592. }
  593. static int pp_dpm_get_sclk_od(void *handle)
  594. {
  595. struct pp_hwmgr *hwmgr = handle;
  596. int ret = 0;
  597. if (!hwmgr || !hwmgr->pm_en)
  598. return -EINVAL;
  599. if (hwmgr->hwmgr_func->get_sclk_od == NULL) {
  600. pr_info("%s was not implemented.\n", __func__);
  601. return 0;
  602. }
  603. mutex_lock(&hwmgr->smu_lock);
  604. ret = hwmgr->hwmgr_func->get_sclk_od(hwmgr);
  605. mutex_unlock(&hwmgr->smu_lock);
  606. return ret;
  607. }
  608. static int pp_dpm_set_sclk_od(void *handle, uint32_t value)
  609. {
  610. struct pp_hwmgr *hwmgr = handle;
  611. int ret = 0;
  612. if (!hwmgr || !hwmgr->pm_en)
  613. return -EINVAL;
  614. if (hwmgr->hwmgr_func->set_sclk_od == NULL) {
  615. pr_info("%s was not implemented.\n", __func__);
  616. return 0;
  617. }
  618. mutex_lock(&hwmgr->smu_lock);
  619. ret = hwmgr->hwmgr_func->set_sclk_od(hwmgr, value);
  620. mutex_unlock(&hwmgr->smu_lock);
  621. return ret;
  622. }
  623. static int pp_dpm_get_mclk_od(void *handle)
  624. {
  625. struct pp_hwmgr *hwmgr = handle;
  626. int ret = 0;
  627. if (!hwmgr || !hwmgr->pm_en)
  628. return -EINVAL;
  629. if (hwmgr->hwmgr_func->get_mclk_od == NULL) {
  630. pr_info("%s was not implemented.\n", __func__);
  631. return 0;
  632. }
  633. mutex_lock(&hwmgr->smu_lock);
  634. ret = hwmgr->hwmgr_func->get_mclk_od(hwmgr);
  635. mutex_unlock(&hwmgr->smu_lock);
  636. return ret;
  637. }
  638. static int pp_dpm_set_mclk_od(void *handle, uint32_t value)
  639. {
  640. struct pp_hwmgr *hwmgr = handle;
  641. int ret = 0;
  642. if (!hwmgr || !hwmgr->pm_en)
  643. return -EINVAL;
  644. if (hwmgr->hwmgr_func->set_mclk_od == NULL) {
  645. pr_info("%s was not implemented.\n", __func__);
  646. return 0;
  647. }
  648. mutex_lock(&hwmgr->smu_lock);
  649. ret = hwmgr->hwmgr_func->set_mclk_od(hwmgr, value);
  650. mutex_unlock(&hwmgr->smu_lock);
  651. return ret;
  652. }
  653. static int pp_dpm_read_sensor(void *handle, int idx,
  654. void *value, int *size)
  655. {
  656. struct pp_hwmgr *hwmgr = handle;
  657. int ret = 0;
  658. if (!hwmgr || !hwmgr->pm_en || !value)
  659. return -EINVAL;
  660. switch (idx) {
  661. case AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK:
  662. *((uint32_t *)value) = hwmgr->pstate_sclk;
  663. return 0;
  664. case AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK:
  665. *((uint32_t *)value) = hwmgr->pstate_mclk;
  666. return 0;
  667. default:
  668. mutex_lock(&hwmgr->smu_lock);
  669. ret = hwmgr->hwmgr_func->read_sensor(hwmgr, idx, value, size);
  670. mutex_unlock(&hwmgr->smu_lock);
  671. return ret;
  672. }
  673. }
  674. static struct amd_vce_state*
  675. pp_dpm_get_vce_clock_state(void *handle, unsigned idx)
  676. {
  677. struct pp_hwmgr *hwmgr = handle;
  678. if (!hwmgr || !hwmgr->pm_en)
  679. return NULL;
  680. if (idx < hwmgr->num_vce_state_tables)
  681. return &hwmgr->vce_states[idx];
  682. return NULL;
  683. }
  684. static int pp_get_power_profile_mode(void *handle, char *buf)
  685. {
  686. struct pp_hwmgr *hwmgr = handle;
  687. if (!hwmgr || !hwmgr->pm_en || !buf)
  688. return -EINVAL;
  689. if (hwmgr->hwmgr_func->get_power_profile_mode == NULL) {
  690. pr_info("%s was not implemented.\n", __func__);
  691. return snprintf(buf, PAGE_SIZE, "\n");
  692. }
  693. return hwmgr->hwmgr_func->get_power_profile_mode(hwmgr, buf);
  694. }
  695. static int pp_set_power_profile_mode(void *handle, long *input, uint32_t size)
  696. {
  697. struct pp_hwmgr *hwmgr = handle;
  698. int ret = -EINVAL;
  699. if (!hwmgr || !hwmgr->pm_en)
  700. return ret;
  701. if (hwmgr->hwmgr_func->set_power_profile_mode == NULL) {
  702. pr_info("%s was not implemented.\n", __func__);
  703. return ret;
  704. }
  705. mutex_lock(&hwmgr->smu_lock);
  706. if (hwmgr->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL)
  707. ret = hwmgr->hwmgr_func->set_power_profile_mode(hwmgr, input, size);
  708. mutex_unlock(&hwmgr->smu_lock);
  709. return ret;
  710. }
  711. static int pp_odn_edit_dpm_table(void *handle, uint32_t type, long *input, uint32_t size)
  712. {
  713. struct pp_hwmgr *hwmgr = handle;
  714. if (!hwmgr || !hwmgr->pm_en)
  715. return -EINVAL;
  716. if (hwmgr->hwmgr_func->odn_edit_dpm_table == NULL) {
  717. pr_info("%s was not implemented.\n", __func__);
  718. return -EINVAL;
  719. }
  720. return hwmgr->hwmgr_func->odn_edit_dpm_table(hwmgr, type, input, size);
  721. }
  722. static int pp_dpm_switch_power_profile(void *handle,
  723. enum PP_SMC_POWER_PROFILE type, bool en)
  724. {
  725. struct pp_hwmgr *hwmgr = handle;
  726. long workload;
  727. uint32_t index;
  728. if (!hwmgr || !hwmgr->pm_en)
  729. return -EINVAL;
  730. if (hwmgr->hwmgr_func->set_power_profile_mode == NULL) {
  731. pr_info("%s was not implemented.\n", __func__);
  732. return -EINVAL;
  733. }
  734. if (!(type < PP_SMC_POWER_PROFILE_CUSTOM))
  735. return -EINVAL;
  736. mutex_lock(&hwmgr->smu_lock);
  737. if (!en) {
  738. hwmgr->workload_mask &= ~(1 << hwmgr->workload_prority[type]);
  739. index = fls(hwmgr->workload_mask);
  740. index = index > 0 && index <= Workload_Policy_Max ? index - 1 : 0;
  741. workload = hwmgr->workload_setting[index];
  742. } else {
  743. hwmgr->workload_mask |= (1 << hwmgr->workload_prority[type]);
  744. index = fls(hwmgr->workload_mask);
  745. index = index <= Workload_Policy_Max ? index - 1 : 0;
  746. workload = hwmgr->workload_setting[index];
  747. }
  748. if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL)
  749. hwmgr->hwmgr_func->set_power_profile_mode(hwmgr, &workload, 0);
  750. mutex_unlock(&hwmgr->smu_lock);
  751. return 0;
  752. }
  753. static int pp_set_power_limit(void *handle, uint32_t limit)
  754. {
  755. struct pp_hwmgr *hwmgr = handle;
  756. if (!hwmgr || !hwmgr->pm_en)
  757. return -EINVAL;
  758. if (hwmgr->hwmgr_func->set_power_limit == NULL) {
  759. pr_info("%s was not implemented.\n", __func__);
  760. return -EINVAL;
  761. }
  762. if (limit == 0)
  763. limit = hwmgr->default_power_limit;
  764. if (limit > hwmgr->default_power_limit)
  765. return -EINVAL;
  766. mutex_lock(&hwmgr->smu_lock);
  767. hwmgr->hwmgr_func->set_power_limit(hwmgr, limit);
  768. hwmgr->power_limit = limit;
  769. mutex_unlock(&hwmgr->smu_lock);
  770. return 0;
  771. }
  772. static int pp_get_power_limit(void *handle, uint32_t *limit, bool default_limit)
  773. {
  774. struct pp_hwmgr *hwmgr = handle;
  775. if (!hwmgr || !hwmgr->pm_en ||!limit)
  776. return -EINVAL;
  777. mutex_lock(&hwmgr->smu_lock);
  778. if (default_limit)
  779. *limit = hwmgr->default_power_limit;
  780. else
  781. *limit = hwmgr->power_limit;
  782. mutex_unlock(&hwmgr->smu_lock);
  783. return 0;
  784. }
  785. static int pp_display_configuration_change(void *handle,
  786. const struct amd_pp_display_configuration *display_config)
  787. {
  788. struct pp_hwmgr *hwmgr = handle;
  789. if (!hwmgr || !hwmgr->pm_en)
  790. return -EINVAL;
  791. mutex_lock(&hwmgr->smu_lock);
  792. phm_store_dal_configuration_data(hwmgr, display_config);
  793. mutex_unlock(&hwmgr->smu_lock);
  794. return 0;
  795. }
  796. static int pp_get_display_power_level(void *handle,
  797. struct amd_pp_simple_clock_info *output)
  798. {
  799. struct pp_hwmgr *hwmgr = handle;
  800. int ret = 0;
  801. if (!hwmgr || !hwmgr->pm_en ||!output)
  802. return -EINVAL;
  803. mutex_lock(&hwmgr->smu_lock);
  804. ret = phm_get_dal_power_level(hwmgr, output);
  805. mutex_unlock(&hwmgr->smu_lock);
  806. return ret;
  807. }
  808. static int pp_get_current_clocks(void *handle,
  809. struct amd_pp_clock_info *clocks)
  810. {
  811. struct amd_pp_simple_clock_info simple_clocks = { 0 };
  812. struct pp_clock_info hw_clocks;
  813. struct pp_hwmgr *hwmgr = handle;
  814. int ret = 0;
  815. if (!hwmgr || !hwmgr->pm_en)
  816. return -EINVAL;
  817. mutex_lock(&hwmgr->smu_lock);
  818. phm_get_dal_power_level(hwmgr, &simple_clocks);
  819. if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
  820. PHM_PlatformCaps_PowerContainment))
  821. ret = phm_get_clock_info(hwmgr, &hwmgr->current_ps->hardware,
  822. &hw_clocks, PHM_PerformanceLevelDesignation_PowerContainment);
  823. else
  824. ret = phm_get_clock_info(hwmgr, &hwmgr->current_ps->hardware,
  825. &hw_clocks, PHM_PerformanceLevelDesignation_Activity);
  826. if (ret) {
  827. pr_info("Error in phm_get_clock_info \n");
  828. mutex_unlock(&hwmgr->smu_lock);
  829. return -EINVAL;
  830. }
  831. clocks->min_engine_clock = hw_clocks.min_eng_clk;
  832. clocks->max_engine_clock = hw_clocks.max_eng_clk;
  833. clocks->min_memory_clock = hw_clocks.min_mem_clk;
  834. clocks->max_memory_clock = hw_clocks.max_mem_clk;
  835. clocks->min_bus_bandwidth = hw_clocks.min_bus_bandwidth;
  836. clocks->max_bus_bandwidth = hw_clocks.max_bus_bandwidth;
  837. clocks->max_engine_clock_in_sr = hw_clocks.max_eng_clk;
  838. clocks->min_engine_clock_in_sr = hw_clocks.min_eng_clk;
  839. if (simple_clocks.level == 0)
  840. clocks->max_clocks_state = PP_DAL_POWERLEVEL_7;
  841. else
  842. clocks->max_clocks_state = simple_clocks.level;
  843. if (0 == phm_get_current_shallow_sleep_clocks(hwmgr, &hwmgr->current_ps->hardware, &hw_clocks)) {
  844. clocks->max_engine_clock_in_sr = hw_clocks.max_eng_clk;
  845. clocks->min_engine_clock_in_sr = hw_clocks.min_eng_clk;
  846. }
  847. mutex_unlock(&hwmgr->smu_lock);
  848. return 0;
  849. }
  850. static int pp_get_clock_by_type(void *handle, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks)
  851. {
  852. struct pp_hwmgr *hwmgr = handle;
  853. int ret = 0;
  854. if (!hwmgr || !hwmgr->pm_en)
  855. return -EINVAL;
  856. if (clocks == NULL)
  857. return -EINVAL;
  858. mutex_lock(&hwmgr->smu_lock);
  859. ret = phm_get_clock_by_type(hwmgr, type, clocks);
  860. mutex_unlock(&hwmgr->smu_lock);
  861. return ret;
  862. }
  863. static int pp_get_clock_by_type_with_latency(void *handle,
  864. enum amd_pp_clock_type type,
  865. struct pp_clock_levels_with_latency *clocks)
  866. {
  867. struct pp_hwmgr *hwmgr = handle;
  868. int ret = 0;
  869. if (!hwmgr || !hwmgr->pm_en ||!clocks)
  870. return -EINVAL;
  871. mutex_lock(&hwmgr->smu_lock);
  872. ret = phm_get_clock_by_type_with_latency(hwmgr, type, clocks);
  873. mutex_unlock(&hwmgr->smu_lock);
  874. return ret;
  875. }
  876. static int pp_get_clock_by_type_with_voltage(void *handle,
  877. enum amd_pp_clock_type type,
  878. struct pp_clock_levels_with_voltage *clocks)
  879. {
  880. struct pp_hwmgr *hwmgr = handle;
  881. int ret = 0;
  882. if (!hwmgr || !hwmgr->pm_en ||!clocks)
  883. return -EINVAL;
  884. mutex_lock(&hwmgr->smu_lock);
  885. ret = phm_get_clock_by_type_with_voltage(hwmgr, type, clocks);
  886. mutex_unlock(&hwmgr->smu_lock);
  887. return ret;
  888. }
  889. static int pp_set_watermarks_for_clocks_ranges(void *handle,
  890. void *clock_ranges)
  891. {
  892. struct pp_hwmgr *hwmgr = handle;
  893. int ret = 0;
  894. if (!hwmgr || !hwmgr->pm_en || !clock_ranges)
  895. return -EINVAL;
  896. mutex_lock(&hwmgr->smu_lock);
  897. ret = phm_set_watermarks_for_clocks_ranges(hwmgr,
  898. clock_ranges);
  899. mutex_unlock(&hwmgr->smu_lock);
  900. return ret;
  901. }
  902. static int pp_display_clock_voltage_request(void *handle,
  903. struct pp_display_clock_request *clock)
  904. {
  905. struct pp_hwmgr *hwmgr = handle;
  906. int ret = 0;
  907. if (!hwmgr || !hwmgr->pm_en ||!clock)
  908. return -EINVAL;
  909. mutex_lock(&hwmgr->smu_lock);
  910. ret = phm_display_clock_voltage_request(hwmgr, clock);
  911. mutex_unlock(&hwmgr->smu_lock);
  912. return ret;
  913. }
  914. static int pp_get_display_mode_validation_clocks(void *handle,
  915. struct amd_pp_simple_clock_info *clocks)
  916. {
  917. struct pp_hwmgr *hwmgr = handle;
  918. int ret = 0;
  919. if (!hwmgr || !hwmgr->pm_en ||!clocks)
  920. return -EINVAL;
  921. clocks->level = PP_DAL_POWERLEVEL_7;
  922. mutex_lock(&hwmgr->smu_lock);
  923. if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DynamicPatchPowerState))
  924. ret = phm_get_max_high_clocks(hwmgr, clocks);
  925. mutex_unlock(&hwmgr->smu_lock);
  926. return ret;
  927. }
  928. static int pp_dpm_powergate_mmhub(void *handle)
  929. {
  930. struct pp_hwmgr *hwmgr = handle;
  931. if (!hwmgr || !hwmgr->pm_en)
  932. return -EINVAL;
  933. if (hwmgr->hwmgr_func->powergate_mmhub == NULL) {
  934. pr_info("%s was not implemented.\n", __func__);
  935. return 0;
  936. }
  937. return hwmgr->hwmgr_func->powergate_mmhub(hwmgr);
  938. }
  939. static int pp_dpm_powergate_gfx(void *handle, bool gate)
  940. {
  941. struct pp_hwmgr *hwmgr = handle;
  942. if (!hwmgr || !hwmgr->pm_en)
  943. return 0;
  944. if (hwmgr->hwmgr_func->powergate_gfx == NULL) {
  945. pr_info("%s was not implemented.\n", __func__);
  946. return 0;
  947. }
  948. return hwmgr->hwmgr_func->powergate_gfx(hwmgr, gate);
  949. }
  950. static int pp_set_powergating_by_smu(void *handle,
  951. uint32_t block_type, bool gate)
  952. {
  953. int ret = 0;
  954. switch (block_type) {
  955. case AMD_IP_BLOCK_TYPE_UVD:
  956. case AMD_IP_BLOCK_TYPE_VCN:
  957. pp_dpm_powergate_uvd(handle, gate);
  958. break;
  959. case AMD_IP_BLOCK_TYPE_VCE:
  960. pp_dpm_powergate_vce(handle, gate);
  961. break;
  962. case AMD_IP_BLOCK_TYPE_GMC:
  963. pp_dpm_powergate_mmhub(handle);
  964. break;
  965. case AMD_IP_BLOCK_TYPE_GFX:
  966. ret = pp_dpm_powergate_gfx(handle, gate);
  967. break;
  968. default:
  969. break;
  970. }
  971. return ret;
  972. }
  973. static int pp_notify_smu_enable_pwe(void *handle)
  974. {
  975. struct pp_hwmgr *hwmgr = handle;
  976. if (!hwmgr || !hwmgr->pm_en)
  977. return -EINVAL;
  978. if (hwmgr->hwmgr_func->smus_notify_pwe == NULL) {
  979. pr_info("%s was not implemented.\n", __func__);
  980. return -EINVAL;;
  981. }
  982. mutex_lock(&hwmgr->smu_lock);
  983. hwmgr->hwmgr_func->smus_notify_pwe(hwmgr);
  984. mutex_unlock(&hwmgr->smu_lock);
  985. return 0;
  986. }
  987. static const struct amd_pm_funcs pp_dpm_funcs = {
  988. .load_firmware = pp_dpm_load_fw,
  989. .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,
  990. .force_performance_level = pp_dpm_force_performance_level,
  991. .get_performance_level = pp_dpm_get_performance_level,
  992. .get_current_power_state = pp_dpm_get_current_power_state,
  993. .dispatch_tasks = pp_dpm_dispatch_tasks,
  994. .set_fan_control_mode = pp_dpm_set_fan_control_mode,
  995. .get_fan_control_mode = pp_dpm_get_fan_control_mode,
  996. .set_fan_speed_percent = pp_dpm_set_fan_speed_percent,
  997. .get_fan_speed_percent = pp_dpm_get_fan_speed_percent,
  998. .get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm,
  999. .get_pp_num_states = pp_dpm_get_pp_num_states,
  1000. .get_pp_table = pp_dpm_get_pp_table,
  1001. .set_pp_table = pp_dpm_set_pp_table,
  1002. .force_clock_level = pp_dpm_force_clock_level,
  1003. .print_clock_levels = pp_dpm_print_clock_levels,
  1004. .get_sclk_od = pp_dpm_get_sclk_od,
  1005. .set_sclk_od = pp_dpm_set_sclk_od,
  1006. .get_mclk_od = pp_dpm_get_mclk_od,
  1007. .set_mclk_od = pp_dpm_set_mclk_od,
  1008. .read_sensor = pp_dpm_read_sensor,
  1009. .get_vce_clock_state = pp_dpm_get_vce_clock_state,
  1010. .switch_power_profile = pp_dpm_switch_power_profile,
  1011. .set_clockgating_by_smu = pp_set_clockgating_by_smu,
  1012. .set_powergating_by_smu = pp_set_powergating_by_smu,
  1013. .get_power_profile_mode = pp_get_power_profile_mode,
  1014. .set_power_profile_mode = pp_set_power_profile_mode,
  1015. .odn_edit_dpm_table = pp_odn_edit_dpm_table,
  1016. .set_power_limit = pp_set_power_limit,
  1017. .get_power_limit = pp_get_power_limit,
  1018. /* export to DC */
  1019. .get_sclk = pp_dpm_get_sclk,
  1020. .get_mclk = pp_dpm_get_mclk,
  1021. .display_configuration_change = pp_display_configuration_change,
  1022. .get_display_power_level = pp_get_display_power_level,
  1023. .get_current_clocks = pp_get_current_clocks,
  1024. .get_clock_by_type = pp_get_clock_by_type,
  1025. .get_clock_by_type_with_latency = pp_get_clock_by_type_with_latency,
  1026. .get_clock_by_type_with_voltage = pp_get_clock_by_type_with_voltage,
  1027. .set_watermarks_for_clocks_ranges = pp_set_watermarks_for_clocks_ranges,
  1028. .display_clock_voltage_request = pp_display_clock_voltage_request,
  1029. .get_display_mode_validation_clocks = pp_get_display_mode_validation_clocks,
  1030. .notify_smu_enable_pwe = pp_notify_smu_enable_pwe,
  1031. };