]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/radeon/dpm: add pre/post_set_power_state callback (sumo)
authorAlex Deucher <alexander.deucher@amd.com>
Tue, 25 Jun 2013 19:40:21 +0000 (15:40 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Jun 2013 23:16:18 +0000 (19:16 -0400)
This properly implemented dynamic state adjustment by
using a working copy of the requested and current
power states.

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
drivers/gpu/drm/radeon/sumo_dpm.h

index 3b8b4954af875c0c9fe5004f4e93dcf2a3a9f824..b0d055a20d5d5440995537599886ea30f6939572 100644 (file)
@@ -1627,7 +1627,9 @@ static struct radeon_asic sumo_asic = {
                .setup_asic = &sumo_dpm_setup_asic,
                .enable = &sumo_dpm_enable,
                .disable = &sumo_dpm_disable,
+               .pre_set_power_state = &sumo_dpm_pre_set_power_state,
                .set_power_state = &sumo_dpm_set_power_state,
+               .post_set_power_state = &sumo_dpm_post_set_power_state,
                .display_configuration_changed = &sumo_dpm_display_configuration_changed,
                .fini = &sumo_dpm_fini,
                .get_sclk = &sumo_dpm_get_sclk,
index 8b059fedfe4f77930565d075d2932d68a040be79..57fd4c021727be1bd3e3cb8ee5ba898dba8ed7f8 100644 (file)
@@ -547,7 +547,9 @@ void btc_dpm_fini(struct radeon_device *rdev);
 int sumo_dpm_init(struct radeon_device *rdev);
 int sumo_dpm_enable(struct radeon_device *rdev);
 void sumo_dpm_disable(struct radeon_device *rdev);
+int sumo_dpm_pre_set_power_state(struct radeon_device *rdev);
 int sumo_dpm_set_power_state(struct radeon_device *rdev);
+void sumo_dpm_post_set_power_state(struct radeon_device *rdev);
 void sumo_dpm_setup_asic(struct radeon_device *rdev);
 void sumo_dpm_display_configuration_changed(struct radeon_device *rdev);
 void sumo_dpm_fini(struct radeon_device *rdev);
index 81713429db1f90bf7bccf51af0b481cd476ee830..6074aafb58a7ef09e3d5dca22e78c27363e09eb4 100644 (file)
@@ -727,15 +727,6 @@ static void sumo_enable_boost(struct radeon_device *rdev,
                sumo_boost_state_enable(rdev, false);
 }
 
-static void sumo_update_current_power_levels(struct radeon_device *rdev,
-                                            struct radeon_ps *rps)
-{
-       struct sumo_ps *new_ps = sumo_get_ps(rps);
-       struct sumo_power_info *pi = sumo_get_pi(rdev);
-
-       pi->current_ps = *new_ps;
-}
-
 static void sumo_set_forced_level(struct radeon_device *rdev, u32 index)
 {
        WREG32_P(CG_SCLK_DPM_CTRL_3, FORCE_SCLK_STATE(index), ~FORCE_SCLK_STATE_MASK);
@@ -1089,11 +1080,6 @@ static void sumo_apply_state_adjust_rules(struct radeon_device *rdev,
        u32 sclk_in_sr = pi->sys_info.min_sclk; /* ??? */
        u32 i;
 
-       /* point to the hw copy since this function will modify the ps */
-       pi->hw_ps = *ps;
-       rdev->pm.dpm.hw_ps.ps_priv = &pi->hw_ps;
-       ps = &pi->hw_ps;
-
        if (new_rps->class & ATOM_PPLIB_CLASSIFICATION_THERMAL)
                return sumo_patch_thermal_state(rdev, ps, current_ps);
 
@@ -1192,6 +1178,28 @@ static int sumo_set_thermal_temperature_range(struct radeon_device *rdev,
        return 0;
 }
 
+static void sumo_update_current_ps(struct radeon_device *rdev,
+                                  struct radeon_ps *rps)
+{
+       struct sumo_ps *new_ps = sumo_get_ps(rps);
+       struct sumo_power_info *pi = sumo_get_pi(rdev);
+
+       pi->current_rps = *rps;
+       pi->current_ps = *new_ps;
+       pi->current_rps.ps_priv = &pi->current_ps;
+}
+
+static void sumo_update_requested_ps(struct radeon_device *rdev,
+                                    struct radeon_ps *rps)
+{
+       struct sumo_ps *new_ps = sumo_get_ps(rps);
+       struct sumo_power_info *pi = sumo_get_pi(rdev);
+
+       pi->requested_rps = *rps;
+       pi->requested_ps = *new_ps;
+       pi->requested_rps.ps_priv = &pi->requested_ps;
+}
+
 int sumo_dpm_enable(struct radeon_device *rdev)
 {
        struct sumo_power_info *pi = sumo_get_pi(rdev);
@@ -1230,6 +1238,8 @@ int sumo_dpm_enable(struct radeon_device *rdev)
                radeon_irq_set(rdev);
        }
 
+       sumo_update_current_ps(rdev, rdev->pm.dpm.boot_ps);
+
        return 0;
 }
 
@@ -1252,19 +1262,34 @@ void sumo_dpm_disable(struct radeon_device *rdev)
                rdev->irq.dpm_thermal = false;
                radeon_irq_set(rdev);
        }
+
+       sumo_update_current_ps(rdev, rdev->pm.dpm.boot_ps);
 }
 
-int sumo_dpm_set_power_state(struct radeon_device *rdev)
+int sumo_dpm_pre_set_power_state(struct radeon_device *rdev)
 {
        struct sumo_power_info *pi = sumo_get_pi(rdev);
-       struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps;
-       struct radeon_ps *old_ps = rdev->pm.dpm.current_ps;
+       struct radeon_ps requested_ps = *rdev->pm.dpm.requested_ps;
+       struct radeon_ps *new_ps = &requested_ps;
+
+       sumo_update_requested_ps(rdev, new_ps);
 
        if (pi->enable_dynamic_patch_ps)
-               sumo_apply_state_adjust_rules(rdev, new_ps, old_ps);
+               sumo_apply_state_adjust_rules(rdev,
+                                             &pi->requested_rps,
+                                             &pi->current_rps);
+
+       return 0;
+}
+
+int sumo_dpm_set_power_state(struct radeon_device *rdev)
+{
+       struct sumo_power_info *pi = sumo_get_pi(rdev);
+       struct radeon_ps *new_ps = &pi->requested_rps;
+       struct radeon_ps *old_ps = &pi->current_rps;
+
        if (pi->enable_dpm)
                sumo_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
-       sumo_update_current_power_levels(rdev, new_ps);
        if (pi->enable_boost) {
                sumo_enable_boost(rdev, new_ps, false);
                sumo_patch_boost_state(rdev, new_ps);
@@ -1293,6 +1318,14 @@ int sumo_dpm_set_power_state(struct radeon_device *rdev)
        return 0;
 }
 
+void sumo_dpm_post_set_power_state(struct radeon_device *rdev)
+{
+       struct sumo_power_info *pi = sumo_get_pi(rdev);
+       struct radeon_ps *new_ps = &pi->requested_rps;
+
+       sumo_update_current_ps(rdev, new_ps);
+}
+
 void sumo_dpm_reset_asic(struct radeon_device *rdev)
 {
        sumo_program_bootup_state(rdev);
@@ -1751,7 +1784,8 @@ void sumo_dpm_fini(struct radeon_device *rdev)
 
 u32 sumo_dpm_get_sclk(struct radeon_device *rdev, bool low)
 {
-       struct sumo_ps *requested_state = sumo_get_ps(rdev->pm.dpm.requested_ps);
+       struct sumo_power_info *pi = sumo_get_pi(rdev);
+       struct sumo_ps *requested_state = sumo_get_ps(&pi->requested_rps);
 
        if (low)
                return requested_state->levels[0].sclk;
index a40b62ae095755ab7c9c7c2bf5ce8fa0b8e97b0d..a3a7a61907136d7333fa813b271550565e474058 100644 (file)
@@ -116,7 +116,6 @@ struct sumo_power_info {
        struct sumo_pl acpi_pl;
        struct sumo_pl boot_pl;
        struct sumo_pl boost_pl;
-       struct sumo_ps current_ps;
        bool disable_gfx_power_gating_in_uvd;
        bool driver_nbps_policy_disable;
        bool enable_alt_vddnb;
@@ -129,7 +128,10 @@ struct sumo_power_info {
        bool enable_dynamic_patch_ps;
        bool enable_dpm;
        bool enable_boost;
-       struct sumo_ps hw_ps;
+       struct radeon_ps current_rps;
+       struct sumo_ps current_ps;
+       struct radeon_ps requested_rps;
+       struct sumo_ps requested_ps;
 };
 
 #define SUMO_UTC_DFLT_00                     0x48