All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: add cancel_delayed_work_sync before power gate
@ 2021-05-17 20:42 James Zhu
  2021-05-18 13:05 ` Christian König
  2021-05-18 13:29 ` Leo Liu
  0 siblings, 2 replies; 3+ messages in thread
From: James Zhu @ 2021-05-17 20:42 UTC (permalink / raw)
  To: amd-gfx; +Cc: jamesz

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

Signed-off-by: James Zhu <James.Zhu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index 779e585..360dff2 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -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;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amdgpu: add cancel_delayed_work_sync before power gate
  2021-05-17 20:42 [PATCH] drm/amdgpu: add cancel_delayed_work_sync before power gate James Zhu
@ 2021-05-18 13:05 ` Christian König
  2021-05-18 13:29 ` Leo Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2021-05-18 13:05 UTC (permalink / raw)
  To: James Zhu, amd-gfx; +Cc: jamesz

Am 17.05.21 um 22:42 schrieb James Zhu:
> 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.

Acked-by: Christian König <christian.koenig@amd.com>

>
> Signed-off-by: James Zhu <James.Zhu@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 19 +++++++++++++------
>   1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> index 779e585..360dff2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> @@ -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;

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amdgpu: add cancel_delayed_work_sync before power gate
  2021-05-17 20:42 [PATCH] drm/amdgpu: add cancel_delayed_work_sync before power gate James Zhu
  2021-05-18 13:05 ` Christian König
@ 2021-05-18 13:29 ` Leo Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Leo Liu @ 2021-05-18 13:29 UTC (permalink / raw)
  To: James Zhu, amd-gfx; +Cc: jamesz

Reviewed-by: Leo Liu <leo.liu@amd.com>

On 2021-05-17 4:42 p.m., James Zhu wrote:
> Add cancel_delayed_work_sync before set power gating state
> to avoid race condition issue when power gating.
>
> Signed-off-by: James Zhu <James.Zhu@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 19 +++++++++++++------
>   1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> index 779e585..360dff2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> @@ -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;
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-18 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 20:42 [PATCH] drm/amdgpu: add cancel_delayed_work_sync before power gate James Zhu
2021-05-18 13:05 ` Christian König
2021-05-18 13:29 ` Leo Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.