Skip to contentSkip to conversation

drm/amdgpu: disable gfxoff if VCN is busy

PATCH Superseded Jiansong Chen 3 participants 4 messages Oct 30, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: disable gfxoff if VCN is busy

Toggle on/off gfxoff during video playback to fix
gpu hang.

Change-Id I5b938c446884268c2cda0801121a53da980e603a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +7 -3
index 277a8435dd06..444b89413232 100644
@@ -358,6 +358,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 	}
 
 	if (!fences && !atomic_read(&adev->vcn.total_submission_cnt)) {
+		amdgpu_gfx_off_ctrl(adev, true);
 		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
 		       AMD_PG_STATE_GATE);
 	} else {
@@ -368,13 +369,16 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
+	bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work);
 
 	atomic_inc(&adev->vcn.total_submission_cnt);
-	cancel_delayed_work_sync(&adev->vcn.idle_work);
 
 	mutex_lock(&adev->vcn.vcn_pg_lock);
-	amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
-	       AMD_PG_STATE_UNGATE);
+	if (set_clocks) {
+		amdgpu_gfx_off_ctrl(adev, false);
+		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
+			AMD_PG_STATE_UNGATE);
+	}
 
 	if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG)	{
 		struct dpg_pause_state new_state;
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw

[AMD Public Use]

Regards,
Hawking
-----Original Message-----
From: Jiansong Chen <[email protected]>
Sent: Friday, October 30, 2020 19:37
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhu, James <[email protected]>; Liu, Leo <[email protected]>; Zhou1, Tao <[email protected]>; Chen, Jiansong (Simon) <[email protected]>
Subject: [PATCH] drm/amdgpu: disable gfxoff if VCN is busy

Toggle on/off gfxoff during video playback to fix gpu hang.

Change-Id I5b938c446884268c2cda0801121a53da980e603a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +7 -4
index 277a8435dd06..444b89413232 100644
@@ -358,6 +358,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 	}
 
 	if (!fences && !atomic_read(&adev->vcn.total_submission_cnt)) {
+		amdgpu_gfx_off_ctrl(adev, true);
 		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
 		       AMD_PG_STATE_GATE);
 	} else {
@@ -368,13 +369,16 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)  void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)  {
 	struct amdgpu_device *adev = ring->adev;
+	bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work);
 
 	atomic_inc(&adev->vcn.total_submission_cnt);
-	cancel_delayed_work_sync(&adev->vcn.idle_work);
 
 	mutex_lock(&adev->vcn.vcn_pg_lock);
-	amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
-	       AMD_PG_STATE_UNGATE);
+	if (set_clocks) {
+		amdgpu_gfx_off_ctrl(adev, false);
+		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
+			AMD_PG_STATE_UNGATE);
+	}
 
 	if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG)	{
 		struct dpg_pause_state new_state;
--

2.25.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
In reply to Jiansong Chen

Hi Jiansong

Pls check inline.

thanks!

James

Quoted 2 lines · Jiansong Chen

Toggle on/off gfxoff during video playback to fix
gpu hang.

[JZ] It is a workaround, not a fix. Also Arcturus needn't this WA.

Quoted 22 lines
Change-Id I5b938c446884268c2cda0801121a53da980e603a
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +1 -0
index 277a8435dd06..444b89413232 100644
@@ -358,6 +358,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
  	}
 
  	if (!fences && !atomic_read(&adev->vcn.total_submission_cnt)) {
+		amdgpu_gfx_off_ctrl(adev, true);
  		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
  		       AMD_PG_STATE_GATE);
  	} else {
@@ -368,13 +369,16 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
  void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
  {
  	struct amdgpu_device *adev = ring->adev;

drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 378

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +3 -3
+	bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work);
 
  	atomic_inc(&adev->vcn.total_submission_cnt);
-	cancel_delayed_work_sync(&adev->vcn.idle_work);
 
  	mutex_lock(&adev->vcn.vcn_pg_lock);
-	amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
-	       AMD_PG_STATE_UNGATE);
+	if (set_clocks) {
+		amdgpu_gfx_off_ctrl(adev, false);

[JZ] Move the above two lines before mutex_lock(&adev->vcn.vcn_pg_lock);

Since it may cause S3 test failure.

drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 384

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +3 -0
+		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
+			AMD_PG_STATE_UNGATE);
+	}
 
  	if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG)	{
  		struct dpg_pause_state new_state;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw

[AMD Official Use Only - Internal Distribution Only]

Hi James,
Thanks for your input, v2 patch is sent out.

Regards,
Jiansong
-----Original Message-----
From: Zhu, James <[email protected]>
Sent: Friday, October 30, 2020 9:06 PM
To: Chen, Jiansong (Simon) <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhu, James <[email protected]>; Liu, Leo <[email protected]>; Zhou1, Tao <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: disable gfxoff if VCN is busy

Hi Jiansong

Pls check inline.

thanks!

James

Quoted 1 line · Jiansong Chen

Toggle on/off gfxoff during video playback to fix gpu hang.

[JZ] It is a workaround, not a fix. Also Arcturus needn't this WA.

Quoted 23 lines
Change-Id I5b938c446884268c2cda0801121a53da980e603a
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +1 -0
index 277a8435dd06..444b89413232 100644
@@ -358,6 +358,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
  }
 
  if (!fences && !atomic_read(&adev->vcn.total_submission_cnt)) {
+amdgpu_gfx_off_ctrl(adev, true);
  amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
         AMD_PG_STATE_GATE);
  } else {
@@ -368,13 +369,16 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
  void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
  {
  struct amdgpu_device *adev = ring->adev;

drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 378

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +3 -3
+bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work);
 
  atomic_inc(&adev->vcn.total_submission_cnt);
-cancel_delayed_work_sync(&adev->vcn.idle_work);
 
  mutex_lock(&adev->vcn.vcn_pg_lock);
-amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
-       AMD_PG_STATE_UNGATE);
+if (set_clocks) {
+amdgpu_gfx_off_ctrl(adev, false);

[JZ] Move the above two lines before mutex_lock(&adev->vcn.vcn_pg_lock);

Since it may cause S3 test failure.

drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 384

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +3 -0
+amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
+AMD_PG_STATE_UNGATE);
+}
 
  if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG){
  struct dpg_pause_state new_state;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx