]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/radeon/dpm/rv7xx: restructure code
authorAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Jun 2013 22:54:46 +0000 (18:54 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Jun 2013 23:16:12 +0000 (19:16 -0400)
Needed to properly handle dynamic state adjustment.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/btc_dpm.c
drivers/gpu/drm/radeon/cypress_dpm.c
drivers/gpu/drm/radeon/rv740_dpm.c
drivers/gpu/drm/radeon/rv770_dpm.c
drivers/gpu/drm/radeon/rv770_dpm.h

index 3c9a9b55fc62de83f53d3ea8e41f2b8136b3d044..e4609fe2228ee7cfc0906781a7f33088f7f396bb 100644 (file)
@@ -2233,6 +2233,8 @@ void btc_dpm_reset_asic(struct radeon_device *rdev)
 int btc_dpm_set_power_state(struct radeon_device *rdev)
 {
        struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
+       struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps;
+       struct radeon_ps *old_ps = rdev->pm.dpm.current_ps;
 
        btc_apply_state_adjust_rules(rdev);
 
@@ -2243,7 +2245,7 @@ int btc_dpm_set_power_state(struct radeon_device *rdev)
        if (eg_pi->pcie_performance_request)
                cypress_notify_link_speed_change_before_state_change(rdev);
 
-       rv770_set_uvd_clock_before_set_eng_clock(rdev);
+       rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
        rv770_halt_smc(rdev);
        btc_set_at_for_uvd(rdev);
        if (eg_pi->smu_uvd_hs)
@@ -2257,7 +2259,7 @@ int btc_dpm_set_power_state(struct radeon_device *rdev)
 
        rv770_resume_smc(rdev);
        rv770_set_sw_state(rdev);
-       rv770_set_uvd_clock_after_set_eng_clock(rdev);
+       rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
 
        if (eg_pi->pcie_performance_request)
                cypress_notify_link_speed_change_after_state_change(rdev);
index afdb7c7d4e867c3c3d6b9ae08a123081b24f7737..2191501ab5fc80f741834e81830bee8a48163756 100644 (file)
@@ -1930,13 +1930,15 @@ void cypress_dpm_disable(struct radeon_device *rdev)
 int cypress_dpm_set_power_state(struct radeon_device *rdev)
 {
        struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
+       struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps;
+       struct radeon_ps *old_ps = rdev->pm.dpm.current_ps;
 
        rv770_restrict_performance_levels_before_switch(rdev);
 
        if (eg_pi->pcie_performance_request)
                cypress_notify_link_speed_change_before_state_change(rdev);
 
-       rv770_set_uvd_clock_before_set_eng_clock(rdev);
+       rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
        rv770_halt_smc(rdev);
        cypress_upload_sw_state(rdev);
 
@@ -1947,7 +1949,7 @@ int cypress_dpm_set_power_state(struct radeon_device *rdev)
 
        rv770_resume_smc(rdev);
        rv770_set_sw_state(rdev);
-       rv770_set_uvd_clock_after_set_eng_clock(rdev);
+       rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
 
        if (eg_pi->pcie_performance_request)
                cypress_notify_link_speed_change_after_state_change(rdev);
index f6d79a1f62c163b1328f5643352caecfe03e137e..c4c8da501da8f86c10370c26873b66e5853372ee 100644 (file)
@@ -29,7 +29,6 @@
 #include "rv770_dpm.h"
 #include "atom.h"
 
-struct rv7xx_ps *rv770_get_ps(struct radeon_ps *rps);
 struct rv7xx_power_info *rv770_get_pi(struct radeon_device *rdev);
 
 u32 rv740_get_decoded_reference_divider(u32 encoded_ref)
index d3a55b792bd66006dfe64667f83bf5c2e3fb66e6..3c2866e7ca5b4b2d624bb62efd55bf6739b0cc76 100644 (file)
@@ -1155,10 +1155,10 @@ static int rv770_populate_smc_mvdd_table(struct radeon_device *rdev,
        return 0;
 }
 
-static int rv770_init_smc_table(struct radeon_device *rdev)
+static int rv770_init_smc_table(struct radeon_device *rdev,
+                               struct radeon_ps *radeon_boot_state)
 {
        struct rv7xx_power_info *pi = rv770_get_pi(rdev);
-       struct radeon_ps *radeon_boot_state = rdev->pm.dpm.boot_ps;
        struct rv7xx_ps *boot_state = rv770_get_ps(radeon_boot_state);
        RV770_SMC_STATETABLE *table = &pi->smc_statetable;
        int ret;
@@ -1364,10 +1364,9 @@ static void rv770_enable_dynamic_pcie_gen2(struct radeon_device *rdev,
                WREG32_P(GENERAL_PWRMGT, 0, ~ENABLE_GEN2PCIE);
 }
 
-static void r7xx_program_memory_timing_parameters(struct radeon_device *rdev)
+static void r7xx_program_memory_timing_parameters(struct radeon_device *rdev,
+                                                 struct radeon_ps *radeon_new_state)
 {
-       struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps;
-
        if ((rdev->family == CHIP_RV730) ||
            (rdev->family == CHIP_RV710) ||
            (rdev->family == CHIP_RV740))
@@ -1376,10 +1375,10 @@ static void r7xx_program_memory_timing_parameters(struct radeon_device *rdev)
                rv770_program_memory_timing_parameters(rdev, radeon_new_state);
 }
 
-static int rv770_upload_sw_state(struct radeon_device *rdev)
+static int rv770_upload_sw_state(struct radeon_device *rdev,
+                                struct radeon_ps *radeon_new_state)
 {
        struct rv7xx_power_info *pi = rv770_get_pi(rdev);
-       struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps;
        u16 address = pi->state_table_start +
                offsetof(RV770_SMC_STATETABLE, driverState);
        RV770_SMC_SWSTATE state = { 0 };
@@ -1426,36 +1425,38 @@ int rv770_set_boot_state(struct radeon_device *rdev)
        return 0;
 }
 
-void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev)
+void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev,
+                                             struct radeon_ps *new_ps,
+                                             struct radeon_ps *old_ps)
 {
-       struct rv7xx_ps *new_state = rv770_get_ps(rdev->pm.dpm.requested_ps);
-       struct rv7xx_ps *current_state = rv770_get_ps(rdev->pm.dpm.current_ps);
+       struct rv7xx_ps *new_state = rv770_get_ps(new_ps);
+       struct rv7xx_ps *current_state = rv770_get_ps(old_ps);
 
-       if ((rdev->pm.dpm.requested_ps->vclk == rdev->pm.dpm.current_ps->vclk) &&
-           (rdev->pm.dpm.requested_ps->dclk == rdev->pm.dpm.current_ps->dclk))
+       if ((new_ps->vclk == old_ps->vclk) &&
+           (new_ps->dclk == old_ps->dclk))
                return;
 
        if (new_state->high.sclk >= current_state->high.sclk)
                return;
 
-       radeon_set_uvd_clocks(rdev, rdev->pm.dpm.requested_ps->vclk,
-                             rdev->pm.dpm.requested_ps->dclk);
+       radeon_set_uvd_clocks(rdev, new_ps->vclk, old_ps->dclk);
 }
 
-void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev)
+void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev,
+                                            struct radeon_ps *new_ps,
+                                            struct radeon_ps *old_ps)
 {
-       struct rv7xx_ps *new_state = rv770_get_ps(rdev->pm.dpm.requested_ps);
-       struct rv7xx_ps *current_state = rv770_get_ps(rdev->pm.dpm.current_ps);
+       struct rv7xx_ps *new_state = rv770_get_ps(new_ps);
+       struct rv7xx_ps *current_state = rv770_get_ps(old_ps);
 
-       if ((rdev->pm.dpm.requested_ps->vclk == rdev->pm.dpm.current_ps->vclk) &&
-           (rdev->pm.dpm.requested_ps->dclk == rdev->pm.dpm.current_ps->dclk))
+       if ((new_ps->vclk == old_ps->vclk) &&
+           (new_ps->dclk == old_ps->dclk))
                return;
 
        if (new_state->high.sclk < current_state->high.sclk)
                return;
 
-       radeon_set_uvd_clocks(rdev, rdev->pm.dpm.requested_ps->vclk,
-                             rdev->pm.dpm.requested_ps->dclk);
+       radeon_set_uvd_clocks(rdev, new_ps->vclk, new_ps->dclk);
 }
 
 int rv770_restrict_performance_levels_before_switch(struct radeon_device *rdev)
