diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2013-01-16 18:53:40 (GMT) |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2013-06-27 23:16:18 (GMT) |
commit | a284c48ae7217fc362b851c68f74d7b414061704 (patch) | |
tree | d26e64601b9fbd29ed7e144c957b3e97b8404813 | |
parent | 422a56bc8a5aaa6d48b244a1ba0484ef4d62a7ac (diff) | |
download | linux-fsl-qoriq-a284c48ae7217fc362b851c68f74d7b414061704.tar.xz |
drm/radeon/dpm: add pre/post_set_power_state callback (TN)
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>
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_asic.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_asic.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/trinity_dpm.c | 73 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/trinity_dpm.h | 6 |
4 files changed, 61 insertions, 22 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index b0d055a..c99fae7 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c @@ -2091,7 +2091,9 @@ static struct radeon_asic trinity_asic = { .setup_asic = &trinity_dpm_setup_asic, .enable = &trinity_dpm_enable, .disable = &trinity_dpm_disable, + .pre_set_power_state = &trinity_dpm_pre_set_power_state, .set_power_state = &trinity_dpm_set_power_state, + .post_set_power_state = &trinity_dpm_post_set_power_state, .display_configuration_changed = &trinity_dpm_display_configuration_changed, .fini = &trinity_dpm_fini, .get_sclk = &trinity_dpm_get_sclk, diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index 57fd4c0..4870ef9 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h @@ -604,7 +604,9 @@ void ni_dpm_print_power_state(struct radeon_device *rdev, int trinity_dpm_init(struct radeon_device *rdev); int trinity_dpm_enable(struct radeon_device *rdev); void trinity_dpm_disable(struct radeon_device *rdev); +int trinity_dpm_pre_set_power_state(struct radeon_device *rdev); int trinity_dpm_set_power_state(struct radeon_device *rdev); +void trinity_dpm_post_set_power_state(struct radeon_device *rdev); void trinity_dpm_setup_asic(struct radeon_device *rdev); void trinity_dpm_display_configuration_changed(struct radeon_device *rdev); void trinity_dpm_fini(struct radeon_device *rdev); diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c index 103efbc..1699e93 100644 --- a/drivers/gpu/drm/radeon/trinity_dpm.c +++ b/drivers/gpu/drm/radeon/trinity_dpm.c @@ -832,15 +832,6 @@ static void trinity_unforce_levels(struct radeon_device *rdev) trinity_dpm_no_forced_level(rdev); } -static void trinity_update_current_power_levels(struct radeon_device *rdev, - struct radeon_ps *rps) -{ - struct trinity_ps *new_ps = trinity_get_ps(rps); - struct trinity_power_info *pi = trinity_get_pi(rdev); - - pi->current_ps = *new_ps; -} - static void trinity_program_power_levels_0_to_n(struct radeon_device *rdev, struct radeon_ps *new_rps, struct radeon_ps *old_rps) @@ -1046,6 +1037,28 @@ static int trinity_set_thermal_temperature_range(struct radeon_device *rdev, return 0; } +static void trinity_update_current_ps(struct radeon_device *rdev, + struct radeon_ps *rps) +{ + struct trinity_ps *new_ps = trinity_get_ps(rps); + struct trinity_power_info *pi = trinity_get_pi(rdev); + + pi->current_rps = *rps; + pi->current_ps = *new_ps; + pi->current_rps.ps_priv = &pi->current_ps; +} + +static void trinity_update_requested_ps(struct radeon_device *rdev, + struct radeon_ps *rps) +{ + struct trinity_ps *new_ps = trinity_get_ps(rps); + struct trinity_power_info *pi = trinity_get_pi(rdev); + + pi->requested_rps = *rps; + pi->requested_ps = *new_ps; + pi->requested_rps.ps_priv = &pi->requested_ps; +} + int trinity_dpm_enable(struct radeon_device *rdev) { struct trinity_power_info *pi = trinity_get_pi(rdev); @@ -1077,6 +1090,8 @@ int trinity_dpm_enable(struct radeon_device *rdev) radeon_irq_set(rdev); } + trinity_update_current_ps(rdev, rdev->pm.dpm.boot_ps); + return 0; } @@ -1099,6 +1114,8 @@ void trinity_dpm_disable(struct radeon_device *rdev) rdev->irq.dpm_thermal = false; radeon_irq_set(rdev); } + + trinity_update_current_ps(rdev, rdev->pm.dpm.boot_ps); } static void trinity_get_min_sclk_divider(struct radeon_device *rdev) @@ -1127,14 +1144,26 @@ static void trinity_setup_nbp_sim(struct radeon_device *rdev, } } -int trinity_dpm_set_power_state(struct radeon_device *rdev) +int trinity_dpm_pre_set_power_state(struct radeon_device *rdev) { struct trinity_power_info *pi = trinity_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; + + trinity_update_requested_ps(rdev, new_ps); - trinity_apply_state_adjust_rules(rdev, new_ps, old_ps); - trinity_update_current_power_levels(rdev, new_ps); + trinity_apply_state_adjust_rules(rdev, + &pi->requested_rps, + &pi->current_rps); + + return 0; +} + +int trinity_dpm_set_power_state(struct radeon_device *rdev) +{ + struct trinity_power_info *pi = trinity_get_pi(rdev); + struct radeon_ps *new_ps = &pi->requested_rps; + struct radeon_ps *old_ps = &pi->current_rps; trinity_acquire_mutex(rdev); if (pi->enable_dpm) { @@ -1153,6 +1182,14 @@ int trinity_dpm_set_power_state(struct radeon_device *rdev) return 0; } +void trinity_dpm_post_set_power_state(struct radeon_device *rdev) +{ + struct trinity_power_info *pi = trinity_get_pi(rdev); + struct radeon_ps *new_ps = &pi->requested_rps; + + trinity_update_current_ps(rdev, new_ps); +} + void trinity_dpm_setup_asic(struct radeon_device *rdev) { trinity_acquire_mutex(rdev); @@ -1390,11 +1427,6 @@ static void trinity_apply_state_adjust_rules(struct radeon_device *rdev, bool force_high; u32 num_active_displays = rdev->pm.dpm.new_active_crtc_count; - /* 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 trinity_patch_thermal_state(rdev, ps, current_ps); @@ -1833,7 +1865,8 @@ void trinity_dpm_fini(struct radeon_device *rdev) u32 trinity_dpm_get_sclk(struct radeon_device *rdev, bool low) { - struct trinity_ps *requested_state = trinity_get_ps(rdev->pm.dpm.requested_ps); + struct trinity_power_info *pi = trinity_get_pi(rdev); + struct trinity_ps *requested_state = trinity_get_ps(&pi->requested_rps); if (low) return requested_state->levels[0].sclk; diff --git a/drivers/gpu/drm/radeon/trinity_dpm.h b/drivers/gpu/drm/radeon/trinity_dpm.h index c663aed..c621b84 100644 --- a/drivers/gpu/drm/radeon/trinity_dpm.h +++ b/drivers/gpu/drm/radeon/trinity_dpm.h @@ -97,7 +97,6 @@ struct trinity_power_info { u32 thermal_auto_throttling; struct trinity_sys_info sys_info; struct trinity_pl boot_pl; - struct trinity_ps current_ps; u32 min_sclk_did; bool enable_nbps_policy; bool voltage_drop_in_dce; @@ -110,7 +109,10 @@ struct trinity_power_info { bool enable_dpm; bool enable_sclk_ds; bool uvd_dpm; - struct trinity_ps hw_ps; + struct radeon_ps current_rps; + struct trinity_ps current_ps; + struct radeon_ps requested_rps; + struct trinity_ps requested_ps; }; #define TRINITY_AT_DFLT 30 |