drm/amdgpu: add missing cleanups for Polaris12 UVD/VCE on suspend
Subsystems (2)
PATCH v2 1/3 drm/amdgpu: add missing cleanups for Polaris12 UVD/VCE on suspend
Perform proper cleanups on UVD/VCE suspend: powergate enablement, clockgating enablement and dpm disablement. This can fix some hangs observed on suspending when UVD/VCE still using(e.g. issue "pm-suspend" when video is still playing).
--v1->v2:
- move the changes to ->hw_fini() (James Zhu)
--- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+)
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +24 -0
@@ -543,6 +543,30 @@ static int uvd_v6_0_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->uvd.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_uvd (adev, false); + }else { +amdgpu_asic_set_uvd_clocks (adev,0 ,0 ); +/* shutdown the UVD block */ +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_CG_STATE_GATE ); + } +if (RREG32 (mmUVD_STATUS) !=0 )uvd_v6_0_stop (adev);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +23 -0
@@ -490,6 +490,29 @@ static int vce_v3_0_hw_fini(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->vce.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_vce (adev, false); + }else { +amdgpu_asic_set_vce_clocks (adev,0 ,0 ); +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_CG_STATE_GATE ); + } + r =vce_v3_0_wait_for_idle (handle);if (r)return r;
Signature · 1 line
2.29.0
PATCH v2 2/3 drm/amdgpu: add missing cleanups for more ASICs on UVD/VCE suspend
This is a supplement for commit below:
"drm/amdgpu: add missing cleanups for Polaris12 UVD/VCE on suspend".
--- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 25 ++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vce_v4_0.c | 23 +++++++++++++++++++++++ 6 files changed, 144 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +24 -0
@@ -698,6 +698,30 @@ static int uvd_v3_1_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->uvd.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_uvd (adev, false); + }else { +amdgpu_asic_set_uvd_clocks (adev,0 ,0 ); +/* shutdown the UVD block */ +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_CG_STATE_GATE ); + } +if (RREG32 (mmUVD_STATUS) !=0 )uvd_v3_1_stop (adev);
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c +24 -0
@@ -212,6 +212,30 @@ static int uvd_v4_2_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->uvd.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_uvd (adev, false); + }else { +amdgpu_asic_set_uvd_clocks (adev,0 ,0 ); +/* shutdown the UVD block */ +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_CG_STATE_GATE ); + } +if (RREG32 (mmUVD_STATUS) !=0 )uvd_v4_2_stop (adev);
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +24 -1
@@ -210,6 +210,30 @@ static int uvd_v5_0_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->uvd.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_uvd (adev, false); + }else { +amdgpu_asic_set_uvd_clocks (adev,0 ,0 ); +/* shutdown the UVD block */ +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_CG_STATE_GATE ); + } +if (RREG32 (mmUVD_STATUS) !=0 )uvd_v5_0_stop (adev);
@@ -224,7 +248,6 @@ static int uvd_v5_0_suspend(void *handle) r =uvd_v5_0_hw_fini (adev);if (r)return r; -uvd_v5_0_set_clockgating_state (adev,AMD_CG_STATE_GATE );return amdgpu_uvd_suspend (adev); }
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +24 -0
@@ -605,6 +605,30 @@ static int uvd_v7_0_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->uvd.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_uvd (adev, false); + }else { +amdgpu_asic_set_uvd_clocks (adev,0 ,0 ); +/* shutdown the UVD block */ +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_CG_STATE_GATE ); + } +if (!amdgpu_sriov_vf (adev))uvd_v7_0_stop (adev);else {
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c +25 -0
@@ -478,6 +478,31 @@ static int vce_v2_0_hw_init(void *handle)static int vce_v2_0_hw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->vce.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_vce (adev, false); + }else { +amdgpu_asic_set_vce_clocks (adev,0 ,0 ); +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_CG_STATE_GATE ); + } +return 0 ; }
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +23 -0
@@ -541,6 +541,29 @@ static int vce_v4_0_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->vce.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_vce (adev, false); + }else { +amdgpu_asic_set_vce_clocks (adev,0 ,0 ); +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_CG_STATE_GATE ); + } +if (!amdgpu_sriov_vf (adev)) {/* vce_v4_0_wait_for_idle(handle); */ vce_v4_0_stop (adev);
Signature · 1 line
2.29.0
PATCH v2 3/3 drm/amdgpu: drop redundant cancel_delayed_work_sync call
In reply to Evan QuanAs those _sw_fini() APIs follow just after _suspend() APIs. And the cancel_delayed_work_sync was already called in latter.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 -- 4 files changed, 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c +0 -2
@@ -47,8 +47,6 @@ int amdgpu_jpeg_sw_fini(struct amdgpu_device *adev) {int i; -cancel_delayed_work_sync (&adev->jpeg.idle_work); -for (i =0 ; i < adev->jpeg.num_jpeg_inst; ++i) {if (adev->jpeg.harvest_config & (1 << i))continue ;
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -1
@@ -325,7 +325,6 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) {int i, j; -cancel_delayed_work_sync (&adev->uvd.idle_work);drm_sched_entity_destroy (&adev->uvd.entity);for (j =0 ; j < adev->uvd.num_uvd_inst; ++j) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0 -1
@@ -217,7 +217,6 @@ int amdgpu_vce_sw_fini(struct amdgpu_device *adev)if (adev->vce.vcpu_bo ==NULL )return 0 ; -cancel_delayed_work_sync (&adev->vce.idle_work);drm_sched_entity_destroy (&adev->vce.entity); amdgpu_bo_free_kernel(&adev->vce.vcpu_bo, &adev->vce.gpu_addr,
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0 -2
@@ -257,8 +257,6 @@ int amdgpu_vcn_sw_fini(struct amdgpu_device *adev) {int i, j; -cancel_delayed_work_sync (&adev->vcn.idle_work); -for (j =0 ; j < adev->vcn.num_vcn_inst; ++j) {if (adev->vcn.harvest_config & (1 << j))continue ;
Signature · 1 line
2.29.0
[Public]
Series is:
As we have rooted cause this issue, shall we revert former patch "drm/amdgpu: disable BACO support for 699F:C7 polaris12 SKU temporarily"?
Regards,
Guchun
-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Monday, August 23, 2021 4:35 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>; Lazar, Lijo <[email protected]>; Zhu, James <[email protected]>; Liu, Leo <[email protected]>; Quan, Evan <[email protected]>; Pan, Xinhui <[email protected]>
Subject: [PATCH V2 1/3] drm/amdgpu: add missing cleanups for Polaris12 UVD/VCE on suspend
Perform proper cleanups on UVD/VCE suspend: powergate enablement, clockgating enablement and dpm disablement. This can fix some hangs observed on suspending when UVD/VCE still using(e.g. issue "pm-suspend" when video is still playing).
--v1->v2:
- move the changes to ->hw_fini() (James Zhu)
--- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+)
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +24 -0
@@ -543,6 +543,30 @@ static int uvd_v6_0_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->uvd.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_uvd (adev, false); + }else { +amdgpu_asic_set_uvd_clocks (adev,0 ,0 ); +/* shutdown the UVD block */ +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_CG_STATE_GATE ); + } +if (RREG32 (mmUVD_STATUS) !=0 )uvd_v6_0_stop (adev);
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +23 -0
@@ -490,6 +490,29 @@ static int vce_v3_0_hw_fini(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->vce.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_vce (adev, false); + }else { +amdgpu_asic_set_vce_clocks (adev,0 ,0 ); +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_CG_STATE_GATE ); + } + r =vce_v3_0_wait_for_idle (handle);if (r)return r;
--
2.29.0
[Public]
Quoted 10 lines
-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Monday, August 23, 2021 4:44 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Lazar, Lijo <[email protected]>; Zhu, James <[email protected]>; Liu, Leo <[email protected]>; Pan, Xinhui <[email protected]>
Subject: RE: [PATCH V2 1/3] drm/amdgpu: add missing cleanups for Polaris12 UVD/VCE on suspend
Quoted 7 lines
[Public]
Series is:
Reviewed-by Guchun Chen <[email protected]>As we have rooted cause this issue, shall we revert former patch "drm/amdgpu: disable BACO support for 699F:C7 polaris12 SKU temporarily"?
[Quan, Evan] Yes, I will do that after those patches landed.
Thanks,
Evan
Quoted 108 lines
Regards,
Guchun-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Monday, August 23, 2021 4:35 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Chen, Guchun <[email protected]>; Lazar, Lijo <[email protected]>; Zhu, James <[email protected]>; Liu, Leo <[email protected]>; Quan, Evan <[email protected]>; Pan, Xinhui <[email protected]>
Subject: [PATCH V2 1/3] drm/amdgpu: add missing cleanups for Polaris12 UVD/VCE on suspendPerform proper cleanups on UVD/VCE suspend: powergate enablement, clockgating enablement and dpm disablement. This can fix some hangs observed on suspending when UVD/VCE still using(e.g. issue "pm-suspend" when video is still playing).
Change-Id I36f39d9731e0a9638b52d5d92558b0ee9c23a9edSigned-off-by Evan Quan <[email protected]>Signed-off-by xinhui pan <[email protected]>--
v1->v2:
- move the changes to ->hw_fini() (James Zhu)--- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+)drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +24
-0@@ -543,6 +543,30 @@ static int uvd_v6_0_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->uvd.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_uvd (adev, false); + }else { +amdgpu_asic_set_uvd_clocks (adev,0 ,0 ); +/* shutdown the UVD block */ +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_UVD , +AMD_CG_STATE_GATE ); + } +if (RREG32 (mmUVD_STATUS) !=0 )uvd_v6_0_stop (adev);drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +23
-0@@ -490,6 +490,29 @@ static int vce_v3_0_hw_fini(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; +/* +* Proper cleanups before halting the HW engine: +* - cancel the delayed idle work +* - enable powergating +* - enable clockgating +* - disable dpm +* +* TODO: to align with the VCN implementation, move the +* jobs for clockgating/powergating/dpm setting to +* ->set_powergating_state(). +*/ +cancel_delayed_work_sync (&adev->vce.idle_work); + +if (adev->pm.dpm_enabled) { +amdgpu_dpm_enable_vce (adev, false); + }else { +amdgpu_asic_set_vce_clocks (adev,0 ,0 ); +amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_PG_STATE_GATE ); +amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_VCE , +AMD_CG_STATE_GATE ); + } + r =vce_v3_0_wait_for_idle (handle);drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +0
-1if (r)return r; --2.29.0