diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 56 |
1 files changed, 5 insertions, 51 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 13ea4da9f23a..f623c71977e9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1700,6 +1700,7 @@ static bool amdgpu_device_check_vram_lost(struct amdgpu_device *adev) | |||
1700 | * Fini or suspend, pass disabling clockgating for hardware IPs. | 1700 | * Fini or suspend, pass disabling clockgating for hardware IPs. |
1701 | * Returns 0 on success, negative error code on failure. | 1701 | * Returns 0 on success, negative error code on failure. |
1702 | */ | 1702 | */ |
1703 | |||
1703 | static int amdgpu_device_set_cg_state(struct amdgpu_device *adev, | 1704 | static int amdgpu_device_set_cg_state(struct amdgpu_device *adev, |
1704 | enum amd_clockgating_state state) | 1705 | enum amd_clockgating_state state) |
1705 | { | 1706 | { |
@@ -1819,21 +1820,13 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) | |||
1819 | amdgpu_amdkfd_device_fini(adev); | 1820 | amdgpu_amdkfd_device_fini(adev); |
1820 | 1821 | ||
1821 | amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE); | 1822 | amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE); |
1823 | amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE); | ||
1824 | |||
1822 | /* need to disable SMC first */ | 1825 | /* need to disable SMC first */ |
1823 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1826 | for (i = 0; i < adev->num_ip_blocks; i++) { |
1824 | if (!adev->ip_blocks[i].status.hw) | 1827 | if (!adev->ip_blocks[i].status.hw) |
1825 | continue; | 1828 | continue; |
1826 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC && | 1829 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) { |
1827 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { | ||
1828 | /* ungate blocks before hw fini so that we can shutdown the blocks safely */ | ||
1829 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, | ||
1830 | AMD_CG_STATE_UNGATE); | ||
1831 | if (r) { | ||
1832 | DRM_ERROR("set_clockgating_state(ungate) of IP block <%s> failed %d\n", | ||
1833 | adev->ip_blocks[i].version->funcs->name, r); | ||
1834 | return r; | ||
1835 | } | ||
1836 | |||
1837 | r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev); | 1830 | r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev); |
1838 | /* XXX handle errors */ | 1831 | /* XXX handle errors */ |
1839 | if (r) { | 1832 | if (r) { |
@@ -1849,20 +1842,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) | |||
1849 | if (!adev->ip_blocks[i].status.hw) | 1842 | if (!adev->ip_blocks[i].status.hw) |
1850 | continue; | 1843 | continue; |
1851 | 1844 | ||
1852 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && | ||
1853 | adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCE && | ||
1854 | adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCN && | ||
1855 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { | ||
1856 | /* ungate blocks before hw fini so that we can shutdown the blocks safely */ | ||
1857 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, | ||
1858 | AMD_CG_STATE_UNGATE); | ||
1859 | if (r) { | ||
1860 | DRM_ERROR("set_clockgating_state(ungate) of IP block <%s> failed %d\n", | ||
1861 | adev->ip_blocks[i].version->funcs->name, r); | ||
1862 | return r; | ||
1863 | } | ||
1864 | } | ||
1865 | |||
1866 | r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev); | 1845 | r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev); |
1867 | /* XXX handle errors */ | 1846 | /* XXX handle errors */ |
1868 | if (r) { | 1847 | if (r) { |
@@ -1957,21 +1936,13 @@ static int amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev) | |||
1957 | amdgpu_virt_request_full_gpu(adev, false); | 1936 | amdgpu_virt_request_full_gpu(adev, false); |
1958 | 1937 | ||
1959 | amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE); | 1938 | amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE); |
1939 | amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE); | ||
1960 | 1940 | ||
1961 | for (i = adev->num_ip_blocks - 1; i >= 0; i--) { | 1941 | for (i = adev->num_ip_blocks - 1; i >= 0; i--) { |
1962 | if (!adev->ip_blocks[i].status.valid) | 1942 | if (!adev->ip_blocks[i].status.valid) |
1963 | continue; | 1943 | continue; |
1964 | /* displays are handled separately */ | 1944 | /* displays are handled separately */ |
1965 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE) { | 1945 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE) { |
1966 | /* ungate blocks so that suspend can properly shut them down */ | ||
1967 | if (adev->ip_blocks[i].version->funcs->set_clockgating_state) { | ||
1968 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, | ||
1969 | AMD_CG_STATE_UNGATE); | ||
1970 | if (r) { | ||
1971 | DRM_ERROR("set_clockgating_state(ungate) of IP block <%s> failed %d\n", | ||
1972 | adev->ip_blocks[i].version->funcs->name, r); | ||
1973 | } | ||
1974 | } | ||
1975 | /* XXX handle errors */ | 1946 | /* XXX handle errors */ |
1976 | r = adev->ip_blocks[i].version->funcs->suspend(adev); | 1947 | r = adev->ip_blocks[i].version->funcs->suspend(adev); |
1977 | /* XXX handle errors */ | 1948 | /* XXX handle errors */ |
@@ -2006,29 +1977,12 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev) | |||
2006 | if (amdgpu_sriov_vf(adev)) | 1977 | if (amdgpu_sriov_vf(adev)) |
2007 | amdgpu_virt_request_full_gpu(adev, false); | 1978 | amdgpu_virt_request_full_gpu(adev, false); |
2008 | 1979 | ||
2009 | /* ungate SMC block first */ | ||
2010 | r = amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_SMC, | ||
2011 | AMD_CG_STATE_UNGATE); | ||
2012 | if (r) { | ||
2013 | DRM_ERROR("set_clockgating_state(ungate) SMC failed %d\n", r); | ||
2014 | } | ||
2015 | |||
2016 | for (i = adev->num_ip_blocks - 1; i >= 0; i--) { | 1980 | for (i = adev->num_ip_blocks - 1; i >= 0; i--) { |
2017 | if (!adev->ip_blocks[i].status.valid) | 1981 | if (!adev->ip_blocks[i].status.valid) |
2018 | continue; | 1982 | continue; |
2019 | /* displays are handled in phase1 */ | 1983 | /* displays are handled in phase1 */ |
2020 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE) | 1984 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE) |
2021 | continue; | 1985 | continue; |
2022 | /* ungate blocks so that suspend can properly shut them down */ | ||
2023 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_SMC && | ||
2024 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { | ||
2025 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, | ||
2026 | AMD_CG_STATE_UNGATE); | ||
2027 | if (r) { | ||
2028 | DRM_ERROR("set_clockgating_state(ungate) of IP block <%s> failed %d\n", | ||
2029 | adev->ip_blocks[i].version->funcs->name, r); | ||
2030 | } | ||
2031 | } | ||
2032 | /* XXX handle errors */ | 1986 | /* XXX handle errors */ |
2033 | r = adev->ip_blocks[i].version->funcs->suspend(adev); | 1987 | r = adev->ip_blocks[i].version->funcs->suspend(adev); |
2034 | /* XXX handle errors */ | 1988 | /* XXX handle errors */ |