[PATCH 2/2] dmr/amdgpu: Move old fence waiting before reservation lock is aquired.

Christian König ckoenig.leichtzumerken at gmail.com
Mon Oct 9 08:36:05 UTC 2017


Am 06.10.2017 um 20:20 schrieb Andrey Grodzovsky:
> From: Andrey Grodzovsky <Andrey.Grodzovsky at amd.com>
>
> This allows to avoid deadlock during GPU reset.
>
> Change-Id: I817e351b02e653f078063c57cec8a0d94062de12
> Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c  | 15 +++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c |  8 ++------
>   2 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 0fa1bc7..79fefc8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -931,6 +931,9 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
>   {
>   	int i, j;
>   	int r, ce_preempt = 0, de_preempt = 0;
> +	struct amdgpu_ctx_ring *cring;
> +	unsigned idx = 0;
> +	struct dma_fence *other = NULL;
>   
>   	for (i = 0, j = 0; i < parser->nchunks && j < parser->job->num_ibs; i++) {
>   		struct amdgpu_cs_chunk *chunk;
> @@ -983,6 +986,18 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
>   	    parser->job->ring->funcs->type == AMDGPU_RING_TYPE_VCE))
>   		return -EINVAL;
>   
> +	cring = &parser->ctx->rings[parser->job->ring->idx];
> +	idx = cring->sequence & (amdgpu_sched_jobs - 1);
> +	other = cring->fences[idx];
> +	if (other) {
> +		signed long r;
> +		r = dma_fence_wait_timeout(other, false, MAX_SCHEDULE_TIMEOUT);
> +		if (r < 0) {
> +			DRM_ERROR("Error (%ld) waiting for fence!\n", r);
> +			return r;
> +		}
> +	}
> +

Please move that into a helper function in amdgpu_ctx.c

Apart from that the change looks good to me.

Christian.

>   	return 0;
>   }
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index c073a68..758b643 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -260,12 +260,8 @@ uint64_t amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring,
>   
>   	idx = seq & (amdgpu_sched_jobs - 1);
>   	other = cring->fences[idx];
> -	if (other) {
> -		signed long r;
> -		r = dma_fence_wait_timeout(other, false, MAX_SCHEDULE_TIMEOUT);
> -		if (r < 0)
> -			DRM_ERROR("Error (%ld) waiting for fence!\n", r);
> -	}
> +	if (other)
> +		BUG_ON(!dma_fence_is_signaled(other));
>   
>   	dma_fence_get(fence);
>   




More information about the amd-gfx mailing list