2 * Copyright 2019 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
23 #define SWSMU_CODE_LAYER_L1
25 #include <linux/firmware.h>
26 #include <linux/pci.h>
29 #include "amdgpu_smu.h"
30 #include "smu_internal.h"
32 #include "arcturus_ppt.h"
33 #include "navi10_ppt.h"
34 #include "sienna_cichlid_ppt.h"
35 #include "renoir_ppt.h"
39 * DO NOT use these for err/warn/info/debug messages.
40 * Use dev_err, dev_warn, dev_info and dev_dbg instead.
41 * They are more MGPU friendly.
48 size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)
52 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
55 mutex_lock(&smu->mutex);
57 size = smu_get_pp_feature_mask(smu, buf);
59 mutex_unlock(&smu->mutex);
64 int smu_sys_set_pp_feature_mask(struct smu_context *smu, uint64_t new_mask)
68 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
71 mutex_lock(&smu->mutex);
73 ret = smu_set_pp_feature_mask(smu, new_mask);
75 mutex_unlock(&smu->mutex);
80 int smu_get_status_gfxoff(struct amdgpu_device *adev, uint32_t *value)
83 struct smu_context *smu = &adev->smu;
85 if (is_support_sw_smu(adev) && smu->ppt_funcs->get_gfx_off_status)
86 *value = smu_get_gfx_off_status(smu);
93 int smu_set_soft_freq_range(struct smu_context *smu,
94 enum smu_clk_type clk_type,
100 mutex_lock(&smu->mutex);
102 if (smu->ppt_funcs->set_soft_freq_limited_range)
103 ret = smu->ppt_funcs->set_soft_freq_limited_range(smu,
108 mutex_unlock(&smu->mutex);
113 int smu_get_dpm_freq_range(struct smu_context *smu,
114 enum smu_clk_type clk_type,
123 mutex_lock(&smu->mutex);
125 if (smu->ppt_funcs->get_dpm_ultimate_freq)
126 ret = smu->ppt_funcs->get_dpm_ultimate_freq(smu,
131 mutex_unlock(&smu->mutex);
136 static int smu_dpm_set_vcn_enable_locked(struct smu_context *smu,
139 struct smu_power_context *smu_power = &smu->smu_power;
140 struct smu_power_gate *power_gate = &smu_power->power_gate;
143 if (!smu->ppt_funcs->dpm_set_vcn_enable)
146 if (atomic_read(&power_gate->vcn_gated) ^ enable)
149 ret = smu->ppt_funcs->dpm_set_vcn_enable(smu, enable);
151 atomic_set(&power_gate->vcn_gated, !enable);
156 static int smu_dpm_set_vcn_enable(struct smu_context *smu,
159 struct smu_power_context *smu_power = &smu->smu_power;
160 struct smu_power_gate *power_gate = &smu_power->power_gate;
163 mutex_lock(&power_gate->vcn_gate_lock);
165 ret = smu_dpm_set_vcn_enable_locked(smu, enable);
167 mutex_unlock(&power_gate->vcn_gate_lock);
172 static int smu_dpm_set_jpeg_enable_locked(struct smu_context *smu,
175 struct smu_power_context *smu_power = &smu->smu_power;
176 struct smu_power_gate *power_gate = &smu_power->power_gate;
179 if (!smu->ppt_funcs->dpm_set_jpeg_enable)
182 if (atomic_read(&power_gate->jpeg_gated) ^ enable)
185 ret = smu->ppt_funcs->dpm_set_jpeg_enable(smu, enable);
187 atomic_set(&power_gate->jpeg_gated, !enable);
192 static int smu_dpm_set_jpeg_enable(struct smu_context *smu,
195 struct smu_power_context *smu_power = &smu->smu_power;
196 struct smu_power_gate *power_gate = &smu_power->power_gate;
199 mutex_lock(&power_gate->jpeg_gate_lock);
201 ret = smu_dpm_set_jpeg_enable_locked(smu, enable);
203 mutex_unlock(&power_gate->jpeg_gate_lock);
209 * smu_dpm_set_power_gate - power gate/ungate the specific IP block
211 * @smu: smu_context pointer
212 * @block_type: the IP block to power gate/ungate
213 * @gate: to power gate if true, ungate otherwise
215 * This API uses no smu->mutex lock protection due to:
216 * 1. It is either called by other IP block(gfx/sdma/vcn/uvd/vce).
217 * This is guarded to be race condition free by the caller.
218 * 2. Or get called on user setting request of power_dpm_force_performance_level.
219 * Under this case, the smu->mutex lock protection is already enforced on
220 * the parent API smu_force_performance_level of the call path.
222 int smu_dpm_set_power_gate(struct smu_context *smu, uint32_t block_type,
227 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
230 switch (block_type) {
232 * Some legacy code of amdgpu_vcn.c and vcn_v2*.c still uses
233 * AMD_IP_BLOCK_TYPE_UVD for VCN. So, here both of them are kept.
235 case AMD_IP_BLOCK_TYPE_UVD:
236 case AMD_IP_BLOCK_TYPE_VCN:
237 ret = smu_dpm_set_vcn_enable(smu, !gate);
239 dev_err(smu->adev->dev, "Failed to power %s VCN!\n",
240 gate ? "gate" : "ungate");
242 case AMD_IP_BLOCK_TYPE_GFX:
243 ret = smu_gfx_off_control(smu, gate);
245 dev_err(smu->adev->dev, "Failed to %s gfxoff!\n",
246 gate ? "enable" : "disable");
248 case AMD_IP_BLOCK_TYPE_SDMA:
249 ret = smu_powergate_sdma(smu, gate);
251 dev_err(smu->adev->dev, "Failed to power %s SDMA!\n",
252 gate ? "gate" : "ungate");
254 case AMD_IP_BLOCK_TYPE_JPEG:
255 ret = smu_dpm_set_jpeg_enable(smu, !gate);
257 dev_err(smu->adev->dev, "Failed to power %s JPEG!\n",
258 gate ? "gate" : "ungate");
261 dev_err(smu->adev->dev, "Unsupported block type!\n");
268 int smu_get_power_num_states(struct smu_context *smu,
269 struct pp_states_info *state_info)
274 /* not support power state */
275 memset(state_info, 0, sizeof(struct pp_states_info));
276 state_info->nums = 1;
277 state_info->states[0] = POWER_STATE_TYPE_DEFAULT;
282 bool is_support_sw_smu(struct amdgpu_device *adev)
284 if (adev->asic_type >= CHIP_ARCTURUS)
290 int smu_sys_get_pp_table(struct smu_context *smu, void **table)
292 struct smu_table_context *smu_table = &smu->smu_table;
293 uint32_t powerplay_table_size;
295 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
298 if (!smu_table->power_play_table && !smu_table->hardcode_pptable)
301 mutex_lock(&smu->mutex);
303 if (smu_table->hardcode_pptable)
304 *table = smu_table->hardcode_pptable;
306 *table = smu_table->power_play_table;
308 powerplay_table_size = smu_table->power_play_table_size;
310 mutex_unlock(&smu->mutex);
312 return powerplay_table_size;
315 int smu_sys_set_pp_table(struct smu_context *smu, void *buf, size_t size)
317 struct smu_table_context *smu_table = &smu->smu_table;
318 ATOM_COMMON_TABLE_HEADER *header = (ATOM_COMMON_TABLE_HEADER *)buf;
321 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
324 if (header->usStructureSize != size) {
325 dev_err(smu->adev->dev, "pp table size not matched !\n");
329 mutex_lock(&smu->mutex);
330 if (!smu_table->hardcode_pptable)
331 smu_table->hardcode_pptable = kzalloc(size, GFP_KERNEL);
332 if (!smu_table->hardcode_pptable) {
337 memcpy(smu_table->hardcode_pptable, buf, size);
338 smu_table->power_play_table = smu_table->hardcode_pptable;
339 smu_table->power_play_table_size = size;
342 * Special hw_fini action(for Navi1x, the DPMs disablement will be
343 * skipped) may be needed for custom pptable uploading.
345 smu->uploading_custom_pp_table = true;
347 ret = smu_reset(smu);
349 dev_info(smu->adev->dev, "smu reset failed, ret = %d\n", ret);
351 smu->uploading_custom_pp_table = false;
354 mutex_unlock(&smu->mutex);
358 static int smu_get_driver_allowed_feature_mask(struct smu_context *smu)
360 struct smu_feature *feature = &smu->smu_feature;
362 uint32_t allowed_feature_mask[SMU_FEATURE_MAX/32];
364 bitmap_zero(feature->allowed, SMU_FEATURE_MAX);
366 ret = smu_get_allowed_feature_mask(smu, allowed_feature_mask,
371 bitmap_or(feature->allowed, feature->allowed,
372 (unsigned long *)allowed_feature_mask,
373 feature->feature_num);
378 static int smu_set_funcs(struct amdgpu_device *adev)
380 struct smu_context *smu = &adev->smu;
382 if (adev->pm.pp_feature & PP_OVERDRIVE_MASK)
383 smu->od_enabled = true;
385 switch (adev->asic_type) {
389 navi10_set_ppt_funcs(smu);
392 adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
393 arcturus_set_ppt_funcs(smu);
394 /* OD is not supported on Arcturus */
395 smu->od_enabled =false;
397 case CHIP_SIENNA_CICHLID:
398 case CHIP_NAVY_FLOUNDER:
399 sienna_cichlid_set_ppt_funcs(smu);
402 renoir_set_ppt_funcs(smu);
411 static int smu_early_init(void *handle)
413 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
414 struct smu_context *smu = &adev->smu;
417 smu->pm_enabled = !!amdgpu_dpm;
419 mutex_init(&smu->mutex);
421 return smu_set_funcs(adev);
424 static int smu_set_default_dpm_table(struct smu_context *smu)
426 struct smu_power_context *smu_power = &smu->smu_power;
427 struct smu_power_gate *power_gate = &smu_power->power_gate;
428 int vcn_gate, jpeg_gate;
431 if (!smu->ppt_funcs->set_default_dpm_table)
434 mutex_lock(&power_gate->vcn_gate_lock);
435 mutex_lock(&power_gate->jpeg_gate_lock);
437 vcn_gate = atomic_read(&power_gate->vcn_gated);
438 jpeg_gate = atomic_read(&power_gate->jpeg_gated);
440 ret = smu_dpm_set_vcn_enable_locked(smu, true);
444 ret = smu_dpm_set_jpeg_enable_locked(smu, true);
448 ret = smu->ppt_funcs->set_default_dpm_table(smu);
450 dev_err(smu->adev->dev,
451 "Failed to setup default dpm clock tables!\n");
453 smu_dpm_set_jpeg_enable_locked(smu, !jpeg_gate);
455 smu_dpm_set_vcn_enable_locked(smu, !vcn_gate);
457 mutex_unlock(&power_gate->jpeg_gate_lock);
458 mutex_unlock(&power_gate->vcn_gate_lock);
463 static int smu_late_init(void *handle)
465 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
466 struct smu_context *smu = &adev->smu;
469 if (!smu->pm_enabled)
472 ret = smu_post_init(smu);
474 dev_err(adev->dev, "Failed to post smu init!\n");
478 ret = smu_set_default_od_settings(smu);
480 dev_err(adev->dev, "Failed to setup default OD settings!\n");
484 ret = smu_populate_umd_state_clk(smu);
486 dev_err(adev->dev, "Failed to populate UMD state clocks!\n");
490 ret = smu_get_asic_power_limits(smu);
492 dev_err(adev->dev, "Failed to get asic power limits!\n");
496 smu_get_unique_id(smu);
498 smu_get_fan_parameters(smu);
500 smu_handle_task(&adev->smu,
501 smu->smu_dpm.dpm_level,
502 AMD_PP_TASK_COMPLETE_INIT,
508 static int smu_init_fb_allocations(struct smu_context *smu)
510 struct amdgpu_device *adev = smu->adev;
511 struct smu_table_context *smu_table = &smu->smu_table;
512 struct smu_table *tables = smu_table->tables;
513 struct smu_table *driver_table = &(smu_table->driver_table);
514 uint32_t max_table_size = 0;
517 /* VRAM allocation for tool table */
518 if (tables[SMU_TABLE_PMSTATUSLOG].size) {
519 ret = amdgpu_bo_create_kernel(adev,
520 tables[SMU_TABLE_PMSTATUSLOG].size,
521 tables[SMU_TABLE_PMSTATUSLOG].align,
522 tables[SMU_TABLE_PMSTATUSLOG].domain,
523 &tables[SMU_TABLE_PMSTATUSLOG].bo,
524 &tables[SMU_TABLE_PMSTATUSLOG].mc_address,
525 &tables[SMU_TABLE_PMSTATUSLOG].cpu_addr);
527 dev_err(adev->dev, "VRAM allocation for tool table failed!\n");
532 /* VRAM allocation for driver table */
533 for (i = 0; i < SMU_TABLE_COUNT; i++) {
534 if (tables[i].size == 0)
537 if (i == SMU_TABLE_PMSTATUSLOG)
540 if (max_table_size < tables[i].size)
541 max_table_size = tables[i].size;
544 driver_table->size = max_table_size;
545 driver_table->align = PAGE_SIZE;
546 driver_table->domain = AMDGPU_GEM_DOMAIN_VRAM;
548 ret = amdgpu_bo_create_kernel(adev,
551 driver_table->domain,
553 &driver_table->mc_address,
554 &driver_table->cpu_addr);
556 dev_err(adev->dev, "VRAM allocation for driver table failed!\n");
557 if (tables[SMU_TABLE_PMSTATUSLOG].mc_address)
558 amdgpu_bo_free_kernel(&tables[SMU_TABLE_PMSTATUSLOG].bo,
559 &tables[SMU_TABLE_PMSTATUSLOG].mc_address,
560 &tables[SMU_TABLE_PMSTATUSLOG].cpu_addr);
566 static int smu_fini_fb_allocations(struct smu_context *smu)
568 struct smu_table_context *smu_table = &smu->smu_table;
569 struct smu_table *tables = smu_table->tables;
570 struct smu_table *driver_table = &(smu_table->driver_table);
572 if (tables[SMU_TABLE_PMSTATUSLOG].mc_address)
573 amdgpu_bo_free_kernel(&tables[SMU_TABLE_PMSTATUSLOG].bo,
574 &tables[SMU_TABLE_PMSTATUSLOG].mc_address,
575 &tables[SMU_TABLE_PMSTATUSLOG].cpu_addr);
577 amdgpu_bo_free_kernel(&driver_table->bo,
578 &driver_table->mc_address,
579 &driver_table->cpu_addr);
585 * smu_alloc_memory_pool - allocate memory pool in the system memory
587 * @smu: amdgpu_device pointer
589 * This memory pool will be used for SMC use and msg SetSystemVirtualDramAddr
590 * and DramLogSetDramAddr can notify it changed.
592 * Returns 0 on success, error on failure.
594 static int smu_alloc_memory_pool(struct smu_context *smu)
596 struct amdgpu_device *adev = smu->adev;
597 struct smu_table_context *smu_table = &smu->smu_table;
598 struct smu_table *memory_pool = &smu_table->memory_pool;
599 uint64_t pool_size = smu->pool_size;
602 if (pool_size == SMU_MEMORY_POOL_SIZE_ZERO)
605 memory_pool->size = pool_size;
606 memory_pool->align = PAGE_SIZE;
607 memory_pool->domain = AMDGPU_GEM_DOMAIN_GTT;
610 case SMU_MEMORY_POOL_SIZE_256_MB:
611 case SMU_MEMORY_POOL_SIZE_512_MB:
612 case SMU_MEMORY_POOL_SIZE_1_GB:
613 case SMU_MEMORY_POOL_SIZE_2_GB:
614 ret = amdgpu_bo_create_kernel(adev,
619 &memory_pool->mc_address,
620 &memory_pool->cpu_addr);
622 dev_err(adev->dev, "VRAM allocation for dramlog failed!\n");
631 static int smu_free_memory_pool(struct smu_context *smu)
633 struct smu_table_context *smu_table = &smu->smu_table;
634 struct smu_table *memory_pool = &smu_table->memory_pool;
636 if (memory_pool->size == SMU_MEMORY_POOL_SIZE_ZERO)
639 amdgpu_bo_free_kernel(&memory_pool->bo,
640 &memory_pool->mc_address,
641 &memory_pool->cpu_addr);
643 memset(memory_pool, 0, sizeof(struct smu_table));
648 static int smu_alloc_dummy_read_table(struct smu_context *smu)
650 struct smu_table_context *smu_table = &smu->smu_table;
651 struct smu_table *dummy_read_1_table =
652 &smu_table->dummy_read_1_table;
653 struct amdgpu_device *adev = smu->adev;
656 dummy_read_1_table->size = 0x40000;
657 dummy_read_1_table->align = PAGE_SIZE;
658 dummy_read_1_table->domain = AMDGPU_GEM_DOMAIN_VRAM;
660 ret = amdgpu_bo_create_kernel(adev,
661 dummy_read_1_table->size,
662 dummy_read_1_table->align,
663 dummy_read_1_table->domain,
664 &dummy_read_1_table->bo,
665 &dummy_read_1_table->mc_address,
666 &dummy_read_1_table->cpu_addr);
668 dev_err(adev->dev, "VRAM allocation for dummy read table failed!\n");
673 static void smu_free_dummy_read_table(struct smu_context *smu)
675 struct smu_table_context *smu_table = &smu->smu_table;
676 struct smu_table *dummy_read_1_table =
677 &smu_table->dummy_read_1_table;
680 amdgpu_bo_free_kernel(&dummy_read_1_table->bo,
681 &dummy_read_1_table->mc_address,
682 &dummy_read_1_table->cpu_addr);
684 memset(dummy_read_1_table, 0, sizeof(struct smu_table));
687 static int smu_smc_table_sw_init(struct smu_context *smu)
692 * Create smu_table structure, and init smc tables such as
693 * TABLE_PPTABLE, TABLE_WATERMARKS, TABLE_SMU_METRICS, and etc.
695 ret = smu_init_smc_tables(smu);
697 dev_err(smu->adev->dev, "Failed to init smc tables!\n");
702 * Create smu_power_context structure, and allocate smu_dpm_context and
703 * context size to fill the smu_power_context data.
705 ret = smu_init_power(smu);
707 dev_err(smu->adev->dev, "Failed to init smu_init_power!\n");
712 * allocate vram bos to store smc table contents.
714 ret = smu_init_fb_allocations(smu);
718 ret = smu_alloc_memory_pool(smu);
722 ret = smu_alloc_dummy_read_table(smu);
726 ret = smu_i2c_init(smu, &smu->adev->pm.smu_i2c);
733 static int smu_smc_table_sw_fini(struct smu_context *smu)
737 smu_i2c_fini(smu, &smu->adev->pm.smu_i2c);
739 smu_free_dummy_read_table(smu);
741 ret = smu_free_memory_pool(smu);
745 ret = smu_fini_fb_allocations(smu);
749 ret = smu_fini_power(smu);
751 dev_err(smu->adev->dev, "Failed to init smu_fini_power!\n");
755 ret = smu_fini_smc_tables(smu);
757 dev_err(smu->adev->dev, "Failed to smu_fini_smc_tables!\n");
764 static void smu_throttling_logging_work_fn(struct work_struct *work)
766 struct smu_context *smu = container_of(work, struct smu_context,
767 throttling_logging_work);
769 smu_log_thermal_throttling(smu);
772 static void smu_interrupt_work_fn(struct work_struct *work)
774 struct smu_context *smu = container_of(work, struct smu_context,
777 mutex_lock(&smu->mutex);
779 if (smu->ppt_funcs && smu->ppt_funcs->interrupt_work)
780 smu->ppt_funcs->interrupt_work(smu);
782 mutex_unlock(&smu->mutex);
785 static int smu_sw_init(void *handle)
787 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
788 struct smu_context *smu = &adev->smu;
791 smu->pool_size = adev->pm.smu_prv_buffer_size;
792 smu->smu_feature.feature_num = SMU_FEATURE_MAX;
793 mutex_init(&smu->smu_feature.mutex);
794 bitmap_zero(smu->smu_feature.supported, SMU_FEATURE_MAX);
795 bitmap_zero(smu->smu_feature.enabled, SMU_FEATURE_MAX);
796 bitmap_zero(smu->smu_feature.allowed, SMU_FEATURE_MAX);
798 mutex_init(&smu->smu_baco.mutex);
799 smu->smu_baco.state = SMU_BACO_STATE_EXIT;
800 smu->smu_baco.platform_support = false;
802 mutex_init(&smu->sensor_lock);
803 mutex_init(&smu->metrics_lock);
804 mutex_init(&smu->message_lock);
806 INIT_WORK(&smu->throttling_logging_work, smu_throttling_logging_work_fn);
807 INIT_WORK(&smu->interrupt_work, smu_interrupt_work_fn);
808 atomic64_set(&smu->throttle_int_counter, 0);
809 smu->watermarks_bitmap = 0;
810 smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
811 smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
813 atomic_set(&smu->smu_power.power_gate.vcn_gated, 1);
814 atomic_set(&smu->smu_power.power_gate.jpeg_gated, 1);
815 mutex_init(&smu->smu_power.power_gate.vcn_gate_lock);
816 mutex_init(&smu->smu_power.power_gate.jpeg_gate_lock);
818 smu->workload_mask = 1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT];
819 smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT] = 0;
820 smu->workload_prority[PP_SMC_POWER_PROFILE_FULLSCREEN3D] = 1;
821 smu->workload_prority[PP_SMC_POWER_PROFILE_POWERSAVING] = 2;
822 smu->workload_prority[PP_SMC_POWER_PROFILE_VIDEO] = 3;
823 smu->workload_prority[PP_SMC_POWER_PROFILE_VR] = 4;
824 smu->workload_prority[PP_SMC_POWER_PROFILE_COMPUTE] = 5;
825 smu->workload_prority[PP_SMC_POWER_PROFILE_CUSTOM] = 6;
827 smu->workload_setting[0] = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
828 smu->workload_setting[1] = PP_SMC_POWER_PROFILE_FULLSCREEN3D;
829 smu->workload_setting[2] = PP_SMC_POWER_PROFILE_POWERSAVING;
830 smu->workload_setting[3] = PP_SMC_POWER_PROFILE_VIDEO;
831 smu->workload_setting[4] = PP_SMC_POWER_PROFILE_VR;
832 smu->workload_setting[5] = PP_SMC_POWER_PROFILE_COMPUTE;
833 smu->workload_setting[6] = PP_SMC_POWER_PROFILE_CUSTOM;
834 smu->display_config = &adev->pm.pm_display_cfg;
836 smu->smu_dpm.dpm_level = AMD_DPM_FORCED_LEVEL_AUTO;
837 smu->smu_dpm.requested_dpm_level = AMD_DPM_FORCED_LEVEL_AUTO;
839 if (!amdgpu_sriov_vf(adev)) {
840 ret = smu_init_microcode(smu);
842 dev_err(adev->dev, "Failed to load smu firmware!\n");
847 ret = smu_smc_table_sw_init(smu);
849 dev_err(adev->dev, "Failed to sw init smc table!\n");
853 ret = smu_register_irq_handler(smu);
855 dev_err(adev->dev, "Failed to register smc irq handler!\n");
862 static int smu_sw_fini(void *handle)
864 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
865 struct smu_context *smu = &adev->smu;
868 ret = smu_smc_table_sw_fini(smu);
870 dev_err(adev->dev, "Failed to sw fini smc table!\n");
874 smu_fini_microcode(smu);
879 static int smu_get_thermal_temperature_range(struct smu_context *smu)
881 struct amdgpu_device *adev = smu->adev;
882 struct smu_temperature_range *range =
886 if (!smu->ppt_funcs->get_thermal_temperature_range)
889 ret = smu->ppt_funcs->get_thermal_temperature_range(smu, range);
893 adev->pm.dpm.thermal.min_temp = range->min;
894 adev->pm.dpm.thermal.max_temp = range->max;
895 adev->pm.dpm.thermal.max_edge_emergency_temp = range->edge_emergency_max;
896 adev->pm.dpm.thermal.min_hotspot_temp = range->hotspot_min;
897 adev->pm.dpm.thermal.max_hotspot_crit_temp = range->hotspot_crit_max;
898 adev->pm.dpm.thermal.max_hotspot_emergency_temp = range->hotspot_emergency_max;
899 adev->pm.dpm.thermal.min_mem_temp = range->mem_min;
900 adev->pm.dpm.thermal.max_mem_crit_temp = range->mem_crit_max;
901 adev->pm.dpm.thermal.max_mem_emergency_temp = range->mem_emergency_max;
906 static int smu_smc_hw_setup(struct smu_context *smu)
908 struct amdgpu_device *adev = smu->adev;
909 uint32_t pcie_gen = 0, pcie_width = 0;
912 if (adev->in_suspend && smu_is_dpm_running(smu)) {
913 dev_info(adev->dev, "dpm has been enabled\n");
917 ret = smu_init_display_count(smu, 0);
919 dev_info(adev->dev, "Failed to pre-set display count as 0!\n");
923 ret = smu_set_driver_table_location(smu);
925 dev_err(adev->dev, "Failed to SetDriverDramAddr!\n");
930 * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools.
932 ret = smu_set_tool_table_location(smu);
934 dev_err(adev->dev, "Failed to SetToolsDramAddr!\n");
939 * Use msg SetSystemVirtualDramAddr and DramLogSetDramAddr can notify
942 ret = smu_notify_memory_pool_location(smu);
944 dev_err(adev->dev, "Failed to SetDramLogDramAddr!\n");
948 /* smu_dump_pptable(smu); */
950 * Copy pptable bo in the vram to smc with SMU MSGs such as
951 * SetDriverDramAddr and TransferTableDram2Smu.
953 ret = smu_write_pptable(smu);
955 dev_err(adev->dev, "Failed to transfer pptable to SMC!\n");
959 /* issue Run*Btc msg */
960 ret = smu_run_btc(smu);
964 ret = smu_feature_set_allowed_mask(smu);
966 dev_err(adev->dev, "Failed to set driver allowed features mask!\n");
970 ret = smu_system_features_control(smu, true);
972 dev_err(adev->dev, "Failed to enable requested dpm features!\n");
976 if (!smu_is_dpm_running(smu))
977 dev_info(adev->dev, "dpm has been disabled\n");
979 if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4)
981 else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)
983 else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2)
985 else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1)
988 /* Bit 31:16: LCLK DPM level. 0 is DPM0, and 1 is DPM1
989 * Bit 15:8: PCIE GEN, 0 to 3 corresponds to GEN1 to GEN4
990 * Bit 7:0: PCIE lane width, 1 to 7 corresponds is x1 to x32
992 if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X16)
994 else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X12)
996 else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X8)
998 else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X4)
1000 else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X2)
1002 else if (adev->pm.pcie_mlw_mask & CAIL_PCIE_LINK_WIDTH_SUPPORT_X1)
1004 ret = smu_update_pcie_parameters(smu, pcie_gen, pcie_width);
1006 dev_err(adev->dev, "Attempt to override pcie params failed!\n");
1010 ret = smu_get_thermal_temperature_range(smu);
1012 dev_err(adev->dev, "Failed to get thermal temperature ranges!\n");
1016 ret = smu_enable_thermal_alert(smu);
1018 dev_err(adev->dev, "Failed to enable thermal alert!\n");
1023 * Set initialized values (get from vbios) to dpm tables context such as
1024 * gfxclk, memclk, dcefclk, and etc. And enable the DPM feature for each
1027 ret = smu_set_default_dpm_table(smu);
1029 dev_err(adev->dev, "Failed to setup default dpm clock tables!\n");
1034 * Set initialized values (get from vbios) to dpm tables context such as
1035 * gfxclk, memclk, dcefclk, and etc. And enable the DPM feature for each
1038 ret = smu_set_default_dpm_table(smu);
1040 dev_err(adev->dev, "Failed to setup default dpm clock tables!\n");
1044 ret = smu_notify_display_change(smu);
1049 * Set min deep sleep dce fclk with bootup value from vbios via
1050 * SetMinDeepSleepDcefclk MSG.
1052 ret = smu_set_min_dcef_deep_sleep(smu,
1053 smu->smu_table.boot_values.dcefclk / 100);
1060 static int smu_start_smc_engine(struct smu_context *smu)
1062 struct amdgpu_device *adev = smu->adev;
1065 if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
1066 if (adev->asic_type < CHIP_NAVI10) {
1067 if (smu->ppt_funcs->load_microcode) {
1068 ret = smu->ppt_funcs->load_microcode(smu);
1075 if (smu->ppt_funcs->check_fw_status) {
1076 ret = smu->ppt_funcs->check_fw_status(smu);
1078 dev_err(adev->dev, "SMC is not ready\n");
1084 * Send msg GetDriverIfVersion to check if the return value is equal
1085 * with DRIVER_IF_VERSION of smc header.
1087 ret = smu_check_fw_version(smu);
1094 static int smu_hw_init(void *handle)
1097 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1098 struct smu_context *smu = &adev->smu;
1100 if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)) {
1101 smu->pm_enabled = false;
1105 ret = smu_start_smc_engine(smu);
1107 dev_err(adev->dev, "SMC engine is not correctly up!\n");
1112 smu_powergate_sdma(&adev->smu, false);
1113 smu_dpm_set_vcn_enable(smu, true);
1114 smu_dpm_set_jpeg_enable(smu, true);
1115 smu_set_gfx_cgpg(&adev->smu, true);
1118 if (!smu->pm_enabled)
1121 /* get boot_values from vbios to set revision, gfxclk, and etc. */
1122 ret = smu_get_vbios_bootup_values(smu);
1124 dev_err(adev->dev, "Failed to get VBIOS boot clock values!\n");
1128 ret = smu_setup_pptable(smu);
1130 dev_err(adev->dev, "Failed to setup pptable!\n");
1134 ret = smu_get_driver_allowed_feature_mask(smu);
1138 ret = smu_smc_hw_setup(smu);
1140 dev_err(adev->dev, "Failed to setup smc hw!\n");
1145 * Move maximum sustainable clock retrieving here considering
1146 * 1. It is not needed on resume(from S3).
1147 * 2. DAL settings come between .hw_init and .late_init of SMU.
1148 * And DAL needs to know the maximum sustainable clocks. Thus
1149 * it cannot be put in .late_init().
1151 ret = smu_init_max_sustainable_clocks(smu);
1153 dev_err(adev->dev, "Failed to init max sustainable clocks!\n");
1157 adev->pm.dpm_enabled = true;
1159 dev_info(adev->dev, "SMU is initialized successfully!\n");
1164 static int smu_disable_dpms(struct smu_context *smu)
1166 struct amdgpu_device *adev = smu->adev;
1168 bool use_baco = !smu->is_apu &&
1169 ((amdgpu_in_reset(adev) &&
1170 (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)) ||
1171 ((adev->in_runpm || adev->in_hibernate) && amdgpu_asic_supports_baco(adev)));
1174 * For custom pptable uploading, skip the DPM features
1175 * disable process on Navi1x ASICs.
1176 * - As the gfx related features are under control of
1177 * RLC on those ASICs. RLC reinitialization will be
1178 * needed to reenable them. That will cost much more
1181 * - SMU firmware can handle the DPM reenablement
1184 if (smu->uploading_custom_pp_table &&
1185 (adev->asic_type >= CHIP_NAVI10) &&
1186 (adev->asic_type <= CHIP_NAVY_FLOUNDER))
1190 * For Sienna_Cichlid, PMFW will handle the features disablement properly
1191 * on BACO in. Driver involvement is unnecessary.
1193 if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&
1198 * For gpu reset, runpm and hibernation through BACO,
1199 * BACO feature has to be kept enabled.
1201 if (use_baco && smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT)) {
1202 ret = smu_disable_all_features_with_exception(smu,
1203 SMU_FEATURE_BACO_BIT);
1205 dev_err(adev->dev, "Failed to disable smu features except BACO.\n");
1207 ret = smu_system_features_control(smu, false);
1209 dev_err(adev->dev, "Failed to disable smu features.\n");
1212 if (adev->asic_type >= CHIP_NAVI10 &&
1213 adev->gfx.rlc.funcs->stop)
1214 adev->gfx.rlc.funcs->stop(adev);
1219 static int smu_smc_hw_cleanup(struct smu_context *smu)
1221 struct amdgpu_device *adev = smu->adev;
1224 cancel_work_sync(&smu->throttling_logging_work);
1225 cancel_work_sync(&smu->interrupt_work);
1227 ret = smu_disable_thermal_alert(smu);
1229 dev_err(adev->dev, "Fail to disable thermal alert!\n");
1233 ret = smu_disable_dpms(smu);
1235 dev_err(adev->dev, "Fail to disable dpm features!\n");
1242 static int smu_hw_fini(void *handle)
1244 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1245 struct smu_context *smu = &adev->smu;
1247 if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
1251 smu_powergate_sdma(&adev->smu, true);
1252 smu_dpm_set_vcn_enable(smu, false);
1253 smu_dpm_set_jpeg_enable(smu, false);
1256 if (!smu->pm_enabled)
1259 adev->pm.dpm_enabled = false;
1261 return smu_smc_hw_cleanup(smu);
1264 int smu_reset(struct smu_context *smu)
1266 struct amdgpu_device *adev = smu->adev;
1269 amdgpu_gfx_off_ctrl(smu->adev, false);
1271 ret = smu_hw_fini(adev);
1275 ret = smu_hw_init(adev);
1279 ret = smu_late_init(adev);
1283 amdgpu_gfx_off_ctrl(smu->adev, true);
1288 static int smu_suspend(void *handle)
1290 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1291 struct smu_context *smu = &adev->smu;
1294 if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
1297 if (!smu->pm_enabled)
1300 adev->pm.dpm_enabled = false;
1302 ret = smu_smc_hw_cleanup(smu);
1306 smu->watermarks_bitmap &= ~(WATERMARKS_LOADED);
1309 smu_set_gfx_cgpg(&adev->smu, false);
1314 static int smu_resume(void *handle)
1317 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1318 struct smu_context *smu = &adev->smu;
1320 if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
1323 if (!smu->pm_enabled)
1326 dev_info(adev->dev, "SMU is resuming...\n");
1328 ret = smu_start_smc_engine(smu);
1330 dev_err(adev->dev, "SMC engine is not correctly up!\n");
1334 ret = smu_smc_hw_setup(smu);
1336 dev_err(adev->dev, "Failed to setup smc hw!\n");
1341 smu_set_gfx_cgpg(&adev->smu, true);
1343 smu->disable_uclk_switch = 0;
1345 adev->pm.dpm_enabled = true;
1347 dev_info(adev->dev, "SMU is resumed successfully!\n");
1352 int smu_display_configuration_change(struct smu_context *smu,
1353 const struct amd_pp_display_configuration *display_config)
1356 int num_of_active_display = 0;
1358 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1361 if (!display_config)
1364 mutex_lock(&smu->mutex);
1366 smu_set_min_dcef_deep_sleep(smu,
1367 display_config->min_dcef_deep_sleep_set_clk / 100);
1369 for (index = 0; index < display_config->num_path_including_non_display; index++) {
1370 if (display_config->displays[index].controller_id != 0)
1371 num_of_active_display++;
1374 smu_set_active_display_count(smu, num_of_active_display);
1376 smu_store_cc6_data(smu, display_config->cpu_pstate_separation_time,
1377 display_config->cpu_cc6_disable,
1378 display_config->cpu_pstate_disable,
1379 display_config->nb_pstate_switch_disable);
1381 mutex_unlock(&smu->mutex);
1386 static int smu_get_clock_info(struct smu_context *smu,
1387 struct smu_clock_info *clk_info,
1388 enum smu_perf_level_designation designation)
1391 struct smu_performance_level level = {0};
1396 ret = smu_get_perf_level(smu, PERF_LEVEL_ACTIVITY, &level);
1400 clk_info->min_mem_clk = level.memory_clock;
1401 clk_info->min_eng_clk = level.core_clock;
1402 clk_info->min_bus_bandwidth = level.non_local_mem_freq * level.non_local_mem_width;
1404 ret = smu_get_perf_level(smu, designation, &level);
1408 clk_info->min_mem_clk = level.memory_clock;
1409 clk_info->min_eng_clk = level.core_clock;
1410 clk_info->min_bus_bandwidth = level.non_local_mem_freq * level.non_local_mem_width;
1415 int smu_get_current_clocks(struct smu_context *smu,
1416 struct amd_pp_clock_info *clocks)
1418 struct amd_pp_simple_clock_info simple_clocks = {0};
1419 struct smu_clock_info hw_clocks;
1422 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1425 mutex_lock(&smu->mutex);
1427 smu_get_dal_power_level(smu, &simple_clocks);
1429 if (smu->support_power_containment)
1430 ret = smu_get_clock_info(smu, &hw_clocks,
1431 PERF_LEVEL_POWER_CONTAINMENT);
1433 ret = smu_get_clock_info(smu, &hw_clocks, PERF_LEVEL_ACTIVITY);
1436 dev_err(smu->adev->dev, "Error in smu_get_clock_info\n");
1440 clocks->min_engine_clock = hw_clocks.min_eng_clk;
1441 clocks->max_engine_clock = hw_clocks.max_eng_clk;
1442 clocks->min_memory_clock = hw_clocks.min_mem_clk;
1443 clocks->max_memory_clock = hw_clocks.max_mem_clk;
1444 clocks->min_bus_bandwidth = hw_clocks.min_bus_bandwidth;
1445 clocks->max_bus_bandwidth = hw_clocks.max_bus_bandwidth;
1446 clocks->max_engine_clock_in_sr = hw_clocks.max_eng_clk;
1447 clocks->min_engine_clock_in_sr = hw_clocks.min_eng_clk;
1449 if (simple_clocks.level == 0)
1450 clocks->max_clocks_state = PP_DAL_POWERLEVEL_7;
1452 clocks->max_clocks_state = simple_clocks.level;
1454 if (!smu_get_current_shallow_sleep_clocks(smu, &hw_clocks)) {
1455 clocks->max_engine_clock_in_sr = hw_clocks.max_eng_clk;
1456 clocks->min_engine_clock_in_sr = hw_clocks.min_eng_clk;
1460 mutex_unlock(&smu->mutex);
1464 static int smu_set_clockgating_state(void *handle,
1465 enum amd_clockgating_state state)
1470 static int smu_set_powergating_state(void *handle,
1471 enum amd_powergating_state state)
1476 static int smu_enable_umd_pstate(void *handle,
1477 enum amd_dpm_forced_level *level)
1479 uint32_t profile_mode_mask = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD |
1480 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK |
1481 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK |
1482 AMD_DPM_FORCED_LEVEL_PROFILE_PEAK;
1484 struct smu_context *smu = (struct smu_context*)(handle);
1485 struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
1487 if (!smu->is_apu && !smu_dpm_ctx->dpm_context)
1490 if (!(smu_dpm_ctx->dpm_level & profile_mode_mask)) {
1491 /* enter umd pstate, save current level, disable gfx cg*/
1492 if (*level & profile_mode_mask) {
1493 smu_dpm_ctx->saved_dpm_level = smu_dpm_ctx->dpm_level;
1494 smu_dpm_ctx->enable_umd_pstate = true;
1495 amdgpu_device_ip_set_powergating_state(smu->adev,
1496 AMD_IP_BLOCK_TYPE_GFX,
1497 AMD_PG_STATE_UNGATE);
1498 amdgpu_device_ip_set_clockgating_state(smu->adev,
1499 AMD_IP_BLOCK_TYPE_GFX,
1500 AMD_CG_STATE_UNGATE);
1501 smu_gfx_ulv_control(smu, false);
1502 smu_deep_sleep_control(smu, false);
1505 /* exit umd pstate, restore level, enable gfx cg*/
1506 if (!(*level & profile_mode_mask)) {
1507 if (*level == AMD_DPM_FORCED_LEVEL_PROFILE_EXIT)
1508 *level = smu_dpm_ctx->saved_dpm_level;
1509 smu_dpm_ctx->enable_umd_pstate = false;
1510 smu_deep_sleep_control(smu, true);
1511 smu_gfx_ulv_control(smu, true);
1512 amdgpu_device_ip_set_clockgating_state(smu->adev,
1513 AMD_IP_BLOCK_TYPE_GFX,
1515 amdgpu_device_ip_set_powergating_state(smu->adev,
1516 AMD_IP_BLOCK_TYPE_GFX,
1524 static int smu_adjust_power_state_dynamic(struct smu_context *smu,
1525 enum amd_dpm_forced_level level,
1526 bool skip_display_settings)
1531 struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
1533 if (!skip_display_settings) {
1534 ret = smu_display_config_changed(smu);
1536 dev_err(smu->adev->dev, "Failed to change display config!");
1541 ret = smu_apply_clocks_adjust_rules(smu);
1543 dev_err(smu->adev->dev, "Failed to apply clocks adjust rules!");
1547 if (!skip_display_settings) {
1548 ret = smu_notify_smc_display_config(smu);
1550 dev_err(smu->adev->dev, "Failed to notify smc display config!");
1555 if (smu_dpm_ctx->dpm_level != level) {
1556 ret = smu_asic_set_performance_level(smu, level);
1558 dev_err(smu->adev->dev, "Failed to set performance level!");
1562 /* update the saved copy */
1563 smu_dpm_ctx->dpm_level = level;
1566 if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {
1567 index = fls(smu->workload_mask);
1568 index = index > 0 && index <= WORKLOAD_POLICY_MAX ? index - 1 : 0;
1569 workload = smu->workload_setting[index];
1571 if (smu->power_profile_mode != workload)
1572 smu_set_power_profile_mode(smu, &workload, 0, false);
1578 int smu_handle_task(struct smu_context *smu,
1579 enum amd_dpm_forced_level level,
1580 enum amd_pp_task task_id,
1585 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1589 mutex_lock(&smu->mutex);
1592 case AMD_PP_TASK_DISPLAY_CONFIG_CHANGE:
1593 ret = smu_pre_display_config_changed(smu);
1596 ret = smu_set_cpu_power_state(smu);
1599 ret = smu_adjust_power_state_dynamic(smu, level, false);
1601 case AMD_PP_TASK_COMPLETE_INIT:
1602 case AMD_PP_TASK_READJUST_POWER_STATE:
1603 ret = smu_adjust_power_state_dynamic(smu, level, true);
1611 mutex_unlock(&smu->mutex);
1616 int smu_switch_power_profile(struct smu_context *smu,
1617 enum PP_SMC_POWER_PROFILE type,
1620 struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
1624 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1627 if (!(type < PP_SMC_POWER_PROFILE_CUSTOM))
1630 mutex_lock(&smu->mutex);
1633 smu->workload_mask &= ~(1 << smu->workload_prority[type]);
1634 index = fls(smu->workload_mask);
1635 index = index > 0 && index <= WORKLOAD_POLICY_MAX ? index - 1 : 0;
1636 workload = smu->workload_setting[index];
1638 smu->workload_mask |= (1 << smu->workload_prority[type]);
1639 index = fls(smu->workload_mask);
1640 index = index <= WORKLOAD_POLICY_MAX ? index - 1 : 0;
1641 workload = smu->workload_setting[index];
1644 if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL)
1645 smu_set_power_profile_mode(smu, &workload, 0, false);
1647 mutex_unlock(&smu->mutex);
1652 enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu)
1654 struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
1655 enum amd_dpm_forced_level level;
1657 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1660 if (!smu->is_apu && !smu_dpm_ctx->dpm_context)
1663 mutex_lock(&(smu->mutex));
1664 level = smu_dpm_ctx->dpm_level;
1665 mutex_unlock(&(smu->mutex));
1670 int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level)
1672 struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
1675 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1678 if (!smu->is_apu && !smu_dpm_ctx->dpm_context)
1681 mutex_lock(&smu->mutex);
1683 ret = smu_enable_umd_pstate(smu, &level);
1685 mutex_unlock(&smu->mutex);
1689 ret = smu_handle_task(smu, level,
1690 AMD_PP_TASK_READJUST_POWER_STATE,
1693 mutex_unlock(&smu->mutex);
1698 int smu_set_display_count(struct smu_context *smu, uint32_t count)
1702 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1705 mutex_lock(&smu->mutex);
1706 ret = smu_init_display_count(smu, count);
1707 mutex_unlock(&smu->mutex);
1712 int smu_force_clk_levels(struct smu_context *smu,
1713 enum smu_clk_type clk_type,
1716 struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
1719 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1722 if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {
1723 dev_dbg(smu->adev->dev, "force clock level is for dpm manual mode only.\n");
1727 mutex_lock(&smu->mutex);
1729 if (smu->ppt_funcs && smu->ppt_funcs->force_clk_levels)
1730 ret = smu->ppt_funcs->force_clk_levels(smu, clk_type, mask);
1732 mutex_unlock(&smu->mutex);
1738 * On system suspending or resetting, the dpm_enabled
1739 * flag will be cleared. So that those SMU services which
1740 * are not supported will be gated.
1741 * However, the mp1 state setting should still be granted
1742 * even if the dpm_enabled cleared.
1744 int smu_set_mp1_state(struct smu_context *smu,
1745 enum pp_mp1_state mp1_state)
1750 if (!smu->pm_enabled)
1753 mutex_lock(&smu->mutex);
1755 switch (mp1_state) {
1756 case PP_MP1_STATE_SHUTDOWN:
1757 msg = SMU_MSG_PrepareMp1ForShutdown;
1759 case PP_MP1_STATE_UNLOAD:
1760 msg = SMU_MSG_PrepareMp1ForUnload;
1762 case PP_MP1_STATE_RESET:
1763 msg = SMU_MSG_PrepareMp1ForReset;
1765 case PP_MP1_STATE_NONE:
1767 mutex_unlock(&smu->mutex);
1771 ret = smu_send_smc_msg(smu, msg, NULL);
1772 /* some asics may not support those messages */
1776 dev_err(smu->adev->dev, "[PrepareMp1] Failed!\n");
1778 mutex_unlock(&smu->mutex);
1783 int smu_set_df_cstate(struct smu_context *smu,
1784 enum pp_df_cstate state)
1788 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1791 if (!smu->ppt_funcs || !smu->ppt_funcs->set_df_cstate)
1794 mutex_lock(&smu->mutex);
1796 ret = smu->ppt_funcs->set_df_cstate(smu, state);
1798 dev_err(smu->adev->dev, "[SetDfCstate] failed!\n");
1800 mutex_unlock(&smu->mutex);
1805 int smu_allow_xgmi_power_down(struct smu_context *smu, bool en)
1809 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1812 if (!smu->ppt_funcs || !smu->ppt_funcs->allow_xgmi_power_down)
1815 mutex_lock(&smu->mutex);
1817 ret = smu->ppt_funcs->allow_xgmi_power_down(smu, en);
1819 dev_err(smu->adev->dev, "[AllowXgmiPowerDown] failed!\n");
1821 mutex_unlock(&smu->mutex);
1826 int smu_write_watermarks_table(struct smu_context *smu)
1830 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1833 mutex_lock(&smu->mutex);
1835 ret = smu_set_watermarks_table(smu, NULL);
1837 mutex_unlock(&smu->mutex);
1842 int smu_set_watermarks_for_clock_ranges(struct smu_context *smu,
1843 struct pp_smu_wm_range_sets *clock_ranges)
1847 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1850 if (smu->disable_watermark)
1853 mutex_lock(&smu->mutex);
1855 ret = smu_set_watermarks_table(smu, clock_ranges);
1857 mutex_unlock(&smu->mutex);
1862 int smu_set_ac_dc(struct smu_context *smu)
1866 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1869 /* controlled by firmware */
1870 if (smu->dc_controlled_by_gpio)
1873 mutex_lock(&smu->mutex);
1874 ret = smu_set_power_source(smu,
1875 smu->adev->pm.ac_power ? SMU_POWER_SOURCE_AC :
1876 SMU_POWER_SOURCE_DC);
1878 dev_err(smu->adev->dev, "Failed to switch to %s mode!\n",
1879 smu->adev->pm.ac_power ? "AC" : "DC");
1880 mutex_unlock(&smu->mutex);
1885 const struct amd_ip_funcs smu_ip_funcs = {
1887 .early_init = smu_early_init,
1888 .late_init = smu_late_init,
1889 .sw_init = smu_sw_init,
1890 .sw_fini = smu_sw_fini,
1891 .hw_init = smu_hw_init,
1892 .hw_fini = smu_hw_fini,
1893 .suspend = smu_suspend,
1894 .resume = smu_resume,
1896 .check_soft_reset = NULL,
1897 .wait_for_idle = NULL,
1899 .set_clockgating_state = smu_set_clockgating_state,
1900 .set_powergating_state = smu_set_powergating_state,
1901 .enable_umd_pstate = smu_enable_umd_pstate,
1904 const struct amdgpu_ip_block_version smu_v11_0_ip_block =
1906 .type = AMD_IP_BLOCK_TYPE_SMC,
1910 .funcs = &smu_ip_funcs,
1913 const struct amdgpu_ip_block_version smu_v12_0_ip_block =
1915 .type = AMD_IP_BLOCK_TYPE_SMC,
1919 .funcs = &smu_ip_funcs,
1922 int smu_load_microcode(struct smu_context *smu)
1926 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1929 mutex_lock(&smu->mutex);
1931 if (smu->ppt_funcs->load_microcode)
1932 ret = smu->ppt_funcs->load_microcode(smu);
1934 mutex_unlock(&smu->mutex);
1939 int smu_check_fw_status(struct smu_context *smu)
1943 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1946 mutex_lock(&smu->mutex);
1948 if (smu->ppt_funcs->check_fw_status)
1949 ret = smu->ppt_funcs->check_fw_status(smu);
1951 mutex_unlock(&smu->mutex);
1956 int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled)
1960 mutex_lock(&smu->mutex);
1962 if (smu->ppt_funcs->set_gfx_cgpg)
1963 ret = smu->ppt_funcs->set_gfx_cgpg(smu, enabled);
1965 mutex_unlock(&smu->mutex);
1970 int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed)
1974 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1977 mutex_lock(&smu->mutex);
1979 if (smu->ppt_funcs->set_fan_speed_rpm)
1980 ret = smu->ppt_funcs->set_fan_speed_rpm(smu, speed);
1982 mutex_unlock(&smu->mutex);
1987 int smu_get_power_limit(struct smu_context *smu,
1991 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
1994 mutex_lock(&smu->mutex);
1996 *limit = (max_setting ? smu->max_power_limit : smu->current_power_limit);
1998 mutex_unlock(&smu->mutex);
2003 int smu_set_power_limit(struct smu_context *smu, uint32_t limit)
2007 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2010 mutex_lock(&smu->mutex);
2012 if (limit > smu->max_power_limit) {
2013 dev_err(smu->adev->dev,
2014 "New power limit (%d) is over the max allowed %d\n",
2015 limit, smu->max_power_limit);
2020 limit = smu->current_power_limit;
2022 if (smu->ppt_funcs->set_power_limit)
2023 ret = smu->ppt_funcs->set_power_limit(smu, limit);
2026 mutex_unlock(&smu->mutex);
2031 int smu_print_clk_levels(struct smu_context *smu, enum smu_clk_type clk_type, char *buf)
2035 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2038 mutex_lock(&smu->mutex);
2040 if (smu->ppt_funcs->print_clk_levels)
2041 ret = smu->ppt_funcs->print_clk_levels(smu, clk_type, buf);
2043 mutex_unlock(&smu->mutex);
2048 int smu_get_od_percentage(struct smu_context *smu, enum smu_clk_type type)
2052 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2055 mutex_lock(&smu->mutex);
2057 if (smu->ppt_funcs->get_od_percentage)
2058 ret = smu->ppt_funcs->get_od_percentage(smu, type);
2060 mutex_unlock(&smu->mutex);
2065 int smu_set_od_percentage(struct smu_context *smu, enum smu_clk_type type, uint32_t value)
2069 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2072 mutex_lock(&smu->mutex);
2074 if (smu->ppt_funcs->set_od_percentage)
2075 ret = smu->ppt_funcs->set_od_percentage(smu, type, value);
2077 mutex_unlock(&smu->mutex);
2082 int smu_od_edit_dpm_table(struct smu_context *smu,
2083 enum PP_OD_DPM_TABLE_COMMAND type,
2084 long *input, uint32_t size)
2088 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2091 mutex_lock(&smu->mutex);
2093 if (smu->ppt_funcs->od_edit_dpm_table) {
2094 ret = smu->ppt_funcs->od_edit_dpm_table(smu, type, input, size);
2095 if (!ret && (type == PP_OD_COMMIT_DPM_TABLE))
2096 ret = smu_handle_task(smu,
2097 smu->smu_dpm.dpm_level,
2098 AMD_PP_TASK_READJUST_POWER_STATE,
2102 mutex_unlock(&smu->mutex);
2107 int smu_read_sensor(struct smu_context *smu,
2108 enum amd_pp_sensors sensor,
2109 void *data, uint32_t *size)
2111 struct smu_umd_pstate_table *pstate_table =
2115 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2121 mutex_lock(&smu->mutex);
2123 if (smu->ppt_funcs->read_sensor)
2124 if (!smu->ppt_funcs->read_sensor(smu, sensor, data, size))
2128 case AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK:
2129 *((uint32_t *)data) = pstate_table->gfxclk_pstate.standard * 100;
2132 case AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK:
2133 *((uint32_t *)data) = pstate_table->uclk_pstate.standard * 100;
2136 case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK:
2137 ret = smu_feature_get_enabled_mask(smu, (uint32_t *)data, 2);
2140 case AMDGPU_PP_SENSOR_UVD_POWER:
2141 *(uint32_t *)data = smu_feature_is_enabled(smu, SMU_FEATURE_DPM_UVD_BIT) ? 1 : 0;
2144 case AMDGPU_PP_SENSOR_VCE_POWER:
2145 *(uint32_t *)data = smu_feature_is_enabled(smu, SMU_FEATURE_DPM_VCE_BIT) ? 1 : 0;
2148 case AMDGPU_PP_SENSOR_VCN_POWER_STATE:
2149 *(uint32_t *)data = atomic_read(&smu->smu_power.power_gate.vcn_gated) ? 0: 1;
2152 case AMDGPU_PP_SENSOR_MIN_FAN_RPM:
2153 *(uint32_t *)data = 0;
2163 mutex_unlock(&smu->mutex);
2168 int smu_get_power_profile_mode(struct smu_context *smu, char *buf)
2172 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2175 mutex_lock(&smu->mutex);
2177 if (smu->ppt_funcs->get_power_profile_mode)
2178 ret = smu->ppt_funcs->get_power_profile_mode(smu, buf);
2180 mutex_unlock(&smu->mutex);
2185 int smu_set_power_profile_mode(struct smu_context *smu,
2187 uint32_t param_size,
2192 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2196 mutex_lock(&smu->mutex);
2198 if (smu->ppt_funcs->set_power_profile_mode)
2199 ret = smu->ppt_funcs->set_power_profile_mode(smu, param, param_size);
2202 mutex_unlock(&smu->mutex);
2208 int smu_get_fan_control_mode(struct smu_context *smu)
2212 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2215 mutex_lock(&smu->mutex);
2217 if (smu->ppt_funcs->get_fan_control_mode)
2218 ret = smu->ppt_funcs->get_fan_control_mode(smu);
2220 mutex_unlock(&smu->mutex);
2225 int smu_set_fan_control_mode(struct smu_context *smu, int value)
2229 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2232 mutex_lock(&smu->mutex);
2234 if (smu->ppt_funcs->set_fan_control_mode)
2235 ret = smu->ppt_funcs->set_fan_control_mode(smu, value);
2237 mutex_unlock(&smu->mutex);
2242 int smu_get_fan_speed_percent(struct smu_context *smu, uint32_t *speed)
2246 uint32_t current_rpm;
2248 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2251 mutex_lock(&smu->mutex);
2253 if (smu->ppt_funcs->get_fan_speed_rpm) {
2254 ret = smu->ppt_funcs->get_fan_speed_rpm(smu, ¤t_rpm);
2256 percent = current_rpm * 100 / smu->fan_max_rpm;
2257 *speed = percent > 100 ? 100 : percent;
2261 mutex_unlock(&smu->mutex);
2267 int smu_set_fan_speed_percent(struct smu_context *smu, uint32_t speed)
2272 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2275 mutex_lock(&smu->mutex);
2277 if (smu->ppt_funcs->set_fan_speed_rpm) {
2280 rpm = speed * smu->fan_max_rpm / 100;
2281 ret = smu->ppt_funcs->set_fan_speed_rpm(smu, rpm);
2284 mutex_unlock(&smu->mutex);
2289 int smu_get_fan_speed_rpm(struct smu_context *smu, uint32_t *speed)
2293 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2296 mutex_lock(&smu->mutex);
2298 if (smu->ppt_funcs->get_fan_speed_rpm)
2299 ret = smu->ppt_funcs->get_fan_speed_rpm(smu, speed);
2301 mutex_unlock(&smu->mutex);
2306 int smu_set_deep_sleep_dcefclk(struct smu_context *smu, int clk)
2310 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2313 mutex_lock(&smu->mutex);
2315 ret = smu_set_min_dcef_deep_sleep(smu, clk);
2317 mutex_unlock(&smu->mutex);
2322 int smu_get_clock_by_type(struct smu_context *smu,
2323 enum amd_pp_clock_type type,
2324 struct amd_pp_clocks *clocks)
2328 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2331 mutex_lock(&smu->mutex);
2333 if (smu->ppt_funcs->get_clock_by_type)
2334 ret = smu->ppt_funcs->get_clock_by_type(smu, type, clocks);
2336 mutex_unlock(&smu->mutex);
2341 int smu_get_max_high_clocks(struct smu_context *smu,
2342 struct amd_pp_simple_clock_info *clocks)
2346 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2349 mutex_lock(&smu->mutex);
2351 if (smu->ppt_funcs->get_max_high_clocks)
2352 ret = smu->ppt_funcs->get_max_high_clocks(smu, clocks);
2354 mutex_unlock(&smu->mutex);
2359 int smu_get_clock_by_type_with_latency(struct smu_context *smu,
2360 enum smu_clk_type clk_type,
2361 struct pp_clock_levels_with_latency *clocks)
2365 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2368 mutex_lock(&smu->mutex);
2370 if (smu->ppt_funcs->get_clock_by_type_with_latency)
2371 ret = smu->ppt_funcs->get_clock_by_type_with_latency(smu, clk_type, clocks);
2373 mutex_unlock(&smu->mutex);
2378 int smu_get_clock_by_type_with_voltage(struct smu_context *smu,
2379 enum amd_pp_clock_type type,
2380 struct pp_clock_levels_with_voltage *clocks)
2384 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2387 mutex_lock(&smu->mutex);
2389 if (smu->ppt_funcs->get_clock_by_type_with_voltage)
2390 ret = smu->ppt_funcs->get_clock_by_type_with_voltage(smu, type, clocks);
2392 mutex_unlock(&smu->mutex);
2398 int smu_display_clock_voltage_request(struct smu_context *smu,
2399 struct pp_display_clock_request *clock_req)
2403 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2406 mutex_lock(&smu->mutex);
2408 if (smu->ppt_funcs->display_clock_voltage_request)
2409 ret = smu->ppt_funcs->display_clock_voltage_request(smu, clock_req);
2411 mutex_unlock(&smu->mutex);
2417 int smu_display_disable_memory_clock_switch(struct smu_context *smu, bool disable_memory_clock_switch)
2421 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2424 mutex_lock(&smu->mutex);
2426 if (smu->ppt_funcs->display_disable_memory_clock_switch)
2427 ret = smu->ppt_funcs->display_disable_memory_clock_switch(smu, disable_memory_clock_switch);
2429 mutex_unlock(&smu->mutex);
2434 int smu_notify_smu_enable_pwe(struct smu_context *smu)
2438 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2441 mutex_lock(&smu->mutex);
2443 if (smu->ppt_funcs->notify_smu_enable_pwe)
2444 ret = smu->ppt_funcs->notify_smu_enable_pwe(smu);
2446 mutex_unlock(&smu->mutex);
2451 int smu_set_xgmi_pstate(struct smu_context *smu,
2456 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2459 mutex_lock(&smu->mutex);
2461 if (smu->ppt_funcs->set_xgmi_pstate)
2462 ret = smu->ppt_funcs->set_xgmi_pstate(smu, pstate);
2464 mutex_unlock(&smu->mutex);
2467 dev_err(smu->adev->dev, "Failed to set XGMI pstate!\n");
2472 int smu_set_azalia_d3_pme(struct smu_context *smu)
2476 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2479 mutex_lock(&smu->mutex);
2481 if (smu->ppt_funcs->set_azalia_d3_pme)
2482 ret = smu->ppt_funcs->set_azalia_d3_pme(smu);
2484 mutex_unlock(&smu->mutex);
2490 * On system suspending or resetting, the dpm_enabled
2491 * flag will be cleared. So that those SMU services which
2492 * are not supported will be gated.
2494 * However, the baco/mode1 reset should still be granted
2495 * as they are still supported and necessary.
2497 bool smu_baco_is_support(struct smu_context *smu)
2501 if (!smu->pm_enabled)
2504 mutex_lock(&smu->mutex);
2506 if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support)
2507 ret = smu->ppt_funcs->baco_is_support(smu);
2509 mutex_unlock(&smu->mutex);
2514 int smu_baco_get_state(struct smu_context *smu, enum smu_baco_state *state)
2516 if (smu->ppt_funcs->baco_get_state)
2519 mutex_lock(&smu->mutex);
2520 *state = smu->ppt_funcs->baco_get_state(smu);
2521 mutex_unlock(&smu->mutex);
2526 int smu_baco_enter(struct smu_context *smu)
2530 if (!smu->pm_enabled)
2533 mutex_lock(&smu->mutex);
2535 if (smu->ppt_funcs->baco_enter)
2536 ret = smu->ppt_funcs->baco_enter(smu);
2538 mutex_unlock(&smu->mutex);
2541 dev_err(smu->adev->dev, "Failed to enter BACO state!\n");
2546 int smu_baco_exit(struct smu_context *smu)
2550 if (!smu->pm_enabled)
2553 mutex_lock(&smu->mutex);
2555 if (smu->ppt_funcs->baco_exit)
2556 ret = smu->ppt_funcs->baco_exit(smu);
2558 mutex_unlock(&smu->mutex);
2561 dev_err(smu->adev->dev, "Failed to exit BACO state!\n");
2566 bool smu_mode1_reset_is_support(struct smu_context *smu)
2570 if (!smu->pm_enabled)
2573 mutex_lock(&smu->mutex);
2575 if (smu->ppt_funcs && smu->ppt_funcs->mode1_reset_is_support)
2576 ret = smu->ppt_funcs->mode1_reset_is_support(smu);
2578 mutex_unlock(&smu->mutex);
2583 int smu_mode1_reset(struct smu_context *smu)
2587 if (!smu->pm_enabled)
2590 mutex_lock(&smu->mutex);
2592 if (smu->ppt_funcs->mode1_reset)
2593 ret = smu->ppt_funcs->mode1_reset(smu);
2595 mutex_unlock(&smu->mutex);
2600 int smu_mode2_reset(struct smu_context *smu)
2604 if (!smu->pm_enabled)
2607 mutex_lock(&smu->mutex);
2609 if (smu->ppt_funcs->mode2_reset)
2610 ret = smu->ppt_funcs->mode2_reset(smu);
2612 mutex_unlock(&smu->mutex);
2615 dev_err(smu->adev->dev, "Mode2 reset failed!\n");
2620 int smu_get_max_sustainable_clocks_by_dc(struct smu_context *smu,
2621 struct pp_smu_nv_clock_table *max_clocks)
2625 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2628 mutex_lock(&smu->mutex);
2630 if (smu->ppt_funcs->get_max_sustainable_clocks_by_dc)
2631 ret = smu->ppt_funcs->get_max_sustainable_clocks_by_dc(smu, max_clocks);
2633 mutex_unlock(&smu->mutex);
2638 int smu_get_uclk_dpm_states(struct smu_context *smu,
2639 unsigned int *clock_values_in_khz,
2640 unsigned int *num_states)
2644 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2647 mutex_lock(&smu->mutex);
2649 if (smu->ppt_funcs->get_uclk_dpm_states)
2650 ret = smu->ppt_funcs->get_uclk_dpm_states(smu, clock_values_in_khz, num_states);
2652 mutex_unlock(&smu->mutex);
2657 enum amd_pm_state_type smu_get_current_power_state(struct smu_context *smu)
2659 enum amd_pm_state_type pm_state = POWER_STATE_TYPE_DEFAULT;
2661 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2664 mutex_lock(&smu->mutex);
2666 if (smu->ppt_funcs->get_current_power_state)
2667 pm_state = smu->ppt_funcs->get_current_power_state(smu);
2669 mutex_unlock(&smu->mutex);
2674 int smu_get_dpm_clock_table(struct smu_context *smu,
2675 struct dpm_clocks *clock_table)
2679 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2682 mutex_lock(&smu->mutex);
2684 if (smu->ppt_funcs->get_dpm_clock_table)
2685 ret = smu->ppt_funcs->get_dpm_clock_table(smu, clock_table);
2687 mutex_unlock(&smu->mutex);
2692 ssize_t smu_sys_get_gpu_metrics(struct smu_context *smu,
2697 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2700 if (!smu->ppt_funcs->get_gpu_metrics)
2703 mutex_lock(&smu->mutex);
2705 size = smu->ppt_funcs->get_gpu_metrics(smu, table);
2707 mutex_unlock(&smu->mutex);
2712 int smu_enable_mgpu_fan_boost(struct smu_context *smu)
2716 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
2719 mutex_lock(&smu->mutex);
2721 if (smu->ppt_funcs->enable_mgpu_fan_boost)
2722 ret = smu->ppt_funcs->enable_mgpu_fan_boost(smu);
2724 mutex_unlock(&smu->mutex);