Commit cb9038aa authored by xinhui pan's avatar xinhui pan Committed by Alex Deucher
Browse files

drm/amdgpu: VCE avoid memory allocation during IB test



alloc extra msg from direct IB pool.

Signed-off-by: default avatarxinhui pan <xinhui.pan@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 68331d7c
Loading
Loading
Loading
Loading
+13 −14
Original line number Original line Diff line number Diff line
@@ -82,7 +82,6 @@ MODULE_FIRMWARE(FIRMWARE_VEGA20);


static void amdgpu_vce_idle_work_handler(struct work_struct *work);
static void amdgpu_vce_idle_work_handler(struct work_struct *work);
static int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
static int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
				     struct amdgpu_bo *bo,
				     struct dma_fence **fence);
				     struct dma_fence **fence);
static int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
static int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
				      bool direct, struct dma_fence **fence);
				      bool direct, struct dma_fence **fence);
@@ -441,12 +440,12 @@ void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp)
 * Open up a stream for HW test
 * Open up a stream for HW test
 */
 */
static int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
static int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
				     struct amdgpu_bo *bo,
				     struct dma_fence **fence)
				     struct dma_fence **fence)
{
{
	const unsigned ib_size_dw = 1024;
	const unsigned ib_size_dw = 1024;
	struct amdgpu_job *job;
	struct amdgpu_job *job;
	struct amdgpu_ib *ib;
	struct amdgpu_ib *ib;
	struct amdgpu_ib ib_msg;
	struct dma_fence *f = NULL;
	struct dma_fence *f = NULL;
	uint64_t addr;
	uint64_t addr;
	int i, r;
	int i, r;
@@ -456,9 +455,17 @@ static int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
	if (r)
	if (r)
		return r;
		return r;


	ib = &job->ibs[0];
	memset(&ib_msg, 0, sizeof(ib_msg));
	/* only one gpu page is needed, alloc +1 page to make addr aligned. */
	r = amdgpu_ib_get(ring->adev, NULL, AMDGPU_GPU_PAGE_SIZE * 2,
			  AMDGPU_IB_POOL_DIRECT,
			  &ib_msg);
	if (r)
		goto err;


	addr = amdgpu_bo_gpu_offset(bo);
	ib = &job->ibs[0];
	/* let addr point to page boundary */
	addr = AMDGPU_GPU_PAGE_ALIGN(ib_msg.gpu_addr);


	/* stitch together an VCE create msg */
	/* stitch together an VCE create msg */
	ib->length_dw = 0;
	ib->length_dw = 0;
@@ -498,6 +505,7 @@ static int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
		ib->ptr[i] = 0x0;
		ib->ptr[i] = 0x0;


	r = amdgpu_job_submit_direct(job, ring, &f);
	r = amdgpu_job_submit_direct(job, ring, &f);
	amdgpu_ib_free(ring->adev, &ib_msg, f);
	if (r)
	if (r)
		goto err;
		goto err;


@@ -1134,20 +1142,13 @@ int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring)
int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout)
int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout)
{
{
	struct dma_fence *fence = NULL;
	struct dma_fence *fence = NULL;
	struct amdgpu_bo *bo = NULL;
	long r;
	long r;


	/* skip vce ring1/2 ib test for now, since it's not reliable */
	/* skip vce ring1/2 ib test for now, since it's not reliable */
	if (ring != &ring->adev->vce.ring[0])
	if (ring != &ring->adev->vce.ring[0])
		return 0;
		return 0;


	r = amdgpu_bo_create_reserved(ring->adev, 512, PAGE_SIZE,
	r = amdgpu_vce_get_create_msg(ring, 1, NULL);
				      AMDGPU_GEM_DOMAIN_VRAM,
				      &bo, NULL, NULL);
	if (r)
		return r;

	r = amdgpu_vce_get_create_msg(ring, 1, bo, NULL);
	if (r)
	if (r)
		goto error;
		goto error;


@@ -1163,8 +1164,6 @@ int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout)


error:
error:
	dma_fence_put(fence);
	dma_fence_put(fence);
	amdgpu_bo_unreserve(bo);
	amdgpu_bo_free_kernel(&bo, NULL, NULL);
	return r;
	return r;
}
}