Lines Matching +full:battery +full:- +full:profile
36 #include <linux/hwmon-sysfs.h>
89 * - battery
91 * - balanced
93 * - performance
95 * battery
97 * On older GPUs, the vbios provided a special power state for battery
98 * operation. Selecting battery switched to this state. This is no
125 return -EPERM; in amdgpu_get_power_dpm_state()
127 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_power_dpm_state()
129 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_power_dpm_state()
134 if (adev->smu.ppt_funcs->get_current_power_state) in amdgpu_get_power_dpm_state()
135 pm = smu_get_current_power_state(&adev->smu); in amdgpu_get_power_dpm_state()
137 pm = adev->pm.dpm.user_state; in amdgpu_get_power_dpm_state()
138 } else if (adev->powerplay.pp_funcs->get_current_power_state) { in amdgpu_get_power_dpm_state()
141 pm = adev->pm.dpm.user_state; in amdgpu_get_power_dpm_state()
144 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_power_dpm_state()
145 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_power_dpm_state()
148 (pm == POWER_STATE_TYPE_BATTERY) ? "battery" : in amdgpu_get_power_dpm_state()
163 return -EPERM; in amdgpu_set_power_dpm_state()
165 if (strncmp("battery", buf, strlen("battery")) == 0) in amdgpu_set_power_dpm_state()
172 return -EINVAL; in amdgpu_set_power_dpm_state()
174 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_power_dpm_state()
176 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_state()
181 mutex_lock(&adev->pm.mutex); in amdgpu_set_power_dpm_state()
182 adev->pm.dpm.user_state = state; in amdgpu_set_power_dpm_state()
183 mutex_unlock(&adev->pm.mutex); in amdgpu_set_power_dpm_state()
184 } else if (adev->powerplay.pp_funcs->dispatch_tasks) { in amdgpu_set_power_dpm_state()
187 mutex_lock(&adev->pm.mutex); in amdgpu_set_power_dpm_state()
188 adev->pm.dpm.user_state = state; in amdgpu_set_power_dpm_state()
189 mutex_unlock(&adev->pm.mutex); in amdgpu_set_power_dpm_state()
193 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_power_dpm_state()
194 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_state()
207 * - auto
209 * - low
211 * - high
213 * - manual
215 * - profile_standard
217 * - profile_min_sclk
219 * - profile_min_mclk
221 * - profile_peak
226 * the optimal power profile for current conditions in the driver.
269 return -EPERM; in amdgpu_get_power_dpm_force_performance_level()
271 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_power_dpm_force_performance_level()
273 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_power_dpm_force_performance_level()
278 level = smu_get_performance_level(&adev->smu); in amdgpu_get_power_dpm_force_performance_level()
279 else if (adev->powerplay.pp_funcs->get_performance_level) in amdgpu_get_power_dpm_force_performance_level()
282 level = adev->pm.dpm.forced_level; in amdgpu_get_power_dpm_force_performance_level()
284 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_power_dpm_force_performance_level()
285 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_power_dpm_force_performance_level()
311 return -EPERM; in amdgpu_set_power_dpm_force_performance_level()
332 return -EINVAL; in amdgpu_set_power_dpm_force_performance_level()
335 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
337 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
342 current_level = smu_get_performance_level(&adev->smu); in amdgpu_set_power_dpm_force_performance_level()
343 else if (adev->powerplay.pp_funcs->get_performance_level) in amdgpu_set_power_dpm_force_performance_level()
347 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
348 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
352 if (adev->asic_type == CHIP_RAVEN) { in amdgpu_set_power_dpm_force_performance_level()
353 if (!(adev->apu_flags & AMD_APU_IS_RAVEN2)) { in amdgpu_set_power_dpm_force_performance_level()
361 /* profile_exit setting is valid only when current mode is in profile mode */ in amdgpu_set_power_dpm_force_performance_level()
367 pr_err("Currently not in any profile mode!\n"); in amdgpu_set_power_dpm_force_performance_level()
368 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
369 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
370 return -EINVAL; in amdgpu_set_power_dpm_force_performance_level()
374 ret = smu_force_performance_level(&adev->smu, level); in amdgpu_set_power_dpm_force_performance_level()
376 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
377 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
378 return -EINVAL; in amdgpu_set_power_dpm_force_performance_level()
380 } else if (adev->powerplay.pp_funcs->force_performance_level) { in amdgpu_set_power_dpm_force_performance_level()
381 mutex_lock(&adev->pm.mutex); in amdgpu_set_power_dpm_force_performance_level()
382 if (adev->pm.dpm.thermal_active) { in amdgpu_set_power_dpm_force_performance_level()
383 mutex_unlock(&adev->pm.mutex); in amdgpu_set_power_dpm_force_performance_level()
384 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
385 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
386 return -EINVAL; in amdgpu_set_power_dpm_force_performance_level()
390 mutex_unlock(&adev->pm.mutex); in amdgpu_set_power_dpm_force_performance_level()
391 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
392 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
393 return -EINVAL; in amdgpu_set_power_dpm_force_performance_level()
395 adev->pm.dpm.forced_level = level; in amdgpu_set_power_dpm_force_performance_level()
397 mutex_unlock(&adev->pm.mutex); in amdgpu_set_power_dpm_force_performance_level()
399 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
400 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_power_dpm_force_performance_level()
415 return -EPERM; in amdgpu_get_pp_num_states()
417 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_num_states()
419 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_num_states()
424 ret = smu_get_power_num_states(&adev->smu, &data); in amdgpu_get_pp_num_states()
427 } else if (adev->powerplay.pp_funcs->get_pp_num_states) { in amdgpu_get_pp_num_states()
433 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_num_states()
434 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_num_states()
440 (data.states[i] == POWER_STATE_TYPE_BATTERY) ? "battery" : in amdgpu_get_pp_num_states()
454 struct smu_context *smu = &adev->smu; in amdgpu_get_pp_cur_state()
459 return -EPERM; in amdgpu_get_pp_cur_state()
461 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_cur_state()
463 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_cur_state()
472 } else if (adev->powerplay.pp_funcs->get_current_power_state in amdgpu_get_pp_cur_state()
473 && adev->powerplay.pp_funcs->get_pp_num_states) { in amdgpu_get_pp_cur_state()
478 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_cur_state()
479 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_cur_state()
487 i = -EINVAL; in amdgpu_get_pp_cur_state()
500 return -EPERM; in amdgpu_get_pp_force_state()
502 if (adev->pp_force_state_enabled) in amdgpu_get_pp_force_state()
520 return -EPERM; in amdgpu_set_pp_force_state()
523 adev->pp_force_state_enabled = false; in amdgpu_set_pp_force_state()
525 adev->pp_force_state_enabled = false; in amdgpu_set_pp_force_state()
526 else if (adev->powerplay.pp_funcs->dispatch_tasks && in amdgpu_set_pp_force_state()
527 adev->powerplay.pp_funcs->get_pp_num_states) { in amdgpu_set_pp_force_state()
532 return -EINVAL; in amdgpu_set_pp_force_state()
539 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_force_state()
541 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_force_state()
550 adev->pp_force_state_enabled = true; in amdgpu_set_pp_force_state()
552 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_force_state()
553 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_force_state()
565 * will attempt to upload a new powerplay table and re-initialize
580 return -EPERM; in amdgpu_get_pp_table()
582 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_table()
584 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_table()
589 size = smu_sys_get_pp_table(&adev->smu, (void **)&table); in amdgpu_get_pp_table()
590 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_table()
591 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_table()
594 } else if (adev->powerplay.pp_funcs->get_pp_table) { in amdgpu_get_pp_table()
596 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_table()
597 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_table()
601 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_table()
602 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_table()
607 size = PAGE_SIZE - 1; in amdgpu_get_pp_table()
624 return -EPERM; in amdgpu_set_pp_table()
626 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_table()
628 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_table()
633 ret = smu_sys_set_pp_table(&adev->smu, (void *)buf, count); in amdgpu_set_pp_table()
635 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_table()
636 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_table()
639 } else if (adev->powerplay.pp_funcs->set_pp_table) in amdgpu_set_pp_table()
642 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_table()
643 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_table()
705 * - a list of engine clock levels and voltages labeled OD_SCLK
707 * - a list of memory clock levels and voltages labeled OD_MCLK
709 * - a list of valid ranges for sclk, mclk, and voltage labeled OD_RANGE
725 * - minimum and maximum engine clock labeled OD_SCLK
727 * - maximum memory clock labeled OD_MCLK
729 * - three <frequency, voltage> points labeled OD_VDDC_CURVE.
732 * - a list of valid ranges for sclk, mclk, and voltage curve points
737 * - First select manual using power_dpm_force_performance_level
739 * - For clock frequency setting, enter a new value by writing a
752 * - When you have edited all of the states as needed, write "c" (commit)
755 * - If you want to reset to the default power levels, write "r" (reset)
777 return -EPERM; in amdgpu_set_pp_od_clk_voltage()
780 return -EINVAL; in amdgpu_set_pp_od_clk_voltage()
793 return -EINVAL; in amdgpu_set_pp_od_clk_voltage()
807 return -EINVAL; in amdgpu_set_pp_od_clk_voltage()
814 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
816 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
821 ret = smu_od_edit_dpm_table(&adev->smu, type, in amdgpu_set_pp_od_clk_voltage()
825 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
826 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
827 return -EINVAL; in amdgpu_set_pp_od_clk_voltage()
831 if (adev->powerplay.pp_funcs->set_fine_grain_clk_vol) { in amdgpu_set_pp_od_clk_voltage()
836 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
837 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
838 return -EINVAL; in amdgpu_set_pp_od_clk_voltage()
842 if (adev->powerplay.pp_funcs->odn_edit_dpm_table) { in amdgpu_set_pp_od_clk_voltage()
846 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
847 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
848 return -EINVAL; in amdgpu_set_pp_od_clk_voltage()
853 if (adev->powerplay.pp_funcs->dispatch_tasks) { in amdgpu_set_pp_od_clk_voltage()
857 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
858 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
861 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
862 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
863 return -EINVAL; in amdgpu_set_pp_od_clk_voltage()
867 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
868 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_od_clk_voltage()
883 return -EPERM; in amdgpu_get_pp_od_clk_voltage()
885 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_od_clk_voltage()
887 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_od_clk_voltage()
892 size = smu_print_clk_levels(&adev->smu, SMU_OD_SCLK, buf); in amdgpu_get_pp_od_clk_voltage()
893 size += smu_print_clk_levels(&adev->smu, SMU_OD_MCLK, buf+size); in amdgpu_get_pp_od_clk_voltage()
894 size += smu_print_clk_levels(&adev->smu, SMU_OD_VDDC_CURVE, buf+size); in amdgpu_get_pp_od_clk_voltage()
895 size += smu_print_clk_levels(&adev->smu, SMU_OD_RANGE, buf+size); in amdgpu_get_pp_od_clk_voltage()
896 } else if (adev->powerplay.pp_funcs->print_clock_levels) { in amdgpu_get_pp_od_clk_voltage()
904 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_od_clk_voltage()
905 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_od_clk_voltage()
918 * - Current ppfeature masks
919 * - List of the all supported powerplay features with their naming,
937 return -EPERM; in amdgpu_set_pp_features()
941 return -EINVAL; in amdgpu_set_pp_features()
945 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_features()
947 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_features()
952 ret = smu_sys_set_pp_feature_mask(&adev->smu, featuremask); in amdgpu_set_pp_features()
954 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_features()
955 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_features()
956 return -EINVAL; in amdgpu_set_pp_features()
958 } else if (adev->powerplay.pp_funcs->set_ppfeature_status) { in amdgpu_set_pp_features()
961 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_features()
962 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_features()
963 return -EINVAL; in amdgpu_set_pp_features()
966 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_features()
967 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_features()
982 return -EPERM; in amdgpu_get_pp_features()
984 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_features()
986 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_features()
991 size = smu_sys_get_pp_feature_mask(&adev->smu, buf); in amdgpu_get_pp_features()
992 else if (adev->powerplay.pp_funcs->get_ppfeature_status) in amdgpu_get_pp_features()
997 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_features()
998 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_features()
1024 * .. code-block:: bash
1043 return -EPERM; in amdgpu_get_pp_dpm_sclk()
1045 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_dpm_sclk()
1047 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_sclk()
1052 size = smu_print_clk_levels(&adev->smu, SMU_SCLK, buf); in amdgpu_get_pp_dpm_sclk()
1053 else if (adev->powerplay.pp_funcs->print_clock_levels) in amdgpu_get_pp_dpm_sclk()
1058 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_dpm_sclk()
1059 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_sclk()
1082 bytes = min(count, sizeof(buf_cpy) - 1); in amdgpu_read_mask()
1091 return -EINVAL; in amdgpu_read_mask()
1111 return -EPERM; in amdgpu_set_pp_dpm_sclk()
1117 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_dpm_sclk()
1119 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_sclk()
1124 ret = smu_force_clk_levels(&adev->smu, SMU_SCLK, mask); in amdgpu_set_pp_dpm_sclk()
1125 else if (adev->powerplay.pp_funcs->force_clock_level) in amdgpu_set_pp_dpm_sclk()
1128 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_dpm_sclk()
1129 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_sclk()
1132 return -EINVAL; in amdgpu_set_pp_dpm_sclk()
1147 return -EPERM; in amdgpu_get_pp_dpm_mclk()
1149 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_dpm_mclk()
1151 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_mclk()
1156 size = smu_print_clk_levels(&adev->smu, SMU_MCLK, buf); in amdgpu_get_pp_dpm_mclk()
1157 else if (adev->powerplay.pp_funcs->print_clock_levels) in amdgpu_get_pp_dpm_mclk()
1162 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_dpm_mclk()
1163 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_mclk()
1179 return -EPERM; in amdgpu_set_pp_dpm_mclk()
1185 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_dpm_mclk()
1187 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_mclk()
1192 ret = smu_force_clk_levels(&adev->smu, SMU_MCLK, mask); in amdgpu_set_pp_dpm_mclk()
1193 else if (adev->powerplay.pp_funcs->force_clock_level) in amdgpu_set_pp_dpm_mclk()
1196 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_dpm_mclk()
1197 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_mclk()
1200 return -EINVAL; in amdgpu_set_pp_dpm_mclk()
1215 return -EPERM; in amdgpu_get_pp_dpm_socclk()
1217 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_dpm_socclk()
1219 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_socclk()
1224 size = smu_print_clk_levels(&adev->smu, SMU_SOCCLK, buf); in amdgpu_get_pp_dpm_socclk()
1225 else if (adev->powerplay.pp_funcs->print_clock_levels) in amdgpu_get_pp_dpm_socclk()
1230 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_dpm_socclk()
1231 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_socclk()
1247 return -EPERM; in amdgpu_set_pp_dpm_socclk()
1253 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_dpm_socclk()
1255 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_socclk()
1260 ret = smu_force_clk_levels(&adev->smu, SMU_SOCCLK, mask); in amdgpu_set_pp_dpm_socclk()
1261 else if (adev->powerplay.pp_funcs->force_clock_level) in amdgpu_set_pp_dpm_socclk()
1266 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_dpm_socclk()
1267 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_socclk()
1270 return -EINVAL; in amdgpu_set_pp_dpm_socclk()
1285 return -EPERM; in amdgpu_get_pp_dpm_fclk()
1287 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_dpm_fclk()
1289 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_fclk()
1294 size = smu_print_clk_levels(&adev->smu, SMU_FCLK, buf); in amdgpu_get_pp_dpm_fclk()
1295 else if (adev->powerplay.pp_funcs->print_clock_levels) in amdgpu_get_pp_dpm_fclk()
1300 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_dpm_fclk()
1301 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_fclk()
1317 return -EPERM; in amdgpu_set_pp_dpm_fclk()
1323 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_dpm_fclk()
1325 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_fclk()
1330 ret = smu_force_clk_levels(&adev->smu, SMU_FCLK, mask); in amdgpu_set_pp_dpm_fclk()
1331 else if (adev->powerplay.pp_funcs->force_clock_level) in amdgpu_set_pp_dpm_fclk()
1336 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_dpm_fclk()
1337 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_fclk()
1340 return -EINVAL; in amdgpu_set_pp_dpm_fclk()
1355 return -EPERM; in amdgpu_get_pp_dpm_dcefclk()
1357 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_dpm_dcefclk()
1359 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_dcefclk()
1364 size = smu_print_clk_levels(&adev->smu, SMU_DCEFCLK, buf); in amdgpu_get_pp_dpm_dcefclk()
1365 else if (adev->powerplay.pp_funcs->print_clock_levels) in amdgpu_get_pp_dpm_dcefclk()
1370 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_dpm_dcefclk()
1371 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_dcefclk()
1387 return -EPERM; in amdgpu_set_pp_dpm_dcefclk()
1393 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_dpm_dcefclk()
1395 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_dcefclk()
1400 ret = smu_force_clk_levels(&adev->smu, SMU_DCEFCLK, mask); in amdgpu_set_pp_dpm_dcefclk()
1401 else if (adev->powerplay.pp_funcs->force_clock_level) in amdgpu_set_pp_dpm_dcefclk()
1406 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_dpm_dcefclk()
1407 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_dcefclk()
1410 return -EINVAL; in amdgpu_set_pp_dpm_dcefclk()
1425 return -EPERM; in amdgpu_get_pp_dpm_pcie()
1427 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_dpm_pcie()
1429 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_pcie()
1434 size = smu_print_clk_levels(&adev->smu, SMU_PCIE, buf); in amdgpu_get_pp_dpm_pcie()
1435 else if (adev->powerplay.pp_funcs->print_clock_levels) in amdgpu_get_pp_dpm_pcie()
1440 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_dpm_pcie()
1441 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_dpm_pcie()
1457 return -EPERM; in amdgpu_set_pp_dpm_pcie()
1463 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_dpm_pcie()
1465 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_pcie()
1470 ret = smu_force_clk_levels(&adev->smu, SMU_PCIE, mask); in amdgpu_set_pp_dpm_pcie()
1471 else if (adev->powerplay.pp_funcs->force_clock_level) in amdgpu_set_pp_dpm_pcie()
1476 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_dpm_pcie()
1477 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_dpm_pcie()
1480 return -EINVAL; in amdgpu_set_pp_dpm_pcie()
1495 return -EPERM; in amdgpu_get_pp_sclk_od()
1497 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_sclk_od()
1499 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_sclk_od()
1504 value = smu_get_od_percentage(&(adev->smu), SMU_OD_SCLK); in amdgpu_get_pp_sclk_od()
1505 else if (adev->powerplay.pp_funcs->get_sclk_od) in amdgpu_get_pp_sclk_od()
1508 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_sclk_od()
1509 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_sclk_od()
1525 return -EPERM; in amdgpu_set_pp_sclk_od()
1530 return -EINVAL; in amdgpu_set_pp_sclk_od()
1532 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_sclk_od()
1534 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_sclk_od()
1539 value = smu_set_od_percentage(&(adev->smu), SMU_OD_SCLK, (uint32_t)value); in amdgpu_set_pp_sclk_od()
1541 if (adev->powerplay.pp_funcs->set_sclk_od) in amdgpu_set_pp_sclk_od()
1544 if (adev->powerplay.pp_funcs->dispatch_tasks) { in amdgpu_set_pp_sclk_od()
1547 adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; in amdgpu_set_pp_sclk_od()
1552 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_sclk_od()
1553 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_sclk_od()
1568 return -EPERM; in amdgpu_get_pp_mclk_od()
1570 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_mclk_od()
1572 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_mclk_od()
1577 value = smu_get_od_percentage(&(adev->smu), SMU_OD_MCLK); in amdgpu_get_pp_mclk_od()
1578 else if (adev->powerplay.pp_funcs->get_mclk_od) in amdgpu_get_pp_mclk_od()
1581 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_mclk_od()
1582 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_mclk_od()
1598 return -EPERM; in amdgpu_set_pp_mclk_od()
1603 return -EINVAL; in amdgpu_set_pp_mclk_od()
1605 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_mclk_od()
1607 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_mclk_od()
1612 value = smu_set_od_percentage(&(adev->smu), SMU_OD_MCLK, (uint32_t)value); in amdgpu_set_pp_mclk_od()
1614 if (adev->powerplay.pp_funcs->set_mclk_od) in amdgpu_set_pp_mclk_od()
1617 if (adev->powerplay.pp_funcs->dispatch_tasks) { in amdgpu_set_pp_mclk_od()
1620 adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; in amdgpu_set_pp_mclk_od()
1625 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_mclk_od()
1626 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_mclk_od()
1639 * and the relevant heuristics settings for that profile.
1641 * To select a profile or create a custom profile, first select manual using
1643 * profile to pp_power_profile_mode will enable those heuristics. To
1645 * starting with the number of the custom profile along with a setting
1661 return -EPERM; in amdgpu_get_pp_power_profile_mode()
1663 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pp_power_profile_mode()
1665 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_power_profile_mode()
1670 size = smu_get_power_profile_mode(&adev->smu, buf); in amdgpu_get_pp_power_profile_mode()
1671 else if (adev->powerplay.pp_funcs->get_power_profile_mode) in amdgpu_get_pp_power_profile_mode()
1676 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pp_power_profile_mode()
1677 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pp_power_profile_mode()
1701 return -EPERM; in amdgpu_set_pp_power_profile_mode()
1707 return -EINVAL; in amdgpu_set_pp_power_profile_mode()
1711 return -EINVAL; in amdgpu_set_pp_power_profile_mode()
1714 memcpy(buf_cpy, buf, count-i); in amdgpu_set_pp_power_profile_mode()
1720 return -EINVAL; in amdgpu_set_pp_power_profile_mode()
1728 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_set_pp_power_profile_mode()
1730 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_power_profile_mode()
1735 ret = smu_set_power_profile_mode(&adev->smu, parameter, parameter_size, true); in amdgpu_set_pp_power_profile_mode()
1736 else if (adev->powerplay.pp_funcs->set_power_profile_mode) in amdgpu_set_pp_power_profile_mode()
1739 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_set_pp_power_profile_mode()
1740 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_set_pp_power_profile_mode()
1745 return -EINVAL; in amdgpu_set_pp_power_profile_mode()
1765 return -EPERM; in amdgpu_get_gpu_busy_percent()
1767 r = pm_runtime_get_sync(ddev->dev); in amdgpu_get_gpu_busy_percent()
1769 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_gpu_busy_percent()
1777 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_gpu_busy_percent()
1778 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_gpu_busy_percent()
1803 return -EPERM; in amdgpu_get_mem_busy_percent()
1805 r = pm_runtime_get_sync(ddev->dev); in amdgpu_get_mem_busy_percent()
1807 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_mem_busy_percent()
1815 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_mem_busy_percent()
1816 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_mem_busy_percent()
1846 return -EPERM; in amdgpu_get_pcie_bw()
1848 if (adev->flags & AMD_IS_APU) in amdgpu_get_pcie_bw()
1849 return -ENODATA; in amdgpu_get_pcie_bw()
1851 if (!adev->asic_funcs->get_pcie_usage) in amdgpu_get_pcie_bw()
1852 return -ENODATA; in amdgpu_get_pcie_bw()
1854 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_pcie_bw()
1856 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pcie_bw()
1862 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_pcie_bw()
1863 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_pcie_bw()
1866 count0, count1, pcie_get_mps(adev->pdev)); in amdgpu_get_pcie_bw()
1887 return -EPERM; in amdgpu_get_unique_id()
1889 if (adev->unique_id) in amdgpu_get_unique_id()
1890 return snprintf(buf, PAGE_SIZE, "%016llx\n", adev->unique_id); in amdgpu_get_unique_id()
1918 adev_to_drm(adev)->unique, in amdgpu_get_thermal_throttling_logging()
1919 atomic_read(&adev->throttling_logging_enabled) ? "enabled" : "disabled", in amdgpu_get_thermal_throttling_logging()
1920 adev->throttling_logging_rs.interval / HZ + 1); in amdgpu_get_thermal_throttling_logging()
1939 return -EINVAL; in amdgpu_set_thermal_throttling_logging()
1942 raw_spin_lock_irqsave(&adev->throttling_logging_rs.lock, flags); in amdgpu_set_thermal_throttling_logging()
1947 adev->throttling_logging_rs.interval = in amdgpu_set_thermal_throttling_logging()
1948 (throttling_logging_interval - 1) * HZ; in amdgpu_set_thermal_throttling_logging()
1949 adev->throttling_logging_rs.begin = 0; in amdgpu_set_thermal_throttling_logging()
1950 adev->throttling_logging_rs.printed = 0; in amdgpu_set_thermal_throttling_logging()
1951 adev->throttling_logging_rs.missed = 0; in amdgpu_set_thermal_throttling_logging()
1952 raw_spin_unlock_irqrestore(&adev->throttling_logging_rs.lock, flags); in amdgpu_set_thermal_throttling_logging()
1954 atomic_set(&adev->throttling_logging_enabled, 1); in amdgpu_set_thermal_throttling_logging()
1956 atomic_set(&adev->throttling_logging_enabled, 0); in amdgpu_set_thermal_throttling_logging()
1985 return -EPERM; in amdgpu_get_gpu_metrics()
1987 ret = pm_runtime_get_sync(ddev->dev); in amdgpu_get_gpu_metrics()
1989 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_gpu_metrics()
1994 size = smu_sys_get_gpu_metrics(&adev->smu, &gpu_metrics); in amdgpu_get_gpu_metrics()
1995 else if (adev->powerplay.pp_funcs->get_gpu_metrics) in amdgpu_get_gpu_metrics()
2002 size = PAGE_SIZE - 1; in amdgpu_get_gpu_metrics()
2007 pm_runtime_mark_last_busy(ddev->dev); in amdgpu_get_gpu_metrics()
2008 pm_runtime_put_autosuspend(ddev->dev); in amdgpu_get_gpu_metrics()
2042 struct device_attribute *dev_attr = &attr->dev_attr; in default_attr_update()
2043 const char *attr_name = dev_attr->attr.name; in default_attr_update()
2044 struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; in default_attr_update()
2045 enum amd_asic_type asic_type = adev->asic_type; in default_attr_update()
2047 if (!(attr->flags & mask)) { in default_attr_update()
2068 if ((is_support_sw_smu(adev) && adev->smu.od_enabled) || in default_attr_update()
2069 (!is_support_sw_smu(adev) && hwmgr->od_enabled)) in default_attr_update()
2072 if (adev->flags & AMD_IS_APU || asic_type == CHIP_VEGA10) in default_attr_update()
2076 if (adev->flags & AMD_IS_APU) in default_attr_update()
2084 if (adev->flags & AMD_IS_APU || asic_type < CHIP_VEGA10) in default_attr_update()
2096 dev_attr->attr.mode &= ~S_IWUGO; in default_attr_update()
2097 dev_attr->store = NULL; in default_attr_update()
2112 struct device_attribute *dev_attr = &attr->dev_attr; in amdgpu_device_attr_create()
2113 const char *name = dev_attr->attr.name; in amdgpu_device_attr_create()
2122 attr_update = attr->attr_update ? attr_update : default_attr_update; in amdgpu_device_attr_create()
2126 dev_err(adev->dev, "failed to update device file %s, ret = %d\n", in amdgpu_device_attr_create()
2134 ret = device_create_file(adev->dev, dev_attr); in amdgpu_device_attr_create()
2136 dev_err(adev->dev, "failed to create device file %s, ret = %d\n", in amdgpu_device_attr_create()
2142 return -ENOMEM; in amdgpu_device_attr_create()
2144 attr_entry->attr = attr; in amdgpu_device_attr_create()
2145 INIT_LIST_HEAD(&attr_entry->entry); in amdgpu_device_attr_create()
2147 list_add_tail(&attr_entry->entry, attr_list); in amdgpu_device_attr_create()
2154 struct device_attribute *dev_attr = &attr->dev_attr; in amdgpu_device_attr_remove()
2156 device_remove_file(adev->dev, dev_attr); in amdgpu_device_attr_remove()
2194 amdgpu_device_attr_remove(adev, entry->attr); in amdgpu_device_attr_remove_groups()
2195 list_del(&entry->entry); in amdgpu_device_attr_remove_groups()
2205 int channel = to_sensor_dev_attr(attr)->index; in amdgpu_hwmon_show_temp()
2209 return -EPERM; in amdgpu_hwmon_show_temp()
2212 return -EINVAL; in amdgpu_hwmon_show_temp()
2214 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_temp()
2216 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_temp()
2237 r = -EINVAL; in amdgpu_hwmon_show_temp()
2241 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_temp()
2242 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_temp()
2255 int hyst = to_sensor_dev_attr(attr)->index; in amdgpu_hwmon_show_temp_thresh()
2259 temp = adev->pm.dpm.thermal.min_temp; in amdgpu_hwmon_show_temp_thresh()
2261 temp = adev->pm.dpm.thermal.max_temp; in amdgpu_hwmon_show_temp_thresh()
2271 int hyst = to_sensor_dev_attr(attr)->index; in amdgpu_hwmon_show_hotspot_temp_thresh()
2275 temp = adev->pm.dpm.thermal.min_hotspot_temp; in amdgpu_hwmon_show_hotspot_temp_thresh()
2277 temp = adev->pm.dpm.thermal.max_hotspot_crit_temp; in amdgpu_hwmon_show_hotspot_temp_thresh()
2287 int hyst = to_sensor_dev_attr(attr)->index; in amdgpu_hwmon_show_mem_temp_thresh()
2291 temp = adev->pm.dpm.thermal.min_mem_temp; in amdgpu_hwmon_show_mem_temp_thresh()
2293 temp = adev->pm.dpm.thermal.max_mem_crit_temp; in amdgpu_hwmon_show_mem_temp_thresh()
2302 int channel = to_sensor_dev_attr(attr)->index; in amdgpu_hwmon_show_temp_label()
2305 return -EINVAL; in amdgpu_hwmon_show_temp_label()
2315 int channel = to_sensor_dev_attr(attr)->index; in amdgpu_hwmon_show_temp_emergency()
2319 return -EINVAL; in amdgpu_hwmon_show_temp_emergency()
2323 temp = adev->pm.dpm.thermal.max_hotspot_emergency_temp; in amdgpu_hwmon_show_temp_emergency()
2326 temp = adev->pm.dpm.thermal.max_edge_emergency_temp; in amdgpu_hwmon_show_temp_emergency()
2329 temp = adev->pm.dpm.thermal.max_mem_emergency_temp; in amdgpu_hwmon_show_temp_emergency()
2345 return -EPERM; in amdgpu_hwmon_get_pwm1_enable()
2347 ret = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1_enable()
2349 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1_enable()
2354 pwm_mode = smu_get_fan_control_mode(&adev->smu); in amdgpu_hwmon_get_pwm1_enable()
2356 if (!adev->powerplay.pp_funcs->get_fan_control_mode) { in amdgpu_hwmon_get_pwm1_enable()
2357 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1_enable()
2358 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1_enable()
2359 return -EINVAL; in amdgpu_hwmon_get_pwm1_enable()
2365 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1_enable()
2366 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1_enable()
2381 return -EPERM; in amdgpu_hwmon_set_pwm1_enable()
2387 ret = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1_enable()
2389 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1_enable()
2394 smu_set_fan_control_mode(&adev->smu, value); in amdgpu_hwmon_set_pwm1_enable()
2396 if (!adev->powerplay.pp_funcs->set_fan_control_mode) { in amdgpu_hwmon_set_pwm1_enable()
2397 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1_enable()
2398 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1_enable()
2399 return -EINVAL; in amdgpu_hwmon_set_pwm1_enable()
2405 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1_enable()
2406 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1_enable()
2435 return -EPERM; in amdgpu_hwmon_set_pwm1()
2437 err = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1()
2439 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1()
2444 pwm_mode = smu_get_fan_control_mode(&adev->smu); in amdgpu_hwmon_set_pwm1()
2450 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1()
2451 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1()
2452 return -EINVAL; in amdgpu_hwmon_set_pwm1()
2457 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1()
2458 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1()
2465 err = smu_set_fan_speed_percent(&adev->smu, value); in amdgpu_hwmon_set_pwm1()
2466 else if (adev->powerplay.pp_funcs->set_fan_speed_percent) in amdgpu_hwmon_set_pwm1()
2469 err = -EINVAL; in amdgpu_hwmon_set_pwm1()
2471 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1()
2472 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_pwm1()
2489 return -EPERM; in amdgpu_hwmon_get_pwm1()
2491 err = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1()
2493 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1()
2498 err = smu_get_fan_speed_percent(&adev->smu, &speed); in amdgpu_hwmon_get_pwm1()
2499 else if (adev->powerplay.pp_funcs->get_fan_speed_percent) in amdgpu_hwmon_get_pwm1()
2502 err = -EINVAL; in amdgpu_hwmon_get_pwm1()
2504 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1()
2505 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_pwm1()
2524 return -EPERM; in amdgpu_hwmon_get_fan1_input()
2526 err = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_input()
2528 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_input()
2533 err = smu_get_fan_speed_rpm(&adev->smu, &speed); in amdgpu_hwmon_get_fan1_input()
2534 else if (adev->powerplay.pp_funcs->get_fan_speed_rpm) in amdgpu_hwmon_get_fan1_input()
2537 err = -EINVAL; in amdgpu_hwmon_get_fan1_input()
2539 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_input()
2540 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_input()
2558 return -EPERM; in amdgpu_hwmon_get_fan1_min()
2560 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_min()
2562 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_min()
2569 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_min()
2570 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_min()
2588 return -EPERM; in amdgpu_hwmon_get_fan1_max()
2590 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_max()
2592 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_max()
2599 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_max()
2600 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_max()
2617 return -EPERM; in amdgpu_hwmon_get_fan1_target()
2619 err = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_target()
2621 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_target()
2626 err = smu_get_fan_speed_rpm(&adev->smu, &rpm); in amdgpu_hwmon_get_fan1_target()
2627 else if (adev->powerplay.pp_funcs->get_fan_speed_rpm) in amdgpu_hwmon_get_fan1_target()
2630 err = -EINVAL; in amdgpu_hwmon_get_fan1_target()
2632 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_target()
2633 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_target()
2651 return -EPERM; in amdgpu_hwmon_set_fan1_target()
2653 err = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_target()
2655 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_target()
2660 pwm_mode = smu_get_fan_control_mode(&adev->smu); in amdgpu_hwmon_set_fan1_target()
2665 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_target()
2666 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_target()
2667 return -ENODATA; in amdgpu_hwmon_set_fan1_target()
2672 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_target()
2673 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_target()
2678 err = smu_set_fan_speed_rpm(&adev->smu, value); in amdgpu_hwmon_set_fan1_target()
2679 else if (adev->powerplay.pp_funcs->set_fan_speed_rpm) in amdgpu_hwmon_set_fan1_target()
2682 err = -EINVAL; in amdgpu_hwmon_set_fan1_target()
2684 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_target()
2685 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_target()
2702 return -EPERM; in amdgpu_hwmon_get_fan1_enable()
2704 ret = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_enable()
2706 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_enable()
2711 pwm_mode = smu_get_fan_control_mode(&adev->smu); in amdgpu_hwmon_get_fan1_enable()
2713 if (!adev->powerplay.pp_funcs->get_fan_control_mode) { in amdgpu_hwmon_get_fan1_enable()
2714 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_enable()
2715 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_enable()
2716 return -EINVAL; in amdgpu_hwmon_get_fan1_enable()
2722 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_enable()
2723 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_get_fan1_enable()
2739 return -EPERM; in amdgpu_hwmon_set_fan1_enable()
2750 return -EINVAL; in amdgpu_hwmon_set_fan1_enable()
2752 err = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_enable()
2754 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_enable()
2759 smu_set_fan_control_mode(&adev->smu, pwm_mode); in amdgpu_hwmon_set_fan1_enable()
2761 if (!adev->powerplay.pp_funcs->set_fan_control_mode) { in amdgpu_hwmon_set_fan1_enable()
2762 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_enable()
2763 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_enable()
2764 return -EINVAL; in amdgpu_hwmon_set_fan1_enable()
2769 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_enable()
2770 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_fan1_enable()
2784 return -EPERM; in amdgpu_hwmon_show_vddgfx()
2786 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_vddgfx()
2788 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_vddgfx()
2796 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_vddgfx()
2797 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_vddgfx()
2821 return -EPERM; in amdgpu_hwmon_show_vddnb()
2824 if (!(adev->flags & AMD_IS_APU)) in amdgpu_hwmon_show_vddnb()
2825 return -EINVAL; in amdgpu_hwmon_show_vddnb()
2827 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_vddnb()
2829 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_vddnb()
2837 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_vddnb()
2838 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_vddnb()
2863 return -EPERM; in amdgpu_hwmon_show_power_avg()
2865 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_avg()
2867 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_avg()
2875 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_avg()
2876 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_avg()
2904 return -EPERM; in amdgpu_hwmon_show_power_cap_max()
2906 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_cap_max()
2908 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_cap_max()
2913 smu_get_power_limit(&adev->smu, &limit, true); in amdgpu_hwmon_show_power_cap_max()
2915 } else if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_power_limit) { in amdgpu_hwmon_show_power_cap_max()
2916 adev->powerplay.pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit, true); in amdgpu_hwmon_show_power_cap_max()
2922 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_cap_max()
2923 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_cap_max()
2938 return -EPERM; in amdgpu_hwmon_show_power_cap()
2940 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_cap()
2942 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_cap()
2947 smu_get_power_limit(&adev->smu, &limit, false); in amdgpu_hwmon_show_power_cap()
2949 } else if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_power_limit) { in amdgpu_hwmon_show_power_cap()
2950 adev->powerplay.pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit, false); in amdgpu_hwmon_show_power_cap()
2956 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_cap()
2957 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_power_cap()
2973 return -EPERM; in amdgpu_hwmon_set_power_cap()
2976 return -EINVAL; in amdgpu_hwmon_set_power_cap()
2985 err = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_power_cap()
2987 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_power_cap()
2992 err = smu_set_power_limit(&adev->smu, value); in amdgpu_hwmon_set_power_cap()
2993 else if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_power_limit) in amdgpu_hwmon_set_power_cap()
2994 err = adev->powerplay.pp_funcs->set_power_limit(adev->powerplay.pp_handle, value); in amdgpu_hwmon_set_power_cap()
2996 err = -EINVAL; in amdgpu_hwmon_set_power_cap()
2998 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_power_cap()
2999 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_set_power_cap()
3016 return -EPERM; in amdgpu_hwmon_show_sclk()
3018 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_sclk()
3020 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_sclk()
3028 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_sclk()
3029 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_sclk()
3053 return -EPERM; in amdgpu_hwmon_show_mclk()
3055 r = pm_runtime_get_sync(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_mclk()
3057 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_mclk()
3065 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_mclk()
3066 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); in amdgpu_hwmon_show_mclk()
3086 * - GPU temperature (via the on-die sensor)
3088 * - GPU voltage
3090 * - Northbridge voltage (APUs only)
3092 * - GPU power
3094 * - GPU fan
3096 * - GPU gfx/compute engine clock
3098 * - GPU memory clock (dGPU only)
3102 * - temp[1-3]_input: the on die GPU temperature in millidegrees Celsius
3103 * - temp2_input and temp3_input are supported on SOC15 dGPUs only
3105 * - temp[1-3]_label: temperature channel label
3106 * - temp2_label and temp3_label are supported on SOC15 dGPUs only
3108 * - temp[1-3]_crit: temperature critical max value in millidegrees Celsius
3109 * - temp2_crit and temp3_crit are supported on SOC15 dGPUs only
3111 * - temp[1-3]_crit_hyst: temperature hysteresis for critical limit in millidegrees Celsius
3112 * - temp2_crit_hyst and temp3_crit_hyst are supported on SOC15 dGPUs only
3114 * - temp[1-3]_emergency: temperature emergency max value(asic shutdown) in millidegrees Celsius
3115 * - these are supported on SOC15 dGPUs only
3119 * - in0_input: the voltage on the GPU in millivolts
3121 * - in1_input: the voltage on the Northbridge in millivolts
3125 * - power1_average: average power used by the GPU in microWatts
3127 * - power1_cap_min: minimum cap supported in microWatts
3129 * - power1_cap_max: maximum cap supported in microWatts
3131 * - power1_cap: selected power cap in microWatts
3135 * - pwm1: pulse width modulation fan level (0-255)
3137 …* - pwm1_enable: pulse width modulation fan control method (0: no fan speed control, 1: manual fan…
3139 * - pwm1_min: pulse width modulation fan control minimum level (0)
3141 * - pwm1_max: pulse width modulation fan control maximum level (255)
3143 * - fan1_min: an minimum value Unit: revolution/min (RPM)
3145 * - fan1_max: an maxmum value Unit: revolution/max (RPM)
3147 * - fan1_input: fan speed in RPM
3149 * - fan[1-\*]_target: Desired fan speed Unit: revolution/min (RPM)
3151 * - fan[1-\*]_enable: Enable or disable the sensors.1: Enable 0: Disable
3155 * - freq1_input: the gfx/compute clock in hertz
3157 * - freq2_input: the memory clock in hertz
3245 umode_t effective_mode = attr->mode; in hwmon_attributes_visible()
3247 /* under multi-vf mode, the hwmon attributes are all not supported */ in hwmon_attributes_visible()
3265 if (adev->pm.no_fan && (attr == &sensor_dev_attr_pwm1.dev_attr.attr || in hwmon_attributes_visible()
3277 if ((adev->flags & AMD_IS_APU) && in hwmon_attributes_visible()
3290 if ((adev->flags & AMD_IS_APU) && (adev->family >= AMDGPU_FAMILY_CZ) && in hwmon_attributes_visible()
3296 if (!adev->pm.dpm_enabled && in hwmon_attributes_visible()
3312 if ((!adev->powerplay.pp_funcs->get_fan_speed_percent && in hwmon_attributes_visible()
3314 (!adev->powerplay.pp_funcs->get_fan_control_mode && in hwmon_attributes_visible()
3318 if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && in hwmon_attributes_visible()
3320 (!adev->powerplay.pp_funcs->set_fan_control_mode && in hwmon_attributes_visible()
3325 if (((adev->flags & AMD_IS_APU) || in hwmon_attributes_visible()
3326 adev->family == AMDGPU_FAMILY_SI) && /* not implemented yet */ in hwmon_attributes_visible()
3332 if (((adev->family == AMDGPU_FAMILY_SI) || in hwmon_attributes_visible()
3333 ((adev->flags & AMD_IS_APU) && in hwmon_attributes_visible()
3334 (adev->asic_type < CHIP_RENOIR))) && /* not implemented yet */ in hwmon_attributes_visible()
3340 if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && in hwmon_attributes_visible()
3341 !adev->powerplay.pp_funcs->get_fan_speed_percent) && in hwmon_attributes_visible()
3342 (!adev->powerplay.pp_funcs->set_fan_speed_rpm && in hwmon_attributes_visible()
3343 !adev->powerplay.pp_funcs->get_fan_speed_rpm) && in hwmon_attributes_visible()
3348 if ((!adev->powerplay.pp_funcs->set_fan_speed_rpm && in hwmon_attributes_visible()
3349 !adev->powerplay.pp_funcs->get_fan_speed_rpm) && in hwmon_attributes_visible()
3355 if ((adev->family == AMDGPU_FAMILY_SI || /* not implemented yet */ in hwmon_attributes_visible()
3356 adev->family == AMDGPU_FAMILY_KV) && /* not implemented yet */ in hwmon_attributes_visible()
3362 if (!(adev->flags & AMD_IS_APU) && in hwmon_attributes_visible()
3368 if ((adev->flags & AMD_IS_APU) && in hwmon_attributes_visible()
3374 if (((adev->flags & AMD_IS_APU) || in hwmon_attributes_visible()
3375 adev->asic_type < CHIP_VEGA10) && in hwmon_attributes_visible()
3407 if (adev->pm.sysfs_initialized) in amdgpu_pm_sysfs_init()
3410 if (adev->pm.dpm_enabled == 0) in amdgpu_pm_sysfs_init()
3413 INIT_LIST_HEAD(&adev->pm.pm_attr_list); in amdgpu_pm_sysfs_init()
3415 adev->pm.int_hwmon_dev = hwmon_device_register_with_groups(adev->dev, in amdgpu_pm_sysfs_init()
3418 if (IS_ERR(adev->pm.int_hwmon_dev)) { in amdgpu_pm_sysfs_init()
3419 ret = PTR_ERR(adev->pm.int_hwmon_dev); in amdgpu_pm_sysfs_init()
3420 dev_err(adev->dev, in amdgpu_pm_sysfs_init()
3442 &adev->pm.pm_attr_list); in amdgpu_pm_sysfs_init()
3446 adev->pm.sysfs_initialized = true; in amdgpu_pm_sysfs_init()
3453 if (adev->pm.dpm_enabled == 0) in amdgpu_pm_sysfs_fini()
3456 if (adev->pm.int_hwmon_dev) in amdgpu_pm_sysfs_fini()
3457 hwmon_device_unregister(adev->pm.int_hwmon_dev); in amdgpu_pm_sysfs_fini()
3459 amdgpu_device_attr_remove_groups(adev, &adev->pm.pm_attr_list); in amdgpu_pm_sysfs_fini()
3512 if (adev->asic_type > CHIP_VEGA20) { in amdgpu_debugfs_pm_info_pp()
3567 struct drm_info_node *node = (struct drm_info_node *) m->private; in amdgpu_debugfs_pm_info()
3568 struct drm_device *dev = node->minor->dev; in amdgpu_debugfs_pm_info()
3574 return -EPERM; in amdgpu_debugfs_pm_info()
3576 r = pm_runtime_get_sync(dev->dev); in amdgpu_debugfs_pm_info()
3578 pm_runtime_put_autosuspend(dev->dev); in amdgpu_debugfs_pm_info()
3582 if (!adev->pm.dpm_enabled) { in amdgpu_debugfs_pm_info()
3584 pm_runtime_mark_last_busy(dev->dev); in amdgpu_debugfs_pm_info()
3585 pm_runtime_put_autosuspend(dev->dev); in amdgpu_debugfs_pm_info()
3590 adev->powerplay.pp_funcs->debugfs_print_current_performance_level) { in amdgpu_debugfs_pm_info()
3591 mutex_lock(&adev->pm.mutex); in amdgpu_debugfs_pm_info()
3592 if (adev->powerplay.pp_funcs->debugfs_print_current_performance_level) in amdgpu_debugfs_pm_info()
3593 adev->powerplay.pp_funcs->debugfs_print_current_performance_level(adev, m); in amdgpu_debugfs_pm_info()
3596 mutex_unlock(&adev->pm.mutex); in amdgpu_debugfs_pm_info()
3611 pm_runtime_mark_last_busy(dev->dev); in amdgpu_debugfs_pm_info()
3612 pm_runtime_put_autosuspend(dev->dev); in amdgpu_debugfs_pm_info()