Skip to contentSkip to conversation

drm/amdgpu: add cancel_delayed_work_sync before power gate

PATCH In review James Zhu 3 participants 3 messages May 17, 2021 – May 18, 2021

Subsystems (2)
lore
Share & tools
lore

James Zhu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: add cancel_delayed_work_sync before power gate

Add cancel_delayed_work_sync before set power gating state to avoid race condition issue when power gating.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +13 -6
index 779e585..360dff2 100644
@@ -388,6 +388,19 @@ static int vcn_v3_0_hw_fini(void *handle)
 			continue;
 
 		ring = &adev->vcn.inst[i].ring_dec;
+		ring->sched.ready = false;
+
+		for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
+			ring = &adev->vcn.inst[i].ring_enc[j];
+			ring->sched.ready = false;
+		}
+	}
+
+	cancel_delayed_work_sync(&adev->vcn.idle_work);
+
+	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
+		if (adev->vcn.harvest_config & (1 << i))
+			continue;
 
 		if (!amdgpu_sriov_vf(adev)) {
 			if ((adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) ||
@@ -396,12 +409,6 @@ static int vcn_v3_0_hw_fini(void *handle)
 				vcn_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE);
 			}
 		}
-		ring->sched.ready = false;
-
-		for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
-			ring = &adev->vcn.inst[i].ring_enc[j];
-			ring->sched.ready = false;
-		}
 	}
 
 	return 0;
Signature · 6 lines
2.7.4

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

Am 17.05.21 um 22:42 schrieb James Zhu:

Quoted 2 lines

Add cancel_delayed_work_sync before set power gating state to avoid race condition issue when power gating.

Sounds logical to me, but Leo needs to take a look as well.

Quoted 33 lines
---
  drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 19 +++++++++++++------
  1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +13 -0
index 779e585..360dff2 100644
@@ -388,6 +388,19 @@ static int vcn_v3_0_hw_fini(void *handle)
  			continue;
 
  		ring = &adev->vcn.inst[i].ring_dec;
+		ring->sched.ready = false;
+
+		for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
+			ring = &adev->vcn.inst[i].ring_enc[j];
+			ring->sched.ready = false;
+		}
+	}
+
+	cancel_delayed_work_sync(&adev->vcn.idle_work);
+
+	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
+		if (adev->vcn.harvest_config & (1 << i))
+			continue;
 
  		if (!amdgpu_sriov_vf(adev)) {
  			if ((adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) ||
@@ -396,12 +409,6 @@ static int vcn_v3_0_hw_fini(void *handle)
  				vcn_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE);
  			}

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c static int vcn_v3_0_hw_fini(void *handle) · line 414

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0 -6
  		}
-		ring->sched.ready = false;
-
-		for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
-			ring = &adev->vcn.inst[i].ring_enc[j];
-			ring->sched.ready = false;
-		}
  	}
 
  	return 0;

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

Reviewed-by on v1 1/1
#2 lore raw
In reply to James Zhu
Quoted 35 lines · James Zhu

Add cancel_delayed_work_sync before set power gating state to avoid race condition issue when power gating.

---
  drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 19 +++++++++++++------
  1 file changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +13 -0
index 779e585..360dff2 100644
@@ -388,6 +388,19 @@ static int vcn_v3_0_hw_fini(void *handle)
  			continue;
 
  		ring = &adev->vcn.inst[i].ring_dec;
+		ring->sched.ready = false;
+
+		for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
+			ring = &adev->vcn.inst[i].ring_enc[j];
+			ring->sched.ready = false;
+		}
+	}
+
+	cancel_delayed_work_sync(&adev->vcn.idle_work);
+
+	for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
+		if (adev->vcn.harvest_config & (1 << i))
+			continue;
 
  		if (!amdgpu_sriov_vf(adev)) {
  			if ((adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) ||
@@ -396,12 +409,6 @@ static int vcn_v3_0_hw_fini(void *handle)
  				vcn_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE);
  			}

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c static int vcn_v3_0_hw_fini(void *handle) · line 414

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0 -6
  		}
-		ring->sched.ready = false;
-
-		for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
-			ring = &adev->vcn.inst[i].ring_enc[j];
-			ring->sched.ready = false;
-		}
  	}
 
  	return 0;

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