diff options
| author | Alex Deucher <alexander.deucher@amd.com> | 2022-02-21 16:01:03 -0500 | 
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2022-02-23 14:02:51 -0500 | 
| commit | 5a82b018230b3947a736f45afa95cab434455248 (patch) | |
| tree | 8388e53d70236764a026e3fda9bc617b47459c98 /drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | |
| parent | a7f520bfd0551f9fd672b45b9b3cc56ab4275128 (diff) | |
drm/amdgpu: use kernel BO API for benchmark buffer management
Simplifies the code quite a bit.
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | 78 | 
1 files changed, 17 insertions, 61 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c index 9973b6266a3d..0701b7dbf5f9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c @@ -75,57 +75,25 @@ static int amdgpu_benchmark_move(struct amdgpu_device *adev, unsigned size,  {  	struct amdgpu_bo *dobj = NULL;  	struct amdgpu_bo *sobj = NULL; -	struct amdgpu_bo_param bp;  	uint64_t saddr, daddr;  	int r, n; -	memset(&bp, 0, sizeof(bp)); -	bp.size = size; -	bp.byte_align = PAGE_SIZE; -	bp.domain = sdomain; -	bp.flags = 0; -	bp.type = ttm_bo_type_kernel; -	bp.resv = NULL; -	bp.bo_ptr_size = sizeof(struct amdgpu_bo); -  	n = AMDGPU_BENCHMARK_ITERATIONS; -	r = amdgpu_bo_create(adev, &bp, &sobj); -	if (r) { -		goto out_cleanup; -	} -	r = amdgpu_bo_reserve(sobj, false); -	if (unlikely(r != 0)) -		goto out_cleanup; -	r = amdgpu_bo_pin(sobj, sdomain); -	if (r) { -		amdgpu_bo_unreserve(sobj); -		goto out_cleanup; -	} -	r = amdgpu_ttm_alloc_gart(&sobj->tbo); -	amdgpu_bo_unreserve(sobj); -	if (r) { -		goto out_cleanup; -	} -	saddr = amdgpu_bo_gpu_offset(sobj); -	bp.domain = ddomain; -	r = amdgpu_bo_create(adev, &bp, &dobj); -	if (r) { -		goto out_cleanup; -	} -	r = amdgpu_bo_reserve(dobj, false); -	if (unlikely(r != 0)) + +	r = amdgpu_bo_create_kernel(adev, size, +				    PAGE_SIZE, sdomain, +				    &sobj, +				    &saddr, +				    NULL); +	if (r)  		goto out_cleanup; -	r = amdgpu_bo_pin(dobj, ddomain); -	if (r) { -		amdgpu_bo_unreserve(sobj); +	r = amdgpu_bo_create_kernel(adev, size, +				    PAGE_SIZE, ddomain, +				    &dobj, +				    &daddr, +				    NULL); +	if (r)  		goto out_cleanup; -	} -	r = amdgpu_ttm_alloc_gart(&dobj->tbo); -	amdgpu_bo_unreserve(dobj); -	if (r) { -		goto out_cleanup; -	} -	daddr = amdgpu_bo_gpu_offset(dobj);  	if (adev->mman.buffer_funcs) {  		r = amdgpu_benchmark_do_move(adev, size, saddr, daddr, n); @@ -141,22 +109,10 @@ out_cleanup:  	if (r < 0)  		dev_info(adev->dev, "Error while benchmarking BO move.\n"); -	if (sobj) { -		r = amdgpu_bo_reserve(sobj, true); -		if (likely(r == 0)) { -			amdgpu_bo_unpin(sobj); -			amdgpu_bo_unreserve(sobj); -		} -		amdgpu_bo_unref(&sobj); -	} -	if (dobj) { -		r = amdgpu_bo_reserve(dobj, true); -		if (likely(r == 0)) { -			amdgpu_bo_unpin(dobj); -			amdgpu_bo_unreserve(dobj); -		} -		amdgpu_bo_unref(&dobj); -	} +	if (sobj) +		amdgpu_bo_free_kernel(&sobj, &saddr, NULL); +	if (dobj) +		amdgpu_bo_free_kernel(&dobj, &daddr, NULL);  	return r;  } | 
