diff options
author | Huang Rui <ray.huang@amd.com> | 2017-01-05 08:07:02 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-01-27 11:13:10 -0500 |
commit | c8781f56c85997a42e8ab3254f37c0c301f6b490 (patch) | |
tree | 4d40ca1dbf030f9a55abe3484cbddde839ff5c3c /drivers/gpu | |
parent | abd2c2fe1212698ed326d5746e487abecb2ed325 (diff) |
drm/amdgpu: add get clockgating_state method for uvd v5&v6
Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 33 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 33 |
3 files changed, 63 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index c2372902f722..5fa7c96dd307 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1037,6 +1037,7 @@ struct amdgpu_uvd { | |||
1037 | bool use_ctx_buf; | 1037 | bool use_ctx_buf; |
1038 | struct amd_sched_entity entity; | 1038 | struct amd_sched_entity entity; |
1039 | uint32_t srbm_soft_reset; | 1039 | uint32_t srbm_soft_reset; |
1040 | bool is_powergated; | ||
1040 | }; | 1041 | }; |
1041 | 1042 | ||
1042 | /* | 1043 | /* |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c index 6de6becce745..9b49824233ae 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | |||
@@ -822,16 +822,44 @@ static int uvd_v5_0_set_powergating_state(void *handle, | |||
822 | * the smc and the hw blocks | 822 | * the smc and the hw blocks |
823 | */ | 823 | */ |
824 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 824 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
825 | int ret = 0; | ||
825 | 826 | ||
826 | if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD)) | 827 | if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD)) |
827 | return 0; | 828 | return 0; |
828 | 829 | ||
829 | if (state == AMD_PG_STATE_GATE) { | 830 | if (state == AMD_PG_STATE_GATE) { |
830 | uvd_v5_0_stop(adev); | 831 | uvd_v5_0_stop(adev); |
831 | return 0; | 832 | adev->uvd.is_powergated = true; |
832 | } else { | 833 | } else { |
833 | return uvd_v5_0_start(adev); | 834 | ret = uvd_v5_0_start(adev); |
835 | if (ret) | ||
836 | goto out; | ||
837 | adev->uvd.is_powergated = false; | ||
838 | } | ||
839 | |||
840 | out: | ||
841 | return ret; | ||
842 | } | ||
843 | |||
844 | static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags) | ||
845 | { | ||
846 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
847 | int data; | ||
848 | |||
849 | mutex_lock(&adev->pm.mutex); | ||
850 | |||
851 | if (adev->uvd.is_powergated) { | ||
852 | DRM_INFO("Cannot get clockgating state when UVD is powergated.\n"); | ||
853 | goto out; | ||
834 | } | 854 | } |
855 | |||
856 | /* AMD_CG_SUPPORT_UVD_MGCG */ | ||
857 | data = RREG32(mmUVD_CGC_CTRL); | ||
858 | if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK) | ||
859 | *flags |= AMD_CG_SUPPORT_UVD_MGCG; | ||
860 | |||
861 | out: | ||
862 | mutex_unlock(&adev->pm.mutex); | ||
835 | } | 863 | } |
836 | 864 | ||
837 | static const struct amd_ip_funcs uvd_v5_0_ip_funcs = { | 865 | static const struct amd_ip_funcs uvd_v5_0_ip_funcs = { |
@@ -849,6 +877,7 @@ static const struct amd_ip_funcs uvd_v5_0_ip_funcs = { | |||
849 | .soft_reset = uvd_v5_0_soft_reset, | 877 | .soft_reset = uvd_v5_0_soft_reset, |
850 | .set_clockgating_state = uvd_v5_0_set_clockgating_state, | 878 | .set_clockgating_state = uvd_v5_0_set_clockgating_state, |
851 | .set_powergating_state = uvd_v5_0_set_powergating_state, | 879 | .set_powergating_state = uvd_v5_0_set_powergating_state, |
880 | .get_clockgating_state = uvd_v5_0_get_clockgating_state, | ||
852 | }; | 881 | }; |
853 | 882 | ||
854 | static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { | 883 | static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index ba0bbf7138dc..de7e03544d00 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
@@ -1047,6 +1047,7 @@ static int uvd_v6_0_set_powergating_state(void *handle, | |||
1047 | * the smc and the hw blocks | 1047 | * the smc and the hw blocks |
1048 | */ | 1048 | */ |
1049 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1049 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1050 | int ret = 0; | ||
1050 | 1051 | ||
1051 | if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD)) | 1052 | if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD)) |
1052 | return 0; | 1053 | return 0; |
@@ -1055,10 +1056,37 @@ static int uvd_v6_0_set_powergating_state(void *handle, | |||
1055 | 1056 | ||
1056 | if (state == AMD_PG_STATE_GATE) { | 1057 | if (state == AMD_PG_STATE_GATE) { |
1057 | uvd_v6_0_stop(adev); | 1058 | uvd_v6_0_stop(adev); |
1058 | return 0; | 1059 | adev->uvd.is_powergated = true; |
1059 | } else { | 1060 | } else { |
1060 | return uvd_v6_0_start(adev); | 1061 | ret = uvd_v6_0_start(adev); |
1062 | if (ret) | ||
1063 | goto out; | ||
1064 | adev->uvd.is_powergated = false; | ||
1065 | } | ||
1066 | |||
1067 | out: | ||
1068 | return ret; | ||
1069 | } | ||
1070 | |||
1071 | static void uvd_v6_0_get_clockgating_state(void *handle, u32 *flags) | ||
1072 | { | ||
1073 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
1074 | int data; | ||
1075 | |||
1076 | mutex_lock(&adev->pm.mutex); | ||
1077 | |||
1078 | if (adev->uvd.is_powergated) { | ||
1079 | DRM_INFO("Cannot get clockgating state when UVD is powergated.\n"); | ||
1080 | goto out; | ||
1061 | } | 1081 | } |
1082 | |||
1083 | /* AMD_CG_SUPPORT_UVD_MGCG */ | ||
1084 | data = RREG32(mmUVD_CGC_CTRL); | ||
1085 | if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK) | ||
1086 | *flags |= AMD_CG_SUPPORT_UVD_MGCG; | ||
1087 | |||
1088 | out: | ||
1089 | mutex_unlock(&adev->pm.mutex); | ||
1062 | } | 1090 | } |
1063 | 1091 | ||
1064 | static const struct amd_ip_funcs uvd_v6_0_ip_funcs = { | 1092 | static const struct amd_ip_funcs uvd_v6_0_ip_funcs = { |
@@ -1079,6 +1107,7 @@ static const struct amd_ip_funcs uvd_v6_0_ip_funcs = { | |||
1079 | .post_soft_reset = uvd_v6_0_post_soft_reset, | 1107 | .post_soft_reset = uvd_v6_0_post_soft_reset, |
1080 | .set_clockgating_state = uvd_v6_0_set_clockgating_state, | 1108 | .set_clockgating_state = uvd_v6_0_set_clockgating_state, |
1081 | .set_powergating_state = uvd_v6_0_set_powergating_state, | 1109 | .set_powergating_state = uvd_v6_0_set_powergating_state, |
1110 | .get_clockgating_state = uvd_v6_0_get_clockgating_state, | ||
1082 | }; | 1111 | }; |
1083 | 1112 | ||
1084 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = { | 1113 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = { |