drm/radeon/kms/pm: track current voltage (v2)
authorAlex Deucher <alexdeucher@gmail.com>
Mon, 7 Jun 2010 22:15:18 +0000 (18:15 -0400)
committerDave Airlie <airlied@redhat.com>
Mon, 7 Jun 2010 23:35:53 +0000 (09:35 +1000)
track the current voltage level and avoid setting it
if the requested voltage is already set.

v2: check voltage type before checking current voltage

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/evergreen.c
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_atombios.c
drivers/gpu/drm/radeon/radeon_pm.c
drivers/gpu/drm/radeon/rv770.c

index 49c94aef0dda9b2459d845ad24da6e091365fa11..b86d6ac9c5bafa1b796f2dd7a9152a1d44134aeb 100644 (file)
@@ -45,8 +45,12 @@ void evergreen_pm_misc(struct radeon_device *rdev)
        struct radeon_power_state *ps = &rdev->pm.power_state[requested_index];
        struct radeon_voltage *voltage = &ps->clock_info[0].voltage;
 
-       if ((voltage->type == VOLTAGE_SW) && voltage->voltage)
-               radeon_atom_set_voltage(rdev, voltage->voltage);
+       if ((voltage->type == VOLTAGE_SW) && voltage->voltage) {
+               if (voltage->voltage != rdev->pm.current_vddc) {
+                       radeon_atom_set_voltage(rdev, voltage->voltage);
+                       rdev->pm.current_vddc = voltage->voltage;
+               }
+       }
 }
 
 void evergreen_pm_prepare(struct radeon_device *rdev)
index d152ceca5d37709263c655e9f524ae679744b1db..acec26b70d0de17e0dbec645170b3ba6d34432c9 100644 (file)
@@ -561,9 +561,12 @@ void r600_pm_misc(struct radeon_device *rdev)
        struct radeon_power_state *ps = &rdev->pm.power_state[requested_index];
        struct radeon_voltage *voltage = &ps->clock_info[0].voltage;
 
-       if ((voltage->type == VOLTAGE_SW) && voltage->voltage)
-               radeon_atom_set_voltage(rdev, voltage->voltage);
-
+       if ((voltage->type == VOLTAGE_SW) && voltage->voltage) {
+               if (voltage->voltage != rdev->pm.current_vddc) {
+                       radeon_atom_set_voltage(rdev, voltage->voltage);
+                       rdev->pm.current_vddc = voltage->voltage;
+               }
+       }
 }
 
 bool r600_gui_idle(struct radeon_device *rdev)
index 2ad0e0304294cbfe2f52583468a78aca6b8fecf9..8e1d44ca26ec420eb062c8f21b836cab73aaf845 100644 (file)
@@ -748,6 +748,7 @@ struct radeon_pm {
        int                     default_power_state_index;
        u32                     current_sclk;
        u32                     current_mclk;
+       u32                     current_vddc;
        struct radeon_i2c_chan *i2c_bus;
        /* selected pm method */
        enum radeon_pm_method     pm_method;
index f0fcd6c3d38c5989d5059522273a0565c2ece9bb..99bd8a9c56b38f8431510bf3cde781345510feb1 100644 (file)
@@ -1966,6 +1966,7 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
 
        rdev->pm.current_power_state_index = rdev->pm.default_power_state_index;
        rdev->pm.current_clock_mode_index = 0;
+       rdev->pm.current_vddc = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].voltage.voltage;
 }
 
 void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable)
index fcdf1db1e3ce692b619667823f6a70e4057d7069..f2e1c60afda5cbdf9683a6aa8b5a5d23449850e5 100644 (file)
@@ -387,6 +387,7 @@ void radeon_pm_resume(struct radeon_device *rdev)
        rdev->pm.current_clock_mode_index = 0;
        rdev->pm.current_sclk = rdev->clock.default_sclk;
        rdev->pm.current_mclk = rdev->clock.default_mclk;
+       rdev->pm.current_vddc = rdev->pm.power_state[rdev->pm.default_power_state_index].clock_info[0].voltage.voltage;
        mutex_unlock(&rdev->pm.mutex);
        radeon_pm_compute_clocks(rdev);
 }
index 33952da65340503ad3e07bbb428bf4487b027737..7bde6eecf8c2344413ebcfbecb43d8ea0fc2b4cd 100644 (file)
@@ -48,8 +48,13 @@ void rv770_pm_misc(struct radeon_device *rdev)
        struct radeon_power_state *ps = &rdev->pm.power_state[requested_index];
        struct radeon_voltage *voltage = &ps->clock_info[0].voltage;
 
-       if ((voltage->type == VOLTAGE_SW) && voltage->voltage)
-               radeon_atom_set_voltage(rdev, voltage->voltage);
+
+       if ((voltage->type == VOLTAGE_SW) && voltage->voltage) {
+               if (voltage->voltage != rdev->pm.current_vddc) {
+                       radeon_atom_set_voltage(rdev, voltage->voltage);
+                       rdev->pm.current_vddc = voltage->voltage;
+               }
+       }
 }
 
 /*