aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/kv_dpm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/kv_dpm.c68
1 files changed, 15 insertions, 53 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
index 8785ca570729..f5a343cb0010 100644
--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
@@ -1550,11 +1550,6 @@ static int kv_update_vce_dpm(struct amdgpu_device *adev,
1550 1550
1551 if (amdgpu_new_state->evclk > 0 && amdgpu_current_state->evclk == 0) { 1551 if (amdgpu_new_state->evclk > 0 && amdgpu_current_state->evclk == 0) {
1552 kv_dpm_powergate_vce(adev, false); 1552 kv_dpm_powergate_vce(adev, false);
1553 /* turn the clocks on when encoding */
1554 ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE,
1555 AMD_CG_STATE_UNGATE);
1556 if (ret)
1557 return ret;
1558 if (pi->caps_stable_p_state) 1553 if (pi->caps_stable_p_state)
1559 pi->vce_boot_level = table->count - 1; 1554 pi->vce_boot_level = table->count - 1;
1560 else 1555 else
@@ -1573,15 +1568,9 @@ static int kv_update_vce_dpm(struct amdgpu_device *adev,
1573 amdgpu_kv_send_msg_to_smc_with_parameter(adev, 1568 amdgpu_kv_send_msg_to_smc_with_parameter(adev,
1574 PPSMC_MSG_VCEDPM_SetEnabledMask, 1569 PPSMC_MSG_VCEDPM_SetEnabledMask,
1575 (1 << pi->vce_boot_level)); 1570 (1 << pi->vce_boot_level));
1576
1577 kv_enable_vce_dpm(adev, true); 1571 kv_enable_vce_dpm(adev, true);
1578 } else if (amdgpu_new_state->evclk == 0 && amdgpu_current_state->evclk > 0) { 1572 } else if (amdgpu_new_state->evclk == 0 && amdgpu_current_state->evclk > 0) {
1579 kv_enable_vce_dpm(adev, false); 1573 kv_enable_vce_dpm(adev, false);
1580 /* turn the clocks off when not encoding */
1581 ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE,
1582 AMD_CG_STATE_GATE);
1583 if (ret)
1584 return ret;
1585 kv_dpm_powergate_vce(adev, true); 1574 kv_dpm_powergate_vce(adev, true);
1586 } 1575 }
1587 1576
@@ -1688,70 +1677,44 @@ static void kv_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate)
1688 struct kv_power_info *pi = kv_get_pi(adev); 1677 struct kv_power_info *pi = kv_get_pi(adev);
1689 int ret; 1678 int ret;
1690 1679
1691 if (pi->uvd_power_gated == gate)
1692 return;
1693
1694 pi->uvd_power_gated = gate; 1680 pi->uvd_power_gated = gate;
1695 1681
1696 if (gate) { 1682 if (gate) {
1697 if (pi->caps_uvd_pg) { 1683 /* stop the UVD block */
1698 /* disable clockgating so we can properly shut down the block */ 1684 ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
1699 ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD, 1685 AMD_PG_STATE_GATE);
1700 AMD_CG_STATE_UNGATE);
1701 /* shutdown the UVD block */
1702 ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
1703 AMD_PG_STATE_GATE);
1704 /* XXX: check for errors */
1705 }
1706 kv_update_uvd_dpm(adev, gate); 1686 kv_update_uvd_dpm(adev, gate);
1707 if (pi->caps_uvd_pg) 1687 if (pi->caps_uvd_pg)
1708 /* power off the UVD block */ 1688 /* power off the UVD block */
1709 amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_UVDPowerOFF); 1689 amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_UVDPowerOFF);
1710 } else { 1690 } else {
1711 if (pi->caps_uvd_pg) { 1691 if (pi->caps_uvd_pg)
1712 /* power on the UVD block */ 1692 /* power on the UVD block */
1713 amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_UVDPowerON); 1693 amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_UVDPowerON);
1714 /* re-init the UVD block */ 1694 /* re-init the UVD block */
1715 ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
1716 AMD_PG_STATE_UNGATE);
1717 /* enable clockgating. hw will dynamically gate/ungate clocks on the fly */
1718 ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
1719 AMD_CG_STATE_GATE);
1720 /* XXX: check for errors */
1721 }
1722 kv_update_uvd_dpm(adev, gate); 1695 kv_update_uvd_dpm(adev, gate);
1696
1697 ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
1698 AMD_PG_STATE_UNGATE);
1723 } 1699 }
1724} 1700}
1725 1701
1726static void kv_dpm_powergate_vce(struct amdgpu_device *adev, bool gate) 1702static void kv_dpm_powergate_vce(struct amdgpu_device *adev, bool gate)
1727{ 1703{
1728 struct kv_power_info *pi = kv_get_pi(adev); 1704 struct kv_power_info *pi = kv_get_pi(adev);
1729 int ret;
1730 1705
1731 if (pi->vce_power_gated == gate) 1706 if (pi->vce_power_gated == gate)
1732 return; 1707 return;
1733 1708
1734 pi->vce_power_gated = gate; 1709 pi->vce_power_gated = gate;
1735 1710
1736 if (gate) { 1711 if (!pi->caps_vce_pg)
1737 if (pi->caps_vce_pg) { 1712 return;
1738 /* shutdown the VCE block */ 1713
1739 ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, 1714 if (gate)
1740 AMD_PG_STATE_GATE); 1715 amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerOFF);
1741 /* XXX: check for errors */ 1716 else
1742 /* power off the VCE block */ 1717 amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerON);
1743 amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerOFF);
1744 }
1745 } else {
1746 if (pi->caps_vce_pg) {
1747 /* power on the VCE block */
1748 amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerON);
1749 /* re-init the VCE block */
1750 ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE,
1751 AMD_PG_STATE_UNGATE);
1752 /* XXX: check for errors */
1753 }
1754 }
1755} 1718}
1756 1719
1757static void kv_dpm_powergate_samu(struct amdgpu_device *adev, bool gate) 1720static void kv_dpm_powergate_samu(struct amdgpu_device *adev, bool gate)
@@ -3009,8 +2972,7 @@ static int kv_dpm_late_init(void *handle)
3009 2972
3010 kv_dpm_powergate_acp(adev, true); 2973 kv_dpm_powergate_acp(adev, true);
3011 kv_dpm_powergate_samu(adev, true); 2974 kv_dpm_powergate_samu(adev, true);
3012 kv_dpm_powergate_vce(adev, true); 2975
3013 kv_dpm_powergate_uvd(adev, true);
3014 return 0; 2976 return 0;
3015} 2977}
3016 2978