diff options
-rw-r--r-- | drivers/gpu/drm/radeon/ci_dpm.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c index 4a0c40186046..c91d0ee9dfdc 100644 --- a/drivers/gpu/drm/radeon/ci_dpm.c +++ b/drivers/gpu/drm/radeon/ci_dpm.c | |||
@@ -746,6 +746,14 @@ static void ci_apply_state_adjust_rules(struct radeon_device *rdev, | |||
746 | u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc; | 746 | u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc; |
747 | int i; | 747 | int i; |
748 | 748 | ||
749 | if (rps->vce_active) { | ||
750 | rps->evclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].evclk; | ||
751 | rps->ecclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].ecclk; | ||
752 | } else { | ||
753 | rps->evclk = 0; | ||
754 | rps->ecclk = 0; | ||
755 | } | ||
756 | |||
749 | if ((rdev->pm.dpm.new_active_crtc_count > 1) || | 757 | if ((rdev->pm.dpm.new_active_crtc_count > 1) || |
750 | ci_dpm_vblank_too_short(rdev)) | 758 | ci_dpm_vblank_too_short(rdev)) |
751 | disable_mclk_switching = true; | 759 | disable_mclk_switching = true; |
@@ -804,6 +812,13 @@ static void ci_apply_state_adjust_rules(struct radeon_device *rdev, | |||
804 | sclk = ps->performance_levels[0].sclk; | 812 | sclk = ps->performance_levels[0].sclk; |
805 | } | 813 | } |
806 | 814 | ||
815 | if (rps->vce_active) { | ||
816 | if (sclk < rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].sclk) | ||
817 | sclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].sclk; | ||
818 | if (mclk < rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].mclk) | ||
819 | mclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].mclk; | ||
820 | } | ||
821 | |||
807 | ps->performance_levels[0].sclk = sclk; | 822 | ps->performance_levels[0].sclk = sclk; |
808 | ps->performance_levels[0].mclk = mclk; | 823 | ps->performance_levels[0].mclk = mclk; |
809 | 824 | ||
@@ -3468,7 +3483,6 @@ static int ci_enable_uvd_dpm(struct radeon_device *rdev, bool enable) | |||
3468 | 0 : -EINVAL; | 3483 | 0 : -EINVAL; |
3469 | } | 3484 | } |
3470 | 3485 | ||
3471 | #if 0 | ||
3472 | static int ci_enable_vce_dpm(struct radeon_device *rdev, bool enable) | 3486 | static int ci_enable_vce_dpm(struct radeon_device *rdev, bool enable) |
3473 | { | 3487 | { |
3474 | struct ci_power_info *pi = ci_get_pi(rdev); | 3488 | struct ci_power_info *pi = ci_get_pi(rdev); |
@@ -3501,6 +3515,7 @@ static int ci_enable_vce_dpm(struct radeon_device *rdev, bool enable) | |||
3501 | 0 : -EINVAL; | 3515 | 0 : -EINVAL; |
3502 | } | 3516 | } |
3503 | 3517 | ||
3518 | #if 0 | ||
3504 | static int ci_enable_samu_dpm(struct radeon_device *rdev, bool enable) | 3519 | static int ci_enable_samu_dpm(struct radeon_device *rdev, bool enable) |
3505 | { | 3520 | { |
3506 | struct ci_power_info *pi = ci_get_pi(rdev); | 3521 | struct ci_power_info *pi = ci_get_pi(rdev); |
@@ -3587,7 +3602,6 @@ static int ci_update_uvd_dpm(struct radeon_device *rdev, bool gate) | |||
3587 | return ci_enable_uvd_dpm(rdev, !gate); | 3602 | return ci_enable_uvd_dpm(rdev, !gate); |
3588 | } | 3603 | } |
3589 | 3604 | ||
3590 | #if 0 | ||
3591 | static u8 ci_get_vce_boot_level(struct radeon_device *rdev) | 3605 | static u8 ci_get_vce_boot_level(struct radeon_device *rdev) |
3592 | { | 3606 | { |
3593 | u8 i; | 3607 | u8 i; |
@@ -3608,13 +3622,11 @@ static int ci_update_vce_dpm(struct radeon_device *rdev, | |||
3608 | struct radeon_ps *radeon_current_state) | 3622 | struct radeon_ps *radeon_current_state) |
3609 | { | 3623 | { |
3610 | struct ci_power_info *pi = ci_get_pi(rdev); | 3624 | struct ci_power_info *pi = ci_get_pi(rdev); |
3611 | bool new_vce_clock_non_zero = (radeon_new_state->evclk != 0); | ||
3612 | bool old_vce_clock_non_zero = (radeon_current_state->evclk != 0); | ||
3613 | int ret = 0; | 3625 | int ret = 0; |
3614 | u32 tmp; | 3626 | u32 tmp; |
3615 | 3627 | ||
3616 | if (new_vce_clock_non_zero != old_vce_clock_non_zero) { | 3628 | if (radeon_current_state->evclk != radeon_new_state->evclk) { |
3617 | if (new_vce_clock_non_zero) { | 3629 | if (radeon_new_state->evclk) { |
3618 | pi->smc_state_table.VceBootLevel = ci_get_vce_boot_level(rdev); | 3630 | pi->smc_state_table.VceBootLevel = ci_get_vce_boot_level(rdev); |
3619 | 3631 | ||
3620 | tmp = RREG32_SMC(DPM_TABLE_475); | 3632 | tmp = RREG32_SMC(DPM_TABLE_475); |
@@ -3630,6 +3642,7 @@ static int ci_update_vce_dpm(struct radeon_device *rdev, | |||
3630 | return ret; | 3642 | return ret; |
3631 | } | 3643 | } |
3632 | 3644 | ||
3645 | #if 0 | ||
3633 | static int ci_update_samu_dpm(struct radeon_device *rdev, bool gate) | 3646 | static int ci_update_samu_dpm(struct radeon_device *rdev, bool gate) |
3634 | { | 3647 | { |
3635 | return ci_enable_samu_dpm(rdev, gate); | 3648 | return ci_enable_samu_dpm(rdev, gate); |
@@ -4752,13 +4765,13 @@ int ci_dpm_set_power_state(struct radeon_device *rdev) | |||
4752 | DRM_ERROR("ci_generate_dpm_level_enable_mask failed\n"); | 4765 | DRM_ERROR("ci_generate_dpm_level_enable_mask failed\n"); |
4753 | return ret; | 4766 | return ret; |
4754 | } | 4767 | } |
4755 | #if 0 | 4768 | |
4756 | ret = ci_update_vce_dpm(rdev, new_ps, old_ps); | 4769 | ret = ci_update_vce_dpm(rdev, new_ps, old_ps); |
4757 | if (ret) { | 4770 | if (ret) { |
4758 | DRM_ERROR("ci_update_vce_dpm failed\n"); | 4771 | DRM_ERROR("ci_update_vce_dpm failed\n"); |
4759 | return ret; | 4772 | return ret; |
4760 | } | 4773 | } |
4761 | #endif | 4774 | |
4762 | ret = ci_update_sclk_t(rdev); | 4775 | ret = ci_update_sclk_t(rdev); |
4763 | if (ret) { | 4776 | if (ret) { |
4764 | DRM_ERROR("ci_update_sclk_t failed\n"); | 4777 | DRM_ERROR("ci_update_sclk_t failed\n"); |
@@ -4995,6 +5008,21 @@ static int ci_parse_power_table(struct radeon_device *rdev) | |||
4995 | power_state_offset += 2 + power_state->v2.ucNumDPMLevels; | 5008 | power_state_offset += 2 + power_state->v2.ucNumDPMLevels; |
4996 | } | 5009 | } |
4997 | rdev->pm.dpm.num_ps = state_array->ucNumEntries; | 5010 | rdev->pm.dpm.num_ps = state_array->ucNumEntries; |
5011 | |||
5012 | /* fill in the vce power states */ | ||
5013 | for (i = 0; i < RADEON_MAX_VCE_LEVELS; i++) { | ||
5014 | u32 sclk, mclk; | ||
5015 | clock_array_index = rdev->pm.dpm.vce_states[i].clk_idx; | ||
5016 | clock_info = (union pplib_clock_info *) | ||
5017 | &clock_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize]; | ||
5018 | sclk = le16_to_cpu(clock_info->ci.usEngineClockLow); | ||
5019 | sclk |= clock_info->ci.ucEngineClockHigh << 16; | ||
5020 | mclk = le16_to_cpu(clock_info->ci.usMemoryClockLow); | ||
5021 | mclk |= clock_info->ci.ucMemoryClockHigh << 16; | ||
5022 | rdev->pm.dpm.vce_states[i].sclk = sclk; | ||
5023 | rdev->pm.dpm.vce_states[i].mclk = mclk; | ||
5024 | } | ||
5025 | |||
4998 | return 0; | 5026 | return 0; |
4999 | } | 5027 | } |
5000 | 5028 | ||
@@ -5080,12 +5108,14 @@ int ci_dpm_init(struct radeon_device *rdev) | |||
5080 | ci_dpm_fini(rdev); | 5108 | ci_dpm_fini(rdev); |
5081 | return ret; | 5109 | return ret; |
5082 | } | 5110 | } |
5083 | ret = ci_parse_power_table(rdev); | 5111 | |
5112 | ret = r600_parse_extended_power_table(rdev); | ||
5084 | if (ret) { | 5113 | if (ret) { |
5085 | ci_dpm_fini(rdev); | 5114 | ci_dpm_fini(rdev); |
5086 | return ret; | 5115 | return ret; |
5087 | } | 5116 | } |
5088 | ret = r600_parse_extended_power_table(rdev); | 5117 | |
5118 | ret = ci_parse_power_table(rdev); | ||
5089 | if (ret) { | 5119 | if (ret) { |
5090 | ci_dpm_fini(rdev); | 5120 | ci_dpm_fini(rdev); |
5091 | return ret; | 5121 | return ret; |