aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Rui <ray.huang@amd.com>2017-01-05 08:27:31 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-01-27 11:13:11 -0500
commitc79b55618a9c9fe2b8cd30ab2c9486d3ca3f1ff3 (patch)
tree19a088583c85dd35e2882a7c7f8f519a04557cdf
parentc8781f56c85997a42e8ab3254f37c0c301f6b490 (diff)
drm/amdgpu: add get clockgating_state method for vce v3
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>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vce_v3_0.c40
2 files changed, 37 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 5fa7c96dd307..393f75f65d4c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1066,6 +1066,7 @@ struct amdgpu_vce {
1066 struct amd_sched_entity entity; 1066 struct amd_sched_entity entity;
1067 uint32_t srbm_soft_reset; 1067 uint32_t srbm_soft_reset;
1068 unsigned num_rings; 1068 unsigned num_rings;
1069 bool is_powergated;
1069}; 1070};
1070 1071
1071/* 1072/*
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
index 37ca685e5a9a..afec2e9d01bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
@@ -777,15 +777,46 @@ static int vce_v3_0_set_powergating_state(void *handle,
777 * the smc and the hw blocks 777 * the smc and the hw blocks
778 */ 778 */
779 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 779 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
780 int ret = 0;
780 781
781 if (!(adev->pg_flags & AMD_PG_SUPPORT_VCE)) 782 if (!(adev->pg_flags & AMD_PG_SUPPORT_VCE))
782 return 0; 783 return 0;
783 784
784 if (state == AMD_PG_STATE_GATE) 785 if (state == AMD_PG_STATE_GATE) {
786 adev->vce.is_powergated = true;
785 /* XXX do we need a vce_v3_0_stop()? */ 787 /* XXX do we need a vce_v3_0_stop()? */
786 return 0; 788 } else {
787 else 789 ret = vce_v3_0_start(adev);
788 return vce_v3_0_start(adev); 790 if (ret)
791 goto out;
792 adev->vce.is_powergated = false;
793 }
794
795out:
796 return ret;
797}
798
799static void vce_v3_0_get_clockgating_state(void *handle, u32 *flags)
800{
801 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
802 int data;
803
804 mutex_lock(&adev->pm.mutex);
805
806 if (adev->vce.is_powergated) {
807 DRM_INFO("Cannot get clockgating state when VCE is powergated.\n");
808 goto out;
809 }
810
811 WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0);
812
813 /* AMD_CG_SUPPORT_VCE_MGCG */
814 data = RREG32(mmVCE_CLOCK_GATING_A);
815 if (data & (0x04 << 4))
816 *flags |= AMD_CG_SUPPORT_VCE_MGCG;
817
818out:
819 mutex_unlock(&adev->pm.mutex);
789} 820}
790 821
791static void vce_v3_0_ring_emit_ib(struct amdgpu_ring *ring, 822static void vce_v3_0_ring_emit_ib(struct amdgpu_ring *ring,
@@ -839,6 +870,7 @@ static const struct amd_ip_funcs vce_v3_0_ip_funcs = {
839 .post_soft_reset = vce_v3_0_post_soft_reset, 870 .post_soft_reset = vce_v3_0_post_soft_reset,
840 .set_clockgating_state = vce_v3_0_set_clockgating_state, 871 .set_clockgating_state = vce_v3_0_set_clockgating_state,
841 .set_powergating_state = vce_v3_0_set_powergating_state, 872 .set_powergating_state = vce_v3_0_set_powergating_state,
873 .get_clockgating_state = vce_v3_0_get_clockgating_state,
842}; 874};
843 875
844static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = { 876static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = {