drm/radeon/dpm: implement force performance level for ON/LN
authorAlex Deucher <alexander.deucher@amd.com>
Tue, 2 Jul 2013 22:50:09 +0000 (18:50 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 5 Jul 2013 22:09:56 +0000 (18:09 -0400)
Allows you to force the selected performance level via sysfs.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_asic.c
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/sumo_dpm.c

index 6ec4831fdb588526bde692cd03893ff355095dd7..5d592aed1ee94306ff8772971ce89b87989af514 100644 (file)
@@ -1641,6 +1641,7 @@ static struct radeon_asic sumo_asic = {
                .get_mclk = &sumo_dpm_get_mclk,
                .print_power_state = &sumo_dpm_print_power_state,
                .debugfs_print_current_performance_level = &sumo_dpm_debugfs_print_current_performance_level,
+               .force_performance_level = &sumo_dpm_force_performance_level,
        },
        .pflip = {
                .pre_page_flip = &evergreen_pre_page_flip,
index 7efa51a13b3c2aa5bba3753f9a7aa45a9a06d3a7..1a89b3af04f33c06b6d31159192e1fd761fdbf24 100644 (file)
@@ -569,6 +569,8 @@ void sumo_dpm_print_power_state(struct radeon_device *rdev,
                                struct radeon_ps *ps);
 void sumo_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
                                                      struct seq_file *m);
+int sumo_dpm_force_performance_level(struct radeon_device *rdev,
+                                    enum radeon_dpm_forced_level level);
 
 /*
  * cayman
index dc599060a9a49033be448a2f7e7f9be12e5f71ec..11b6b9924f1bc54656ec0d4f85307d658c2d0ffc 100644 (file)
@@ -1319,6 +1319,8 @@ int sumo_dpm_set_power_state(struct radeon_device *rdev)
        if (pi->enable_dpm)
                sumo_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
 
+       rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
+
        return 0;
 }
 
@@ -1830,3 +1832,45 @@ u32 sumo_dpm_get_mclk(struct radeon_device *rdev, bool low)
 
        return pi->sys_info.bootup_uma_clk;
 }
+
+int sumo_dpm_force_performance_level(struct radeon_device *rdev,
+                                    enum radeon_dpm_forced_level level)
+{
+       struct sumo_power_info *pi = sumo_get_pi(rdev);
+       struct radeon_ps *rps = &pi->current_rps;
+       struct sumo_ps *ps = sumo_get_ps(rps);
+       int i;
+
+       if (ps->num_levels <= 1)
+               return 0;
+
+       if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
+               sumo_power_level_enable(rdev, ps->num_levels - 1, true);
+               sumo_set_forced_level(rdev, ps->num_levels - 1);
+               sumo_set_forced_mode_enabled(rdev);
+               for (i = 0; i < ps->num_levels - 1; i++) {
+                       sumo_power_level_enable(rdev, i, false);
+               }
+               sumo_set_forced_mode(rdev, false);
+               sumo_set_forced_mode_enabled(rdev);
+               sumo_set_forced_mode(rdev, false);
+       } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) {
+               sumo_power_level_enable(rdev, 0, true);
+               sumo_set_forced_level(rdev, 0);
+               sumo_set_forced_mode_enabled(rdev);
+               for (i = 1; i < ps->num_levels; i++) {
+                       sumo_power_level_enable(rdev, i, false);
+               }
+               sumo_set_forced_mode(rdev, false);
+               sumo_set_forced_mode_enabled(rdev);
+               sumo_set_forced_mode(rdev, false);
+       } else {
+               for (i = 0; i < ps->num_levels; i++) {
+                       sumo_power_level_enable(rdev, i, true);
+               }
+       }
+
+       rdev->pm.dpm.forced_level = level;
+
+       return 0;
+}