@@ -1720,11 +1721,11 @@ void rv770_program_response_times(struct radeon_device *rdev)
 #endif
 }
 
-static void rv770_program_dcodt_before_state_switch(struct radeon_device *rdev)
+static void rv770_program_dcodt_before_state_switch(struct radeon_device *rdev,
+                                                   struct radeon_ps *radeon_new_state,
+                                                   struct radeon_ps *radeon_current_state)
 {
        struct rv7xx_power_info *pi = rv770_get_pi(rdev);
-       struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps;
-       struct radeon_ps *radeon_current_state = rdev->pm.dpm.current_ps;
        struct rv7xx_ps *new_state = rv770_get_ps(radeon_new_state);
        struct rv7xx_ps *current_state = rv770_get_ps(radeon_current_state);
        bool current_use_dc = false;
@@ -1749,11 +1750,11 @@ static void rv770_program_dcodt_before_state_switch(struct radeon_device *rdev)
                rv730_program_dcodt(rdev, new_use_dc);
 }
 
-static void rv770_program_dcodt_after_state_switch(struct radeon_device *rdev)
+static void rv770_program_dcodt_after_state_switch(struct radeon_device *rdev,
+                                                  struct radeon_ps *radeon_new_state,
+                                                  struct radeon_ps *radeon_current_state)
 {
        struct rv7xx_power_info *pi = rv770_get_pi(rdev);
-       struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps;
-       struct radeon_ps *radeon_current_state = rdev->pm.dpm.current_ps;
        struct rv7xx_ps *new_state = rv770_get_ps(radeon_new_state);
        struct rv7xx_ps *current_state = rv770_get_ps(radeon_current_state);
        bool current_use_dc = false;
@@ -1873,6 +1874,7 @@ int rv770_set_thermal_temperature_range(struct radeon_device *rdev,
 int rv770_dpm_enable(struct radeon_device *rdev)
 {
        struct rv7xx_power_info *pi = rv770_get_pi(rdev);
+       struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
 
        if (pi->gfx_clock_gating)
                rv770_restore_cgcg(rdev);
@@ -1915,7 +1917,7 @@ int rv770_dpm_enable(struct radeon_device *rdev)
        if (rv770_upload_firmware(rdev))
                return -EINVAL;
        /* get ucode version ?  */
-       if (rv770_init_smc_table(rdev))
+       if (rv770_init_smc_table(rdev, boot_ps))
                return -EINVAL;
        rv770_program_response_times(rdev);
        r7xx_start_smc(rdev);
@@ -1990,19 +1992,21 @@ void rv770_dpm_disable(struct radeon_device *rdev)
 int rv770_dpm_set_power_state(struct radeon_device *rdev)
 {
        struct rv7xx_power_info *pi = rv770_get_pi(rdev);
+       struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps;
+       struct radeon_ps *old_ps = rdev->pm.dpm.current_ps;
 
        rv770_restrict_performance_levels_before_switch(rdev);
-       rv770_set_uvd_clock_before_set_eng_clock(rdev);
+       rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
        rv770_halt_smc(rdev);
-       rv770_upload_sw_state(rdev);
-       r7xx_program_memory_timing_parameters(rdev);
+       rv770_upload_sw_state(rdev, new_ps);
+       r7xx_program_memory_timing_parameters(rdev, new_ps);
        if (pi->dcodt)
-               rv770_program_dcodt_before_state_switch(rdev);
+               rv770_program_dcodt_before_state_switch(rdev, new_ps, old_ps);
        rv770_resume_smc(rdev);
        rv770_set_sw_state(rdev);
        if (pi->dcodt)
-               rv770_program_dcodt_after_state_switch(rdev);
-       rv770_set_uvd_clock_after_set_eng_clock(rdev);
+               rv770_program_dcodt_after_state_switch(rdev, new_ps, old_ps);
+       rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
        rv770_unrestrict_performance_levels_after_switch(rdev);
 
        return 0;
@@ -2011,13 +2015,14 @@ int rv770_dpm_set_power_state(struct radeon_device *rdev)
 void rv770_dpm_reset_asic(struct radeon_device *rdev)
 {
        struct rv7xx_power_info *pi = rv770_get_pi(rdev);
+       struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
 
        rv770_restrict_performance_levels_before_switch(rdev);
        if (pi->dcodt)
-               rv770_program_dcodt_before_state_switch(rdev);
+               rv770_program_dcodt_before_state_switch(rdev, boot_ps, boot_ps);
        rv770_set_boot_state(rdev);
        if (pi->dcodt)
-               rv770_program_dcodt_after_state_switch(rdev);
+               rv770_program_dcodt_after_state_switch(rdev, boot_ps, boot_ps);
 }
 
 void rv770_dpm_setup_asic(struct radeon_device *rdev)
index d1fb1cfac43d09d4121346337c43b9fd8ba8170a..7fa14b9557f3a795f3f8b9bc8ac0d111c5ee638f 100644 (file)
@@ -267,8 +267,12 @@ int rv770_resume_smc(struct radeon_device *rdev);
 int rv770_set_sw_state(struct radeon_device *rdev);
 int rv770_set_boot_state(struct radeon_device *rdev);
 int rv7xx_parse_power_table(struct radeon_device *rdev);
-void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev);
-void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev);
+void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev,
+                                             struct radeon_ps *new_ps,
+                                             struct radeon_ps *old_ps);
+void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev,
+                                            struct radeon_ps *new_ps,
+                                            struct radeon_ps *old_ps);
 
 /* smc */
 int rv770_read_smc_soft_register(struct radeon_device *rdev,