Lines Matching refs:rdev
51 static void radeon_debugfs_pm_init(struct radeon_device *rdev);
52 static bool radeon_pm_in_vbl(struct radeon_device *rdev);
53 static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish);
54 static void radeon_pm_update_profile(struct radeon_device *rdev);
55 static void radeon_pm_set_clocks(struct radeon_device *rdev);
57 int radeon_pm_get_type_index(struct radeon_device *rdev, in radeon_pm_get_type_index() argument
64 for (i = 0; i < rdev->pm.num_power_states; i++) { in radeon_pm_get_type_index()
65 if (rdev->pm.power_state[i].type == ps_type) { in radeon_pm_get_type_index()
72 return rdev->pm.default_power_state_index; in radeon_pm_get_type_index()
75 void radeon_pm_acpi_event_handler(struct radeon_device *rdev) in radeon_pm_acpi_event_handler() argument
77 if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) { in radeon_pm_acpi_event_handler()
78 mutex_lock(&rdev->pm.mutex); in radeon_pm_acpi_event_handler()
80 rdev->pm.dpm.ac_power = true; in radeon_pm_acpi_event_handler()
82 rdev->pm.dpm.ac_power = false; in radeon_pm_acpi_event_handler()
83 if (rdev->family == CHIP_ARUBA) { in radeon_pm_acpi_event_handler()
84 if (rdev->asic->dpm.enable_bapm) in radeon_pm_acpi_event_handler()
85 radeon_dpm_enable_bapm(rdev, rdev->pm.dpm.ac_power); in radeon_pm_acpi_event_handler()
87 mutex_unlock(&rdev->pm.mutex); in radeon_pm_acpi_event_handler()
88 } else if (rdev->pm.pm_method == PM_METHOD_PROFILE) { in radeon_pm_acpi_event_handler()
89 if (rdev->pm.profile == PM_PROFILE_AUTO) { in radeon_pm_acpi_event_handler()
90 mutex_lock(&rdev->pm.mutex); in radeon_pm_acpi_event_handler()
91 radeon_pm_update_profile(rdev); in radeon_pm_acpi_event_handler()
92 radeon_pm_set_clocks(rdev); in radeon_pm_acpi_event_handler()
93 mutex_unlock(&rdev->pm.mutex); in radeon_pm_acpi_event_handler()
98 static void radeon_pm_update_profile(struct radeon_device *rdev) in radeon_pm_update_profile() argument
100 switch (rdev->pm.profile) { in radeon_pm_update_profile()
102 rdev->pm.profile_index = PM_PROFILE_DEFAULT_IDX; in radeon_pm_update_profile()
106 if (rdev->pm.active_crtc_count > 1) in radeon_pm_update_profile()
107 rdev->pm.profile_index = PM_PROFILE_HIGH_MH_IDX; in radeon_pm_update_profile()
109 rdev->pm.profile_index = PM_PROFILE_HIGH_SH_IDX; in radeon_pm_update_profile()
111 if (rdev->pm.active_crtc_count > 1) in radeon_pm_update_profile()
112 rdev->pm.profile_index = PM_PROFILE_MID_MH_IDX; in radeon_pm_update_profile()
114 rdev->pm.profile_index = PM_PROFILE_MID_SH_IDX; in radeon_pm_update_profile()
118 if (rdev->pm.active_crtc_count > 1) in radeon_pm_update_profile()
119 rdev->pm.profile_index = PM_PROFILE_LOW_MH_IDX; in radeon_pm_update_profile()
121 rdev->pm.profile_index = PM_PROFILE_LOW_SH_IDX; in radeon_pm_update_profile()
124 if (rdev->pm.active_crtc_count > 1) in radeon_pm_update_profile()
125 rdev->pm.profile_index = PM_PROFILE_MID_MH_IDX; in radeon_pm_update_profile()
127 rdev->pm.profile_index = PM_PROFILE_MID_SH_IDX; in radeon_pm_update_profile()
130 if (rdev->pm.active_crtc_count > 1) in radeon_pm_update_profile()
131 rdev->pm.profile_index = PM_PROFILE_HIGH_MH_IDX; in radeon_pm_update_profile()
133 rdev->pm.profile_index = PM_PROFILE_HIGH_SH_IDX; in radeon_pm_update_profile()
137 if (rdev->pm.active_crtc_count == 0) { in radeon_pm_update_profile()
138 rdev->pm.requested_power_state_index = in radeon_pm_update_profile()
139 rdev->pm.profiles[rdev->pm.profile_index].dpms_off_ps_idx; in radeon_pm_update_profile()
140 rdev->pm.requested_clock_mode_index = in radeon_pm_update_profile()
141 rdev->pm.profiles[rdev->pm.profile_index].dpms_off_cm_idx; in radeon_pm_update_profile()
143 rdev->pm.requested_power_state_index = in radeon_pm_update_profile()
144 rdev->pm.profiles[rdev->pm.profile_index].dpms_on_ps_idx; in radeon_pm_update_profile()
145 rdev->pm.requested_clock_mode_index = in radeon_pm_update_profile()
146 rdev->pm.profiles[rdev->pm.profile_index].dpms_on_cm_idx; in radeon_pm_update_profile()
150 static void radeon_unmap_vram_bos(struct radeon_device *rdev) in radeon_unmap_vram_bos() argument
154 if (list_empty(&rdev->gem.objects)) in radeon_unmap_vram_bos()
157 list_for_each_entry_safe(bo, n, &rdev->gem.objects, list) { in radeon_unmap_vram_bos()
163 static void radeon_sync_with_vblank(struct radeon_device *rdev) in radeon_sync_with_vblank() argument
165 if (rdev->pm.active_crtcs) { in radeon_sync_with_vblank()
166 rdev->pm.vblank_sync = false; in radeon_sync_with_vblank()
168 rdev->irq.vblank_queue, rdev->pm.vblank_sync, in radeon_sync_with_vblank()
173 static void radeon_set_power_state(struct radeon_device *rdev) in radeon_set_power_state() argument
178 if ((rdev->pm.requested_clock_mode_index == rdev->pm.current_clock_mode_index) && in radeon_set_power_state()
179 (rdev->pm.requested_power_state_index == rdev->pm.current_power_state_index)) in radeon_set_power_state()
182 if (radeon_gui_idle(rdev)) { in radeon_set_power_state()
183 sclk = rdev->pm.power_state[rdev->pm.requested_power_state_index]. in radeon_set_power_state()
184 clock_info[rdev->pm.requested_clock_mode_index].sclk; in radeon_set_power_state()
185 if (sclk > rdev->pm.default_sclk) in radeon_set_power_state()
186 sclk = rdev->pm.default_sclk; in radeon_set_power_state()
192 if ((rdev->pm.pm_method == PM_METHOD_PROFILE) && in radeon_set_power_state()
193 (rdev->family >= CHIP_BARTS) && in radeon_set_power_state()
194 rdev->pm.active_crtc_count && in radeon_set_power_state()
195 ((rdev->pm.profile_index == PM_PROFILE_MID_MH_IDX) || in radeon_set_power_state()
196 (rdev->pm.profile_index == PM_PROFILE_LOW_MH_IDX))) in radeon_set_power_state()
197 mclk = rdev->pm.power_state[rdev->pm.requested_power_state_index]. in radeon_set_power_state()
198 clock_info[rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx].mclk; in radeon_set_power_state()
200 mclk = rdev->pm.power_state[rdev->pm.requested_power_state_index]. in radeon_set_power_state()
201 clock_info[rdev->pm.requested_clock_mode_index].mclk; in radeon_set_power_state()
203 if (mclk > rdev->pm.default_mclk) in radeon_set_power_state()
204 mclk = rdev->pm.default_mclk; in radeon_set_power_state()
207 if (sclk < rdev->pm.current_sclk) in radeon_set_power_state()
210 radeon_sync_with_vblank(rdev); in radeon_set_power_state()
212 if (rdev->pm.pm_method == PM_METHOD_DYNPM) { in radeon_set_power_state()
213 if (!radeon_pm_in_vbl(rdev)) in radeon_set_power_state()
217 radeon_pm_prepare(rdev); in radeon_set_power_state()
221 radeon_pm_misc(rdev); in radeon_set_power_state()
224 if (sclk != rdev->pm.current_sclk) { in radeon_set_power_state()
225 radeon_pm_debug_check_in_vbl(rdev, false); in radeon_set_power_state()
226 radeon_set_engine_clock(rdev, sclk); in radeon_set_power_state()
227 radeon_pm_debug_check_in_vbl(rdev, true); in radeon_set_power_state()
228 rdev->pm.current_sclk = sclk; in radeon_set_power_state()
233 if (rdev->asic->pm.set_memory_clock && (mclk != rdev->pm.current_mclk)) { in radeon_set_power_state()
234 radeon_pm_debug_check_in_vbl(rdev, false); in radeon_set_power_state()
235 radeon_set_memory_clock(rdev, mclk); in radeon_set_power_state()
236 radeon_pm_debug_check_in_vbl(rdev, true); in radeon_set_power_state()
237 rdev->pm.current_mclk = mclk; in radeon_set_power_state()
243 radeon_pm_misc(rdev); in radeon_set_power_state()
245 radeon_pm_finish(rdev); in radeon_set_power_state()
247 rdev->pm.current_power_state_index = rdev->pm.requested_power_state_index; in radeon_set_power_state()
248 rdev->pm.current_clock_mode_index = rdev->pm.requested_clock_mode_index; in radeon_set_power_state()
253 static void radeon_pm_set_clocks(struct radeon_device *rdev) in radeon_pm_set_clocks() argument
259 if ((rdev->pm.requested_clock_mode_index == rdev->pm.current_clock_mode_index) && in radeon_pm_set_clocks()
260 (rdev->pm.requested_power_state_index == rdev->pm.current_power_state_index)) in radeon_pm_set_clocks()
263 down_write(&rdev->pm.mclk_lock); in radeon_pm_set_clocks()
264 mutex_lock(&rdev->ring_lock); in radeon_pm_set_clocks()
268 struct radeon_ring *ring = &rdev->ring[i]; in radeon_pm_set_clocks()
272 r = radeon_fence_wait_empty(rdev, i); in radeon_pm_set_clocks()
275 mutex_unlock(&rdev->ring_lock); in radeon_pm_set_clocks()
276 up_write(&rdev->pm.mclk_lock); in radeon_pm_set_clocks()
281 radeon_unmap_vram_bos(rdev); in radeon_pm_set_clocks()
283 if (rdev->irq.installed) { in radeon_pm_set_clocks()
285 drm_for_each_crtc(crtc, rdev_to_drm(rdev)) { in radeon_pm_set_clocks()
286 if (rdev->pm.active_crtcs & (1 << i)) { in radeon_pm_set_clocks()
289 rdev->pm.req_vblank |= (1 << i); in radeon_pm_set_clocks()
298 radeon_set_power_state(rdev); in radeon_pm_set_clocks()
300 if (rdev->irq.installed) { in radeon_pm_set_clocks()
302 drm_for_each_crtc(crtc, rdev_to_drm(rdev)) { in radeon_pm_set_clocks()
303 if (rdev->pm.req_vblank & (1 << i)) { in radeon_pm_set_clocks()
304 rdev->pm.req_vblank &= ~(1 << i); in radeon_pm_set_clocks()
312 radeon_update_bandwidth_info(rdev); in radeon_pm_set_clocks()
313 if (rdev->pm.active_crtc_count) in radeon_pm_set_clocks()
314 radeon_bandwidth_update(rdev); in radeon_pm_set_clocks()
316 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE; in radeon_pm_set_clocks()
318 mutex_unlock(&rdev->ring_lock); in radeon_pm_set_clocks()
319 up_write(&rdev->pm.mclk_lock); in radeon_pm_set_clocks()
322 static void radeon_pm_print_states(struct radeon_device *rdev) in radeon_pm_print_states() argument
328 DRM_DEBUG_DRIVER("%d Power State(s)\n", rdev->pm.num_power_states); in radeon_pm_print_states()
329 for (i = 0; i < rdev->pm.num_power_states; i++) { in radeon_pm_print_states()
330 power_state = &rdev->pm.power_state[i]; in radeon_pm_print_states()
333 if (i == rdev->pm.default_power_state_index) in radeon_pm_print_states()
335 if ((rdev->flags & RADEON_IS_PCIE) && !(rdev->flags & RADEON_IS_IGP)) in radeon_pm_print_states()
342 if (rdev->flags & RADEON_IS_IGP) in radeon_pm_print_states()
361 struct radeon_device *rdev = ddev->dev_private; in radeon_get_pm_profile() local
362 int cp = rdev->pm.profile; in radeon_get_pm_profile()
376 struct radeon_device *rdev = ddev->dev_private; in radeon_set_pm_profile() local
379 if ((rdev->flags & RADEON_IS_PX) && in radeon_set_pm_profile()
383 mutex_lock(&rdev->pm.mutex); in radeon_set_pm_profile()
384 if (rdev->pm.pm_method == PM_METHOD_PROFILE) { in radeon_set_pm_profile()
386 rdev->pm.profile = PM_PROFILE_DEFAULT; in radeon_set_pm_profile()
388 rdev->pm.profile = PM_PROFILE_AUTO; in radeon_set_pm_profile()
390 rdev->pm.profile = PM_PROFILE_LOW; in radeon_set_pm_profile()
392 rdev->pm.profile = PM_PROFILE_MID; in radeon_set_pm_profile()
394 rdev->pm.profile = PM_PROFILE_HIGH; in radeon_set_pm_profile()
399 radeon_pm_update_profile(rdev); in radeon_set_pm_profile()
400 radeon_pm_set_clocks(rdev); in radeon_set_pm_profile()
405 mutex_unlock(&rdev->pm.mutex); in radeon_set_pm_profile()
415 struct radeon_device *rdev = ddev->dev_private; in radeon_get_pm_method() local
416 int pm = rdev->pm.pm_method; in radeon_get_pm_method()
428 struct radeon_device *rdev = ddev->dev_private; in radeon_set_pm_method() local
431 if ((rdev->flags & RADEON_IS_PX) && in radeon_set_pm_method()
438 if (rdev->pm.pm_method == PM_METHOD_DPM) { in radeon_set_pm_method()
444 mutex_lock(&rdev->pm.mutex); in radeon_set_pm_method()
445 rdev->pm.pm_method = PM_METHOD_DYNPM; in radeon_set_pm_method()
446 rdev->pm.dynpm_state = DYNPM_STATE_PAUSED; in radeon_set_pm_method()
447 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT; in radeon_set_pm_method()
448 mutex_unlock(&rdev->pm.mutex); in radeon_set_pm_method()
450 mutex_lock(&rdev->pm.mutex); in radeon_set_pm_method()
452 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED; in radeon_set_pm_method()
453 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE; in radeon_set_pm_method()
454 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_set_pm_method()
455 mutex_unlock(&rdev->pm.mutex); in radeon_set_pm_method()
456 cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work); in radeon_set_pm_method()
461 radeon_pm_compute_clocks(rdev); in radeon_set_pm_method()
471 struct radeon_device *rdev = ddev->dev_private; in radeon_get_dpm_state() local
472 enum radeon_pm_state_type pm = rdev->pm.dpm.user_state; in radeon_get_dpm_state()
485 struct radeon_device *rdev = ddev->dev_private; in radeon_set_dpm_state() local
487 mutex_lock(&rdev->pm.mutex); in radeon_set_dpm_state()
489 rdev->pm.dpm.user_state = POWER_STATE_TYPE_BATTERY; in radeon_set_dpm_state()
491 rdev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; in radeon_set_dpm_state()
493 rdev->pm.dpm.user_state = POWER_STATE_TYPE_PERFORMANCE; in radeon_set_dpm_state()
495 mutex_unlock(&rdev->pm.mutex); in radeon_set_dpm_state()
499 mutex_unlock(&rdev->pm.mutex); in radeon_set_dpm_state()
502 if (!(rdev->flags & RADEON_IS_PX) || in radeon_set_dpm_state()
504 radeon_pm_compute_clocks(rdev); in radeon_set_dpm_state()
515 struct radeon_device *rdev = ddev->dev_private; in radeon_get_dpm_forced_performance_level() local
516 enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level; in radeon_get_dpm_forced_performance_level()
518 if ((rdev->flags & RADEON_IS_PX) && in radeon_get_dpm_forced_performance_level()
533 struct radeon_device *rdev = ddev->dev_private; in radeon_set_dpm_forced_performance_level() local
538 if ((rdev->flags & RADEON_IS_PX) && in radeon_set_dpm_forced_performance_level()
542 mutex_lock(&rdev->pm.mutex); in radeon_set_dpm_forced_performance_level()
553 if (rdev->asic->dpm.force_performance_level) { in radeon_set_dpm_forced_performance_level()
554 if (rdev->pm.dpm.thermal_active) { in radeon_set_dpm_forced_performance_level()
558 ret = radeon_dpm_force_performance_level(rdev, level); in radeon_set_dpm_forced_performance_level()
563 mutex_unlock(&rdev->pm.mutex); in radeon_set_dpm_forced_performance_level()
572 struct radeon_device *rdev = dev_get_drvdata(dev); in radeon_hwmon_get_pwm1_enable() local
575 if (rdev->asic->dpm.fan_ctrl_get_mode) in radeon_hwmon_get_pwm1_enable()
576 pwm_mode = rdev->asic->dpm.fan_ctrl_get_mode(rdev); in radeon_hwmon_get_pwm1_enable()
587 struct radeon_device *rdev = dev_get_drvdata(dev); in radeon_hwmon_set_pwm1_enable() local
591 if (!rdev->asic->dpm.fan_ctrl_set_mode) in radeon_hwmon_set_pwm1_enable()
600 rdev->asic->dpm.fan_ctrl_set_mode(rdev, FDO_PWM_MODE_STATIC); in radeon_hwmon_set_pwm1_enable()
603 rdev->asic->dpm.fan_ctrl_set_mode(rdev, 0); in radeon_hwmon_set_pwm1_enable()
628 struct radeon_device *rdev = dev_get_drvdata(dev); in radeon_hwmon_set_pwm1() local
638 err = rdev->asic->dpm.set_fan_speed_percent(rdev, value); in radeon_hwmon_set_pwm1()
649 struct radeon_device *rdev = dev_get_drvdata(dev); in radeon_hwmon_get_pwm1() local
653 err = rdev->asic->dpm.get_fan_speed_percent(rdev, &speed); in radeon_hwmon_get_pwm1()
673 struct radeon_device *rdev = dev_get_drvdata(dev); in radeon_hwmon_show_temp() local
674 struct drm_device *ddev = rdev_to_drm(rdev); in radeon_hwmon_show_temp()
678 if ((rdev->flags & RADEON_IS_PX) && in radeon_hwmon_show_temp()
682 if (rdev->asic->pm.get_temperature) in radeon_hwmon_show_temp()
683 temp = radeon_get_temperature(rdev); in radeon_hwmon_show_temp()
694 struct radeon_device *rdev = dev_get_drvdata(dev); in radeon_hwmon_show_temp_thresh() local
699 temp = rdev->pm.dpm.thermal.min_temp; in radeon_hwmon_show_temp_thresh()
701 temp = rdev->pm.dpm.thermal.max_temp; in radeon_hwmon_show_temp_thresh()
717 struct radeon_device *rdev = dev_get_drvdata(dev); in radeon_hwmon_show_sclk() local
718 struct drm_device *ddev = rdev_to_drm(rdev); in radeon_hwmon_show_sclk()
722 if ((rdev->flags & RADEON_IS_PX) && in radeon_hwmon_show_sclk()
726 if (rdev->asic->dpm.get_current_sclk) in radeon_hwmon_show_sclk()
727 sclk = radeon_dpm_get_current_sclk(rdev); in radeon_hwmon_show_sclk()
742 struct radeon_device *rdev = dev_get_drvdata(dev); in radeon_hwmon_show_vddc() local
743 struct drm_device *ddev = rdev_to_drm(rdev); in radeon_hwmon_show_vddc()
747 if ((rdev->flags & RADEON_IS_PX) && in radeon_hwmon_show_vddc()
751 if (rdev->asic->dpm.get_current_vddc) in radeon_hwmon_show_vddc()
752 vddc = rdev->asic->dpm.get_current_vddc(rdev); in radeon_hwmon_show_vddc()
777 struct radeon_device *rdev = dev_get_drvdata(dev); in hwmon_attributes_visible() local
781 if (rdev->pm.pm_method != PM_METHOD_DPM && in hwmon_attributes_visible()
794 !rdev->asic->dpm.get_current_vddc) in hwmon_attributes_visible()
798 if (rdev->pm.no_fan && in hwmon_attributes_visible()
806 if ((!rdev->asic->dpm.get_fan_speed_percent && in hwmon_attributes_visible()
808 (!rdev->asic->dpm.fan_ctrl_get_mode && in hwmon_attributes_visible()
812 if ((!rdev->asic->dpm.set_fan_speed_percent && in hwmon_attributes_visible()
814 (!rdev->asic->dpm.fan_ctrl_set_mode && in hwmon_attributes_visible()
819 if ((!rdev->asic->dpm.set_fan_speed_percent && in hwmon_attributes_visible()
820 !rdev->asic->dpm.get_fan_speed_percent) && in hwmon_attributes_visible()
838 static int radeon_hwmon_init(struct radeon_device *rdev) in radeon_hwmon_init() argument
842 switch (rdev->pm.int_thermal_type) { in radeon_hwmon_init()
851 if (rdev->asic->pm.get_temperature == NULL) in radeon_hwmon_init()
853 rdev->pm.int_hwmon_dev = hwmon_device_register_with_groups(rdev->dev, in radeon_hwmon_init()
854 "radeon", rdev, in radeon_hwmon_init()
856 if (IS_ERR(rdev->pm.int_hwmon_dev)) { in radeon_hwmon_init()
857 err = PTR_ERR(rdev->pm.int_hwmon_dev); in radeon_hwmon_init()
858 dev_err(rdev->dev, in radeon_hwmon_init()
869 static void radeon_hwmon_fini(struct radeon_device *rdev) in radeon_hwmon_fini() argument
871 if (rdev->pm.int_hwmon_dev) in radeon_hwmon_fini()
872 hwmon_device_unregister(rdev->pm.int_hwmon_dev); in radeon_hwmon_fini()
877 struct radeon_device *rdev = in radeon_dpm_thermal_work_handler() local
883 if (!rdev->pm.dpm_enabled) in radeon_dpm_thermal_work_handler()
886 if (rdev->asic->pm.get_temperature) { in radeon_dpm_thermal_work_handler()
887 int temp = radeon_get_temperature(rdev); in radeon_dpm_thermal_work_handler()
889 if (temp < rdev->pm.dpm.thermal.min_temp) in radeon_dpm_thermal_work_handler()
891 dpm_state = rdev->pm.dpm.user_state; in radeon_dpm_thermal_work_handler()
893 if (rdev->pm.dpm.thermal.high_to_low) in radeon_dpm_thermal_work_handler()
895 dpm_state = rdev->pm.dpm.user_state; in radeon_dpm_thermal_work_handler()
897 mutex_lock(&rdev->pm.mutex); in radeon_dpm_thermal_work_handler()
899 rdev->pm.dpm.thermal_active = true; in radeon_dpm_thermal_work_handler()
901 rdev->pm.dpm.thermal_active = false; in radeon_dpm_thermal_work_handler()
902 rdev->pm.dpm.state = dpm_state; in radeon_dpm_thermal_work_handler()
903 mutex_unlock(&rdev->pm.mutex); in radeon_dpm_thermal_work_handler()
905 radeon_pm_compute_clocks(rdev); in radeon_dpm_thermal_work_handler()
908 static bool radeon_dpm_single_display(struct radeon_device *rdev) in radeon_dpm_single_display() argument
910 bool single_display = (rdev->pm.dpm.new_active_crtc_count < 2) ? in radeon_dpm_single_display()
914 if (single_display && rdev->asic->dpm.vblank_too_short) { in radeon_dpm_single_display()
915 if (radeon_dpm_vblank_too_short(rdev)) in radeon_dpm_single_display()
922 if (single_display && (r600_dpm_get_vrefresh(rdev) >= 120)) in radeon_dpm_single_display()
928 static struct radeon_ps *radeon_dpm_pick_power_state(struct radeon_device *rdev, in radeon_dpm_pick_power_state() argument
934 bool single_display = radeon_dpm_single_display(rdev); in radeon_dpm_pick_power_state()
947 for (i = 0; i < rdev->pm.dpm.num_ps; i++) { in radeon_dpm_pick_power_state()
948 ps = &rdev->pm.dpm.ps[i]; in radeon_dpm_pick_power_state()
981 if (rdev->pm.dpm.uvd_ps) in radeon_dpm_pick_power_state()
982 return rdev->pm.dpm.uvd_ps; in radeon_dpm_pick_power_state()
1002 return rdev->pm.dpm.boot_ps; in radeon_dpm_pick_power_state()
1031 if (rdev->pm.dpm.uvd_ps) { in radeon_dpm_pick_power_state()
1032 return rdev->pm.dpm.uvd_ps; in radeon_dpm_pick_power_state()
1055 static void radeon_dpm_change_power_state_locked(struct radeon_device *rdev) in radeon_dpm_change_power_state_locked() argument
1061 bool single_display = radeon_dpm_single_display(rdev); in radeon_dpm_change_power_state_locked()
1064 if (!rdev->pm.dpm_enabled) in radeon_dpm_change_power_state_locked()
1067 if (rdev->pm.dpm.user_state != rdev->pm.dpm.state) { in radeon_dpm_change_power_state_locked()
1069 if ((!rdev->pm.dpm.thermal_active) && in radeon_dpm_change_power_state_locked()
1070 (!rdev->pm.dpm.uvd_active)) in radeon_dpm_change_power_state_locked()
1071 rdev->pm.dpm.state = rdev->pm.dpm.user_state; in radeon_dpm_change_power_state_locked()
1073 dpm_state = rdev->pm.dpm.state; in radeon_dpm_change_power_state_locked()
1075 ps = radeon_dpm_pick_power_state(rdev, dpm_state); in radeon_dpm_change_power_state_locked()
1077 rdev->pm.dpm.requested_ps = ps; in radeon_dpm_change_power_state_locked()
1082 if (rdev->pm.dpm.current_ps == rdev->pm.dpm.requested_ps) { in radeon_dpm_change_power_state_locked()
1084 if (ps->vce_active != rdev->pm.dpm.vce_active) in radeon_dpm_change_power_state_locked()
1087 if (rdev->pm.dpm.single_display != single_display) in radeon_dpm_change_power_state_locked()
1089 if ((rdev->family < CHIP_BARTS) || (rdev->flags & RADEON_IS_IGP)) { in radeon_dpm_change_power_state_locked()
1093 if (rdev->pm.dpm.new_active_crtcs != rdev->pm.dpm.current_active_crtcs) { in radeon_dpm_change_power_state_locked()
1095 radeon_bandwidth_update(rdev); in radeon_dpm_change_power_state_locked()
1097 radeon_dpm_display_configuration_changed(rdev); in radeon_dpm_change_power_state_locked()
1098 rdev->pm.dpm.current_active_crtcs = rdev->pm.dpm.new_active_crtcs; in radeon_dpm_change_power_state_locked()
1099 rdev->pm.dpm.current_active_crtc_count = rdev->pm.dpm.new_active_crtc_count; in radeon_dpm_change_power_state_locked()
1107 if (rdev->pm.dpm.new_active_crtcs == in radeon_dpm_change_power_state_locked()
1108 rdev->pm.dpm.current_active_crtcs) { in radeon_dpm_change_power_state_locked()
1111 if ((rdev->pm.dpm.current_active_crtc_count > 1) && in radeon_dpm_change_power_state_locked()
1112 (rdev->pm.dpm.new_active_crtc_count > 1)) { in radeon_dpm_change_power_state_locked()
1114 radeon_bandwidth_update(rdev); in radeon_dpm_change_power_state_locked()
1116 radeon_dpm_display_configuration_changed(rdev); in radeon_dpm_change_power_state_locked()
1117 rdev->pm.dpm.current_active_crtcs = rdev->pm.dpm.new_active_crtcs; in radeon_dpm_change_power_state_locked()
1118 rdev->pm.dpm.current_active_crtc_count = rdev->pm.dpm.new_active_crtc_count; in radeon_dpm_change_power_state_locked()
1128 radeon_dpm_print_power_state(rdev, rdev->pm.dpm.current_ps); in radeon_dpm_change_power_state_locked()
1130 radeon_dpm_print_power_state(rdev, rdev->pm.dpm.requested_ps); in radeon_dpm_change_power_state_locked()
1133 down_write(&rdev->pm.mclk_lock); in radeon_dpm_change_power_state_locked()
1134 mutex_lock(&rdev->ring_lock); in radeon_dpm_change_power_state_locked()
1137 ps->vce_active = rdev->pm.dpm.vce_active; in radeon_dpm_change_power_state_locked()
1139 ret = radeon_dpm_pre_set_power_state(rdev); in radeon_dpm_change_power_state_locked()
1144 radeon_bandwidth_update(rdev); in radeon_dpm_change_power_state_locked()
1146 radeon_dpm_display_configuration_changed(rdev); in radeon_dpm_change_power_state_locked()
1150 struct radeon_ring *ring = &rdev->ring[i]; in radeon_dpm_change_power_state_locked()
1152 radeon_fence_wait_empty(rdev, i); in radeon_dpm_change_power_state_locked()
1156 radeon_dpm_set_power_state(rdev); in radeon_dpm_change_power_state_locked()
1159 rdev->pm.dpm.current_ps = rdev->pm.dpm.requested_ps; in radeon_dpm_change_power_state_locked()
1161 radeon_dpm_post_set_power_state(rdev); in radeon_dpm_change_power_state_locked()
1163 rdev->pm.dpm.current_active_crtcs = rdev->pm.dpm.new_active_crtcs; in radeon_dpm_change_power_state_locked()
1164 rdev->pm.dpm.current_active_crtc_count = rdev->pm.dpm.new_active_crtc_count; in radeon_dpm_change_power_state_locked()
1165 rdev->pm.dpm.single_display = single_display; in radeon_dpm_change_power_state_locked()
1167 if (rdev->asic->dpm.force_performance_level) { in radeon_dpm_change_power_state_locked()
1168 if (rdev->pm.dpm.thermal_active) { in radeon_dpm_change_power_state_locked()
1169 enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level; in radeon_dpm_change_power_state_locked()
1171 radeon_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_LOW); in radeon_dpm_change_power_state_locked()
1173 rdev->pm.dpm.forced_level = level; in radeon_dpm_change_power_state_locked()
1176 radeon_dpm_force_performance_level(rdev, rdev->pm.dpm.forced_level); in radeon_dpm_change_power_state_locked()
1181 mutex_unlock(&rdev->ring_lock); in radeon_dpm_change_power_state_locked()
1182 up_write(&rdev->pm.mclk_lock); in radeon_dpm_change_power_state_locked()
1185 void radeon_dpm_enable_uvd(struct radeon_device *rdev, bool enable) in radeon_dpm_enable_uvd() argument
1189 if (rdev->asic->dpm.powergate_uvd) { in radeon_dpm_enable_uvd()
1190 mutex_lock(&rdev->pm.mutex); in radeon_dpm_enable_uvd()
1193 enable |= rdev->pm.dpm.sd > 0; in radeon_dpm_enable_uvd()
1194 enable |= rdev->pm.dpm.hd > 0; in radeon_dpm_enable_uvd()
1196 radeon_dpm_powergate_uvd(rdev, !enable); in radeon_dpm_enable_uvd()
1197 mutex_unlock(&rdev->pm.mutex); in radeon_dpm_enable_uvd()
1200 mutex_lock(&rdev->pm.mutex); in radeon_dpm_enable_uvd()
1201 rdev->pm.dpm.uvd_active = true; in radeon_dpm_enable_uvd()
1204 if ((rdev->pm.dpm.sd == 1) && (rdev->pm.dpm.hd == 0)) in radeon_dpm_enable_uvd()
1206 else if ((rdev->pm.dpm.sd == 2) && (rdev->pm.dpm.hd == 0)) in radeon_dpm_enable_uvd()
1208 else if ((rdev->pm.dpm.sd == 0) && (rdev->pm.dpm.hd == 1)) in radeon_dpm_enable_uvd()
1210 else if ((rdev->pm.dpm.sd == 0) && (rdev->pm.dpm.hd == 2)) in radeon_dpm_enable_uvd()
1215 rdev->pm.dpm.state = dpm_state; in radeon_dpm_enable_uvd()
1216 mutex_unlock(&rdev->pm.mutex); in radeon_dpm_enable_uvd()
1218 mutex_lock(&rdev->pm.mutex); in radeon_dpm_enable_uvd()
1219 rdev->pm.dpm.uvd_active = false; in radeon_dpm_enable_uvd()
1220 mutex_unlock(&rdev->pm.mutex); in radeon_dpm_enable_uvd()
1223 radeon_pm_compute_clocks(rdev); in radeon_dpm_enable_uvd()
1227 void radeon_dpm_enable_vce(struct radeon_device *rdev, bool enable) in radeon_dpm_enable_vce() argument
1230 mutex_lock(&rdev->pm.mutex); in radeon_dpm_enable_vce()
1231 rdev->pm.dpm.vce_active = true; in radeon_dpm_enable_vce()
1233 rdev->pm.dpm.vce_level = RADEON_VCE_LEVEL_AC_ALL; in radeon_dpm_enable_vce()
1234 mutex_unlock(&rdev->pm.mutex); in radeon_dpm_enable_vce()
1236 mutex_lock(&rdev->pm.mutex); in radeon_dpm_enable_vce()
1237 rdev->pm.dpm.vce_active = false; in radeon_dpm_enable_vce()
1238 mutex_unlock(&rdev->pm.mutex); in radeon_dpm_enable_vce()
1241 radeon_pm_compute_clocks(rdev); in radeon_dpm_enable_vce()
1244 static void radeon_pm_suspend_old(struct radeon_device *rdev) in radeon_pm_suspend_old() argument
1246 mutex_lock(&rdev->pm.mutex); in radeon_pm_suspend_old()
1247 if (rdev->pm.pm_method == PM_METHOD_DYNPM) { in radeon_pm_suspend_old()
1248 if (rdev->pm.dynpm_state == DYNPM_STATE_ACTIVE) in radeon_pm_suspend_old()
1249 rdev->pm.dynpm_state = DYNPM_STATE_SUSPENDED; in radeon_pm_suspend_old()
1251 mutex_unlock(&rdev->pm.mutex); in radeon_pm_suspend_old()
1253 cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work); in radeon_pm_suspend_old()
1256 static void radeon_pm_suspend_dpm(struct radeon_device *rdev) in radeon_pm_suspend_dpm() argument
1258 mutex_lock(&rdev->pm.mutex); in radeon_pm_suspend_dpm()
1260 radeon_dpm_disable(rdev); in radeon_pm_suspend_dpm()
1262 rdev->pm.dpm.current_ps = rdev->pm.dpm.requested_ps = rdev->pm.dpm.boot_ps; in radeon_pm_suspend_dpm()
1263 rdev->pm.dpm_enabled = false; in radeon_pm_suspend_dpm()
1264 mutex_unlock(&rdev->pm.mutex); in radeon_pm_suspend_dpm()
1267 void radeon_pm_suspend(struct radeon_device *rdev) in radeon_pm_suspend() argument
1269 if (rdev->pm.pm_method == PM_METHOD_DPM) in radeon_pm_suspend()
1270 radeon_pm_suspend_dpm(rdev); in radeon_pm_suspend()
1272 radeon_pm_suspend_old(rdev); in radeon_pm_suspend()
1275 static void radeon_pm_resume_old(struct radeon_device *rdev) in radeon_pm_resume_old() argument
1278 if ((rdev->family >= CHIP_BARTS) && in radeon_pm_resume_old()
1279 (rdev->family <= CHIP_CAYMAN) && in radeon_pm_resume_old()
1280 rdev->mc_fw) { in radeon_pm_resume_old()
1281 if (rdev->pm.default_vddc) in radeon_pm_resume_old()
1282 radeon_atom_set_voltage(rdev, rdev->pm.default_vddc, in radeon_pm_resume_old()
1284 if (rdev->pm.default_vddci) in radeon_pm_resume_old()
1285 radeon_atom_set_voltage(rdev, rdev->pm.default_vddci, in radeon_pm_resume_old()
1287 if (rdev->pm.default_sclk) in radeon_pm_resume_old()
1288 radeon_set_engine_clock(rdev, rdev->pm.default_sclk); in radeon_pm_resume_old()
1289 if (rdev->pm.default_mclk) in radeon_pm_resume_old()
1290 radeon_set_memory_clock(rdev, rdev->pm.default_mclk); in radeon_pm_resume_old()
1293 mutex_lock(&rdev->pm.mutex); in radeon_pm_resume_old()
1294 rdev->pm.current_power_state_index = rdev->pm.default_power_state_index; in radeon_pm_resume_old()
1295 rdev->pm.current_clock_mode_index = 0; in radeon_pm_resume_old()
1296 rdev->pm.current_sclk = rdev->pm.default_sclk; in radeon_pm_resume_old()
1297 rdev->pm.current_mclk = rdev->pm.default_mclk; in radeon_pm_resume_old()
1298 if (rdev->pm.power_state) { in radeon_pm_resume_old()
1299 …rdev->pm.current_vddc = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].vol… in radeon_pm_resume_old()
1300 …rdev->pm.current_vddci = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].vo… in radeon_pm_resume_old()
1302 if (rdev->pm.pm_method == PM_METHOD_DYNPM in radeon_pm_resume_old()
1303 && rdev->pm.dynpm_state == DYNPM_STATE_SUSPENDED) { in radeon_pm_resume_old()
1304 rdev->pm.dynpm_state = DYNPM_STATE_ACTIVE; in radeon_pm_resume_old()
1305 schedule_delayed_work(&rdev->pm.dynpm_idle_work, in radeon_pm_resume_old()
1308 mutex_unlock(&rdev->pm.mutex); in radeon_pm_resume_old()
1309 radeon_pm_compute_clocks(rdev); in radeon_pm_resume_old()
1312 static void radeon_pm_resume_dpm(struct radeon_device *rdev) in radeon_pm_resume_dpm() argument
1317 mutex_lock(&rdev->pm.mutex); in radeon_pm_resume_dpm()
1318 rdev->pm.dpm.current_ps = rdev->pm.dpm.requested_ps = rdev->pm.dpm.boot_ps; in radeon_pm_resume_dpm()
1319 radeon_dpm_setup_asic(rdev); in radeon_pm_resume_dpm()
1320 ret = radeon_dpm_enable(rdev); in radeon_pm_resume_dpm()
1321 mutex_unlock(&rdev->pm.mutex); in radeon_pm_resume_dpm()
1324 rdev->pm.dpm_enabled = true; in radeon_pm_resume_dpm()
1329 if ((rdev->family >= CHIP_BARTS) && in radeon_pm_resume_dpm()
1330 (rdev->family <= CHIP_CAYMAN) && in radeon_pm_resume_dpm()
1331 rdev->mc_fw) { in radeon_pm_resume_dpm()
1332 if (rdev->pm.default_vddc) in radeon_pm_resume_dpm()
1333 radeon_atom_set_voltage(rdev, rdev->pm.default_vddc, in radeon_pm_resume_dpm()
1335 if (rdev->pm.default_vddci) in radeon_pm_resume_dpm()
1336 radeon_atom_set_voltage(rdev, rdev->pm.default_vddci, in radeon_pm_resume_dpm()
1338 if (rdev->pm.default_sclk) in radeon_pm_resume_dpm()
1339 radeon_set_engine_clock(rdev, rdev->pm.default_sclk); in radeon_pm_resume_dpm()
1340 if (rdev->pm.default_mclk) in radeon_pm_resume_dpm()
1341 radeon_set_memory_clock(rdev, rdev->pm.default_mclk); in radeon_pm_resume_dpm()
1345 void radeon_pm_resume(struct radeon_device *rdev) in radeon_pm_resume() argument
1347 if (rdev->pm.pm_method == PM_METHOD_DPM) in radeon_pm_resume()
1348 radeon_pm_resume_dpm(rdev); in radeon_pm_resume()
1350 radeon_pm_resume_old(rdev); in radeon_pm_resume()
1353 static int radeon_pm_init_old(struct radeon_device *rdev) in radeon_pm_init_old() argument
1357 rdev->pm.profile = PM_PROFILE_DEFAULT; in radeon_pm_init_old()
1358 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED; in radeon_pm_init_old()
1359 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE; in radeon_pm_init_old()
1360 rdev->pm.dynpm_can_upclock = true; in radeon_pm_init_old()
1361 rdev->pm.dynpm_can_downclock = true; in radeon_pm_init_old()
1362 rdev->pm.default_sclk = rdev->clock.default_sclk; in radeon_pm_init_old()
1363 rdev->pm.default_mclk = rdev->clock.default_mclk; in radeon_pm_init_old()
1364 rdev->pm.current_sclk = rdev->clock.default_sclk; in radeon_pm_init_old()
1365 rdev->pm.current_mclk = rdev->clock.default_mclk; in radeon_pm_init_old()
1366 rdev->pm.int_thermal_type = THERMAL_TYPE_NONE; in radeon_pm_init_old()
1368 if (rdev->bios) { in radeon_pm_init_old()
1369 if (rdev->is_atom_bios) in radeon_pm_init_old()
1370 radeon_atombios_get_power_modes(rdev); in radeon_pm_init_old()
1372 radeon_combios_get_power_modes(rdev); in radeon_pm_init_old()
1373 radeon_pm_print_states(rdev); in radeon_pm_init_old()
1374 radeon_pm_init_profile(rdev); in radeon_pm_init_old()
1376 if ((rdev->family >= CHIP_BARTS) && in radeon_pm_init_old()
1377 (rdev->family <= CHIP_CAYMAN) && in radeon_pm_init_old()
1378 rdev->mc_fw) { in radeon_pm_init_old()
1379 if (rdev->pm.default_vddc) in radeon_pm_init_old()
1380 radeon_atom_set_voltage(rdev, rdev->pm.default_vddc, in radeon_pm_init_old()
1382 if (rdev->pm.default_vddci) in radeon_pm_init_old()
1383 radeon_atom_set_voltage(rdev, rdev->pm.default_vddci, in radeon_pm_init_old()
1385 if (rdev->pm.default_sclk) in radeon_pm_init_old()
1386 radeon_set_engine_clock(rdev, rdev->pm.default_sclk); in radeon_pm_init_old()
1387 if (rdev->pm.default_mclk) in radeon_pm_init_old()
1388 radeon_set_memory_clock(rdev, rdev->pm.default_mclk); in radeon_pm_init_old()
1393 ret = radeon_hwmon_init(rdev); in radeon_pm_init_old()
1397 INIT_DELAYED_WORK(&rdev->pm.dynpm_idle_work, radeon_dynpm_idle_work_handler); in radeon_pm_init_old()
1399 if (rdev->pm.num_power_states > 1) { in radeon_pm_init_old()
1400 radeon_debugfs_pm_init(rdev); in radeon_pm_init_old()
1407 static void radeon_dpm_print_power_states(struct radeon_device *rdev) in radeon_dpm_print_power_states() argument
1411 for (i = 0; i < rdev->pm.dpm.num_ps; i++) { in radeon_dpm_print_power_states()
1413 radeon_dpm_print_power_state(rdev, &rdev->pm.dpm.ps[i]); in radeon_dpm_print_power_states()
1417 static int radeon_pm_init_dpm(struct radeon_device *rdev) in radeon_pm_init_dpm() argument
1422 rdev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; in radeon_pm_init_dpm()
1423 rdev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; in radeon_pm_init_dpm()
1424 rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO; in radeon_pm_init_dpm()
1425 rdev->pm.default_sclk = rdev->clock.default_sclk; in radeon_pm_init_dpm()
1426 rdev->pm.default_mclk = rdev->clock.default_mclk; in radeon_pm_init_dpm()
1427 rdev->pm.current_sclk = rdev->clock.default_sclk; in radeon_pm_init_dpm()
1428 rdev->pm.current_mclk = rdev->clock.default_mclk; in radeon_pm_init_dpm()
1429 rdev->pm.int_thermal_type = THERMAL_TYPE_NONE; in radeon_pm_init_dpm()
1431 if (rdev->bios && rdev->is_atom_bios) in radeon_pm_init_dpm()
1432 radeon_atombios_get_power_modes(rdev); in radeon_pm_init_dpm()
1437 ret = radeon_hwmon_init(rdev); in radeon_pm_init_dpm()
1441 INIT_WORK(&rdev->pm.dpm.thermal.work, radeon_dpm_thermal_work_handler); in radeon_pm_init_dpm()
1442 mutex_lock(&rdev->pm.mutex); in radeon_pm_init_dpm()
1443 radeon_dpm_init(rdev); in radeon_pm_init_dpm()
1444 rdev->pm.dpm.current_ps = rdev->pm.dpm.requested_ps = rdev->pm.dpm.boot_ps; in radeon_pm_init_dpm()
1446 radeon_dpm_print_power_states(rdev); in radeon_pm_init_dpm()
1447 radeon_dpm_setup_asic(rdev); in radeon_pm_init_dpm()
1448 ret = radeon_dpm_enable(rdev); in radeon_pm_init_dpm()
1449 mutex_unlock(&rdev->pm.mutex); in radeon_pm_init_dpm()
1452 rdev->pm.dpm_enabled = true; in radeon_pm_init_dpm()
1454 radeon_debugfs_pm_init(rdev); in radeon_pm_init_dpm()
1461 rdev->pm.dpm_enabled = false; in radeon_pm_init_dpm()
1462 if ((rdev->family >= CHIP_BARTS) && in radeon_pm_init_dpm()
1463 (rdev->family <= CHIP_CAYMAN) && in radeon_pm_init_dpm()
1464 rdev->mc_fw) { in radeon_pm_init_dpm()
1465 if (rdev->pm.default_vddc) in radeon_pm_init_dpm()
1466 radeon_atom_set_voltage(rdev, rdev->pm.default_vddc, in radeon_pm_init_dpm()
1468 if (rdev->pm.default_vddci) in radeon_pm_init_dpm()
1469 radeon_atom_set_voltage(rdev, rdev->pm.default_vddci, in radeon_pm_init_dpm()
1471 if (rdev->pm.default_sclk) in radeon_pm_init_dpm()
1472 radeon_set_engine_clock(rdev, rdev->pm.default_sclk); in radeon_pm_init_dpm()
1473 if (rdev->pm.default_mclk) in radeon_pm_init_dpm()
1474 radeon_set_memory_clock(rdev, rdev->pm.default_mclk); in radeon_pm_init_dpm()
1496 int radeon_pm_init(struct radeon_device *rdev) in radeon_pm_init() argument
1503 if (rdev->pdev->vendor == p->chip_vendor && in radeon_pm_init()
1504 rdev->pdev->device == p->chip_device && in radeon_pm_init()
1505 rdev->pdev->subsystem_vendor == p->subsys_vendor && in radeon_pm_init()
1506 rdev->pdev->subsystem_device == p->subsys_device) { in radeon_pm_init()
1514 switch (rdev->family) { in radeon_pm_init()
1524 if (!rdev->rlc_fw) in radeon_pm_init()
1525 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_pm_init()
1526 else if ((rdev->family >= CHIP_RV770) && in radeon_pm_init()
1527 (!(rdev->flags & RADEON_IS_IGP)) && in radeon_pm_init()
1528 (!rdev->smc_fw)) in radeon_pm_init()
1529 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_pm_init()
1531 rdev->pm.pm_method = PM_METHOD_DPM; in radeon_pm_init()
1533 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_pm_init()
1562 if (!rdev->rlc_fw) in radeon_pm_init()
1563 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_pm_init()
1564 else if ((rdev->family >= CHIP_RV770) && in radeon_pm_init()
1565 (!(rdev->flags & RADEON_IS_IGP)) && in radeon_pm_init()
1566 (!rdev->smc_fw)) in radeon_pm_init()
1567 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_pm_init()
1569 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_pm_init()
1571 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_pm_init()
1573 rdev->pm.pm_method = PM_METHOD_DPM; in radeon_pm_init()
1577 rdev->pm.pm_method = PM_METHOD_PROFILE; in radeon_pm_init()
1581 if (rdev->pm.pm_method == PM_METHOD_DPM) in radeon_pm_init()
1582 return radeon_pm_init_dpm(rdev); in radeon_pm_init()
1584 return radeon_pm_init_old(rdev); in radeon_pm_init()
1587 int radeon_pm_late_init(struct radeon_device *rdev) in radeon_pm_late_init() argument
1591 if (rdev->pm.pm_method == PM_METHOD_DPM) { in radeon_pm_late_init()
1592 if (rdev->pm.dpm_enabled) { in radeon_pm_late_init()
1593 if (!rdev->pm.sysfs_initialized) { in radeon_pm_late_init()
1594 ret = device_create_file(rdev->dev, &dev_attr_power_dpm_state); in radeon_pm_late_init()
1597 ret = device_create_file(rdev->dev, &dev_attr_power_dpm_force_performance_level); in radeon_pm_late_init()
1601 ret = device_create_file(rdev->dev, &dev_attr_power_profile); in radeon_pm_late_init()
1604 ret = device_create_file(rdev->dev, &dev_attr_power_method); in radeon_pm_late_init()
1607 rdev->pm.sysfs_initialized = true; in radeon_pm_late_init()
1610 mutex_lock(&rdev->pm.mutex); in radeon_pm_late_init()
1611 ret = radeon_dpm_late_enable(rdev); in radeon_pm_late_init()
1612 mutex_unlock(&rdev->pm.mutex); in radeon_pm_late_init()
1614 rdev->pm.dpm_enabled = false; in radeon_pm_late_init()
1620 radeon_pm_compute_clocks(rdev); in radeon_pm_late_init()
1624 if ((rdev->pm.num_power_states > 1) && in radeon_pm_late_init()
1625 (!rdev->pm.sysfs_initialized)) { in radeon_pm_late_init()
1627 ret = device_create_file(rdev->dev, &dev_attr_power_profile); in radeon_pm_late_init()
1630 ret = device_create_file(rdev->dev, &dev_attr_power_method); in radeon_pm_late_init()
1634 rdev->pm.sysfs_initialized = true; in radeon_pm_late_init()
1640 static void radeon_pm_fini_old(struct radeon_device *rdev) in radeon_pm_fini_old() argument
1642 if (rdev->pm.num_power_states > 1) { in radeon_pm_fini_old()
1643 mutex_lock(&rdev->pm.mutex); in radeon_pm_fini_old()
1644 if (rdev->pm.pm_method == PM_METHOD_PROFILE) { in radeon_pm_fini_old()
1645 rdev->pm.profile = PM_PROFILE_DEFAULT; in radeon_pm_fini_old()
1646 radeon_pm_update_profile(rdev); in radeon_pm_fini_old()
1647 radeon_pm_set_clocks(rdev); in radeon_pm_fini_old()
1648 } else if (rdev->pm.pm_method == PM_METHOD_DYNPM) { in radeon_pm_fini_old()
1650 rdev->pm.dynpm_state = DYNPM_STATE_DISABLED; in radeon_pm_fini_old()
1651 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT; in radeon_pm_fini_old()
1652 radeon_pm_set_clocks(rdev); in radeon_pm_fini_old()
1654 mutex_unlock(&rdev->pm.mutex); in radeon_pm_fini_old()
1656 cancel_delayed_work_sync(&rdev->pm.dynpm_idle_work); in radeon_pm_fini_old()
1658 device_remove_file(rdev->dev, &dev_attr_power_profile); in radeon_pm_fini_old()
1659 device_remove_file(rdev->dev, &dev_attr_power_method); in radeon_pm_fini_old()
1662 radeon_hwmon_fini(rdev); in radeon_pm_fini_old()
1663 kfree(rdev->pm.power_state); in radeon_pm_fini_old()
1666 static void radeon_pm_fini_dpm(struct radeon_device *rdev) in radeon_pm_fini_dpm() argument
1668 if (rdev->pm.num_power_states > 1) { in radeon_pm_fini_dpm()
1669 mutex_lock(&rdev->pm.mutex); in radeon_pm_fini_dpm()
1670 radeon_dpm_disable(rdev); in radeon_pm_fini_dpm()
1671 mutex_unlock(&rdev->pm.mutex); in radeon_pm_fini_dpm()
1673 device_remove_file(rdev->dev, &dev_attr_power_dpm_state); in radeon_pm_fini_dpm()
1674 device_remove_file(rdev->dev, &dev_attr_power_dpm_force_performance_level); in radeon_pm_fini_dpm()
1676 device_remove_file(rdev->dev, &dev_attr_power_profile); in radeon_pm_fini_dpm()
1677 device_remove_file(rdev->dev, &dev_attr_power_method); in radeon_pm_fini_dpm()
1679 radeon_dpm_fini(rdev); in radeon_pm_fini_dpm()
1681 radeon_hwmon_fini(rdev); in radeon_pm_fini_dpm()
1682 kfree(rdev->pm.power_state); in radeon_pm_fini_dpm()
1685 void radeon_pm_fini(struct radeon_device *rdev) in radeon_pm_fini() argument
1687 if (rdev->pm.pm_method == PM_METHOD_DPM) in radeon_pm_fini()
1688 radeon_pm_fini_dpm(rdev); in radeon_pm_fini()
1690 radeon_pm_fini_old(rdev); in radeon_pm_fini()
1693 static void radeon_pm_compute_clocks_old(struct radeon_device *rdev) in radeon_pm_compute_clocks_old() argument
1695 struct drm_device *ddev = rdev_to_drm(rdev); in radeon_pm_compute_clocks_old()
1699 if (rdev->pm.num_power_states < 2) in radeon_pm_compute_clocks_old()
1702 mutex_lock(&rdev->pm.mutex); in radeon_pm_compute_clocks_old()
1704 rdev->pm.active_crtcs = 0; in radeon_pm_compute_clocks_old()
1705 rdev->pm.active_crtc_count = 0; in radeon_pm_compute_clocks_old()
1706 if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { in radeon_pm_compute_clocks_old()
1711 rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id); in radeon_pm_compute_clocks_old()
1712 rdev->pm.active_crtc_count++; in radeon_pm_compute_clocks_old()
1717 if (rdev->pm.pm_method == PM_METHOD_PROFILE) { in radeon_pm_compute_clocks_old()
1718 radeon_pm_update_profile(rdev); in radeon_pm_compute_clocks_old()
1719 radeon_pm_set_clocks(rdev); in radeon_pm_compute_clocks_old()
1720 } else if (rdev->pm.pm_method == PM_METHOD_DYNPM) { in radeon_pm_compute_clocks_old()
1721 if (rdev->pm.dynpm_state != DYNPM_STATE_DISABLED) { in radeon_pm_compute_clocks_old()
1722 if (rdev->pm.active_crtc_count > 1) { in radeon_pm_compute_clocks_old()
1723 if (rdev->pm.dynpm_state == DYNPM_STATE_ACTIVE) { in radeon_pm_compute_clocks_old()
1724 cancel_delayed_work(&rdev->pm.dynpm_idle_work); in radeon_pm_compute_clocks_old()
1726 rdev->pm.dynpm_state = DYNPM_STATE_PAUSED; in radeon_pm_compute_clocks_old()
1727 rdev->pm.dynpm_planned_action = DYNPM_ACTION_DEFAULT; in radeon_pm_compute_clocks_old()
1728 radeon_pm_get_dynpm_state(rdev); in radeon_pm_compute_clocks_old()
1729 radeon_pm_set_clocks(rdev); in radeon_pm_compute_clocks_old()
1733 } else if (rdev->pm.active_crtc_count == 1) { in radeon_pm_compute_clocks_old()
1736 if (rdev->pm.dynpm_state == DYNPM_STATE_MINIMUM) { in radeon_pm_compute_clocks_old()
1737 rdev->pm.dynpm_state = DYNPM_STATE_ACTIVE; in radeon_pm_compute_clocks_old()
1738 rdev->pm.dynpm_planned_action = DYNPM_ACTION_UPCLOCK; in radeon_pm_compute_clocks_old()
1739 radeon_pm_get_dynpm_state(rdev); in radeon_pm_compute_clocks_old()
1740 radeon_pm_set_clocks(rdev); in radeon_pm_compute_clocks_old()
1742 schedule_delayed_work(&rdev->pm.dynpm_idle_work, in radeon_pm_compute_clocks_old()
1744 } else if (rdev->pm.dynpm_state == DYNPM_STATE_PAUSED) { in radeon_pm_compute_clocks_old()
1745 rdev->pm.dynpm_state = DYNPM_STATE_ACTIVE; in radeon_pm_compute_clocks_old()
1746 schedule_delayed_work(&rdev->pm.dynpm_idle_work, in radeon_pm_compute_clocks_old()
1751 if (rdev->pm.dynpm_state != DYNPM_STATE_MINIMUM) { in radeon_pm_compute_clocks_old()
1752 cancel_delayed_work(&rdev->pm.dynpm_idle_work); in radeon_pm_compute_clocks_old()
1754 rdev->pm.dynpm_state = DYNPM_STATE_MINIMUM; in radeon_pm_compute_clocks_old()
1755 rdev->pm.dynpm_planned_action = DYNPM_ACTION_MINIMUM; in radeon_pm_compute_clocks_old()
1756 radeon_pm_get_dynpm_state(rdev); in radeon_pm_compute_clocks_old()
1757 radeon_pm_set_clocks(rdev); in radeon_pm_compute_clocks_old()
1763 mutex_unlock(&rdev->pm.mutex); in radeon_pm_compute_clocks_old()
1766 static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev) in radeon_pm_compute_clocks_dpm() argument
1768 struct drm_device *ddev = rdev_to_drm(rdev); in radeon_pm_compute_clocks_dpm()
1773 if (!rdev->pm.dpm_enabled) in radeon_pm_compute_clocks_dpm()
1776 mutex_lock(&rdev->pm.mutex); in radeon_pm_compute_clocks_dpm()
1779 rdev->pm.dpm.new_active_crtcs = 0; in radeon_pm_compute_clocks_dpm()
1780 rdev->pm.dpm.new_active_crtc_count = 0; in radeon_pm_compute_clocks_dpm()
1781 rdev->pm.dpm.high_pixelclock_count = 0; in radeon_pm_compute_clocks_dpm()
1782 if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { in radeon_pm_compute_clocks_dpm()
1787 rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id); in radeon_pm_compute_clocks_dpm()
1788 rdev->pm.dpm.new_active_crtc_count++; in radeon_pm_compute_clocks_dpm()
1794 rdev->pm.dpm.high_pixelclock_count++; in radeon_pm_compute_clocks_dpm()
1801 rdev->pm.dpm.ac_power = true; in radeon_pm_compute_clocks_dpm()
1803 rdev->pm.dpm.ac_power = false; in radeon_pm_compute_clocks_dpm()
1805 radeon_dpm_change_power_state_locked(rdev); in radeon_pm_compute_clocks_dpm()
1807 mutex_unlock(&rdev->pm.mutex); in radeon_pm_compute_clocks_dpm()
1811 void radeon_pm_compute_clocks(struct radeon_device *rdev) in radeon_pm_compute_clocks() argument
1813 if (rdev->pm.pm_method == PM_METHOD_DPM) in radeon_pm_compute_clocks()
1814 radeon_pm_compute_clocks_dpm(rdev); in radeon_pm_compute_clocks()
1816 radeon_pm_compute_clocks_old(rdev); in radeon_pm_compute_clocks()
1819 static bool radeon_pm_in_vbl(struct radeon_device *rdev) in radeon_pm_in_vbl() argument
1827 for (crtc = 0; (crtc < rdev->num_crtc) && in_vbl; crtc++) { in radeon_pm_in_vbl()
1828 if (rdev->pm.active_crtcs & (1 << crtc)) { in radeon_pm_in_vbl()
1829 vbl_status = radeon_get_crtc_scanoutpos(rdev_to_drm(rdev), in radeon_pm_in_vbl()
1833 &rdev->mode_info.crtcs[crtc]->base.hwmode); in radeon_pm_in_vbl()
1843 static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish) in radeon_pm_debug_check_in_vbl() argument
1846 bool in_vbl = radeon_pm_in_vbl(rdev); in radeon_pm_debug_check_in_vbl()
1856 struct radeon_device *rdev; in radeon_dynpm_idle_work_handler() local
1858 rdev = container_of(work, struct radeon_device, in radeon_dynpm_idle_work_handler()
1861 mutex_lock(&rdev->pm.mutex); in radeon_dynpm_idle_work_handler()
1862 if (rdev->pm.dynpm_state == DYNPM_STATE_ACTIVE) { in radeon_dynpm_idle_work_handler()
1867 struct radeon_ring *ring = &rdev->ring[i]; in radeon_dynpm_idle_work_handler()
1870 not_processed += radeon_fence_count_emitted(rdev, i); in radeon_dynpm_idle_work_handler()
1877 if (rdev->pm.dynpm_planned_action == DYNPM_ACTION_DOWNCLOCK) { in radeon_dynpm_idle_work_handler()
1878 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE; in radeon_dynpm_idle_work_handler()
1879 } else if (rdev->pm.dynpm_planned_action == DYNPM_ACTION_NONE && in radeon_dynpm_idle_work_handler()
1880 rdev->pm.dynpm_can_upclock) { in radeon_dynpm_idle_work_handler()
1881 rdev->pm.dynpm_planned_action = in radeon_dynpm_idle_work_handler()
1883 rdev->pm.dynpm_action_timeout = jiffies + in radeon_dynpm_idle_work_handler()
1887 if (rdev->pm.dynpm_planned_action == DYNPM_ACTION_UPCLOCK) { in radeon_dynpm_idle_work_handler()
1888 rdev->pm.dynpm_planned_action = DYNPM_ACTION_NONE; in radeon_dynpm_idle_work_handler()
1889 } else if (rdev->pm.dynpm_planned_action == DYNPM_ACTION_NONE && in radeon_dynpm_idle_work_handler()
1890 rdev->pm.dynpm_can_downclock) { in radeon_dynpm_idle_work_handler()
1891 rdev->pm.dynpm_planned_action = in radeon_dynpm_idle_work_handler()
1893 rdev->pm.dynpm_action_timeout = jiffies + in radeon_dynpm_idle_work_handler()
1901 if (rdev->pm.dynpm_planned_action != DYNPM_ACTION_NONE && in radeon_dynpm_idle_work_handler()
1902 time_after(jiffies, rdev->pm.dynpm_action_timeout)) { in radeon_dynpm_idle_work_handler()
1903 radeon_pm_get_dynpm_state(rdev); in radeon_dynpm_idle_work_handler()
1904 radeon_pm_set_clocks(rdev); in radeon_dynpm_idle_work_handler()
1907 schedule_delayed_work(&rdev->pm.dynpm_idle_work, in radeon_dynpm_idle_work_handler()
1910 mutex_unlock(&rdev->pm.mutex); in radeon_dynpm_idle_work_handler()
1920 struct radeon_device *rdev = m->private; in radeon_debugfs_pm_info_show() local
1921 struct drm_device *ddev = rdev_to_drm(rdev); in radeon_debugfs_pm_info_show()
1923 if ((rdev->flags & RADEON_IS_PX) && in radeon_debugfs_pm_info_show()
1926 } else if (rdev->pm.dpm_enabled) { in radeon_debugfs_pm_info_show()
1927 mutex_lock(&rdev->pm.mutex); in radeon_debugfs_pm_info_show()
1928 if (rdev->asic->dpm.debugfs_print_current_performance_level) in radeon_debugfs_pm_info_show()
1929 radeon_dpm_debugfs_print_current_performance_level(rdev, m); in radeon_debugfs_pm_info_show()
1932 mutex_unlock(&rdev->pm.mutex); in radeon_debugfs_pm_info_show()
1934 seq_printf(m, "default engine clock: %u0 kHz\n", rdev->pm.default_sclk); in radeon_debugfs_pm_info_show()
1936 if ((rdev->family >= CHIP_PALM) && (rdev->flags & RADEON_IS_IGP)) in radeon_debugfs_pm_info_show()
1937 seq_printf(m, "current engine clock: %u0 kHz\n", rdev->pm.current_sclk); in radeon_debugfs_pm_info_show()
1939 seq_printf(m, "current engine clock: %u0 kHz\n", radeon_get_engine_clock(rdev)); in radeon_debugfs_pm_info_show()
1940 seq_printf(m, "default memory clock: %u0 kHz\n", rdev->pm.default_mclk); in radeon_debugfs_pm_info_show()
1941 if (rdev->asic->pm.get_memory_clock) in radeon_debugfs_pm_info_show()
1942 seq_printf(m, "current memory clock: %u0 kHz\n", radeon_get_memory_clock(rdev)); in radeon_debugfs_pm_info_show()
1943 if (rdev->pm.current_vddc) in radeon_debugfs_pm_info_show()
1944 seq_printf(m, "voltage: %u mV\n", rdev->pm.current_vddc); in radeon_debugfs_pm_info_show()
1945 if (rdev->asic->pm.get_pcie_lanes) in radeon_debugfs_pm_info_show()
1946 seq_printf(m, "PCIE lanes: %d\n", radeon_get_pcie_lanes(rdev)); in radeon_debugfs_pm_info_show()
1955 static void radeon_debugfs_pm_init(struct radeon_device *rdev) in radeon_debugfs_pm_init() argument
1958 struct dentry *root = rdev_to_drm(rdev)->primary->debugfs_root; in radeon_debugfs_pm_init()
1960 debugfs_create_file("radeon_pm_info", 0444, root, rdev, in radeon_debugfs_pm_init()