diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 33 | 
1 files changed, 19 insertions, 14 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 06d07502a1f6..970b065e9a6b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -32,6 +32,7 @@  #include <drm/amdgpu_drm.h>  #include <drm/drm_syncobj.h> +#include "amdgpu_cs.h"  #include "amdgpu.h"  #include "amdgpu_trace.h"  #include "amdgpu_gmc.h" @@ -127,8 +128,6 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs  		goto free_chunk;  	} -	mutex_lock(&p->ctx->lock); -  	/* skip guilty context job */  	if (atomic_read(&p->ctx->guilty) == 1) {  		ret = -ECANCELED; @@ -314,7 +313,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,  	}  	total_vram = adev->gmc.real_vram_size - atomic64_read(&adev->vram_pin_size); -	used_vram = amdgpu_vram_mgr_usage(&adev->mman.vram_mgr); +	used_vram = ttm_resource_manager_usage(&adev->mman.vram_mgr.manager);  	free_vram = used_vram >= total_vram ? 0 : total_vram - used_vram;  	spin_lock(&adev->mm_stats.lock); @@ -341,7 +340,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,  	if (free_vram >= 128 * 1024 * 1024 || free_vram >= total_vram / 8) {  		s64 min_us; -		/* Be more aggresive on dGPUs. Try to fill a portion of free +		/* Be more aggressive on dGPUs. Try to fill a portion of free  		 * VRAM now.  		 */  		if (!(adev->flags & AMD_IS_APU)) @@ -585,6 +584,16 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,  		}  	} +	/* Move fence waiting after getting reservation lock of +	 * PD root. Then there is no need on a ctx mutex lock. +	 */ +	r = amdgpu_ctx_wait_prev_fence(p->ctx, p->entity); +	if (unlikely(r != 0)) { +		if (r != -ERESTARTSYS) +			DRM_ERROR("amdgpu_ctx_wait_prev_fence failed.\n"); +		goto error_validate; +	} +  	amdgpu_cs_get_threshold_for_moves(p->adev, &p->bytes_moved_threshold,  					  &p->bytes_moved_vis_threshold);  	p->bytes_moved = 0; @@ -700,7 +709,6 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error,  	dma_fence_put(parser->fence);  	if (parser->ctx) { -		mutex_unlock(&parser->ctx->lock);  		amdgpu_ctx_put(parser->ctx);  	}  	if (parser->bo_list) @@ -775,12 +783,12 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)  				memcpy(ib->ptr, kptr, chunk_ib->ib_bytes);  				amdgpu_bo_kunmap(aobj); -				r = amdgpu_ring_parse_cs(ring, p, j); +				r = amdgpu_ring_parse_cs(ring, p, p->job, ib);  				if (r)  					return r;  			} else {  				ib->ptr = (uint32_t *)kptr; -				r = amdgpu_ring_patch_cs_in_place(ring, p, j); +				r = amdgpu_ring_patch_cs_in_place(ring, p, p->job, ib);  				amdgpu_bo_kunmap(aobj);  				if (r)  					return r; @@ -944,7 +952,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,  	if (parser->job->uf_addr && ring->funcs->no_user_fence)  		return -EINVAL; -	return amdgpu_ctx_wait_prev_fence(parser->ctx, parser->entity); +	return 0;  }  static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p, @@ -1272,16 +1280,13 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,  			continue;  		/* -		 * Work around dma_resv shortcommings by wrapping up the +		 * Work around dma_resv shortcomings by wrapping up the  		 * submission in a dma_fence_chain and add it as exclusive -		 * fence, but first add the submission as shared fence to make -		 * sure that shared fences never signal before the exclusive -		 * one. +		 * fence.  		 */  		dma_fence_chain_init(chain, dma_resv_excl_fence(resv),  				     dma_fence_get(p->fence), 1); -		dma_resv_add_shared_fence(resv, p->fence);  		rcu_assign_pointer(resv->fence_excl, &chain->base);  		e->chain = NULL;  	} @@ -1363,7 +1368,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)  		goto out;  	r = amdgpu_cs_submit(&parser, cs); -  out:  	amdgpu_cs_parser_fini(&parser, r, reserved_buffers); @@ -1509,6 +1513,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data,  		return 0;  	default: +		dma_fence_put(fence);  		return -EINVAL;  	}  } |