[PATCH 2/2] drm/amdgpu:update kernel vcn ring test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



add session context buffer to decoder ring test fro vcn v1 to v3.

Signed-off-by: Saleemkhan Jamadar <saleemkhan.jamadar@xxxxxxx>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 43 ++++++++++++++++++++++---
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 04daaaf6ab34..3e9c023e6c42 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -518,9 +518,11 @@ int amdgpu_vcn_dec_sw_ring_test_ring(struct amdgpu_ring *ring)
 
 static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
 				   struct amdgpu_ib *ib_msg,
-				   struct dma_fence **fence)
+				   struct dma_fence **fence,
+				   uint64_t session_ctx_buf_gaddr)
 {
 	u64 addr = AMDGPU_GPU_PAGE_ALIGN(ib_msg->gpu_addr);
+        struct amdgpu_vcn_decode_buffer *decode_buffer = NULL;
 	struct amdgpu_device *adev = ring->adev;
 	struct dma_fence *f = NULL;
 	struct amdgpu_job *job;
@@ -534,6 +536,22 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
 		goto err;
 
 	ib = &job->ibs[0];
+	ib->length_dw = 0;
+        ib->ptr[ib->length_dw++] = sizeof(struct amdgpu_vcn_decode_buffer) + 8;
+        ib->ptr[ib->length_dw++] = cpu_to_le32(AMDGPU_VCN_IB_FLAG_DECODE_BUFFER);
+        decode_buffer = (struct amdgpu_vcn_decode_buffer *)&(ib->ptr[ib->length_dw]);
+        ib->length_dw += sizeof(struct amdgpu_vcn_decode_buffer) / 4;
+        memset(decode_buffer, 0, sizeof(struct amdgpu_vcn_decode_buffer));
+
+        if (session_ctx_buf_gaddr) {
+                decode_buffer->valid_buf_flag |=
+                                        cpu_to_le32(AMDGPU_VCN_CMD_FLAG_SESSION_CONTEXT_BUFFER);
+                decode_buffer->session_context_buffer_address_hi =
+                                                        cpu_to_le32(session_ctx_buf_gaddr >> 32);
+                decode_buffer->session_context_buffer_address_lo =
+                                                        cpu_to_le32(session_ctx_buf_gaddr);
+        }
+
 	ib->ptr[0] = PACKET0(adev->vcn.internal.data0, 0);
 	ib->ptr[1] = addr;
 	ib->ptr[2] = PACKET0(adev->vcn.internal.data1, 0);
@@ -544,7 +562,7 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
 		ib->ptr[i] = PACKET0(adev->vcn.internal.nop, 0);
 		ib->ptr[i+1] = 0;
 	}
-	ib->length_dw = 16;
+	ib->length_dw += 16;
 
 	r = amdgpu_job_submit_direct(job, ring, &f);
 	if (r)
@@ -631,20 +649,34 @@ int amdgpu_vcn_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout)
 {
 	struct dma_fence *fence = NULL;
 	struct amdgpu_ib ib;
+	struct amdgpu_bo *session_ctx_buf = NULL;
+        void *cpu_addr = NULL;
+        uint64_t gpu_addr = 0;
 	long r;
 
+	r = amdgpu_bo_create_kernel(ring->adev, 128*1024, PAGE_SIZE,
+				    AMDGPU_GEM_DOMAIN_VRAM |
+				    AMDGPU_GEM_DOMAIN_GTT,
+				    &session_ctx_buf,
+				    &gpu_addr,
+				    &cpu_addr);
+	if (r) {
+		dev_err(ring->adev->dev, "VCN ib test:%ld failed to allocate session ctx bo\n", r);
+		return r;
+	}
+
 	r = amdgpu_vcn_dec_get_create_msg(ring, 1, &ib);
 	if (r)
 		goto error;
 
-	r = amdgpu_vcn_dec_send_msg(ring, &ib, NULL);
+	r = amdgpu_vcn_dec_send_msg(ring, &ib, NULL, gpu_addr);
 	if (r)
 		goto error;
 	r = amdgpu_vcn_dec_get_destroy_msg(ring, 1, &ib);
 	if (r)
 		goto error;
 
-	r = amdgpu_vcn_dec_send_msg(ring, &ib, &fence);
+	r = amdgpu_vcn_dec_send_msg(ring, &ib, &fence, gpu_addr);
 	if (r)
 		goto error;
 
@@ -656,6 +688,7 @@ int amdgpu_vcn_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout)
 
 	dma_fence_put(fence);
 error:
+	amdgpu_bo_free_kernel(&session_ctx_buf, &gpu_addr, &cpu_addr);
 	return r;
 }
 
@@ -692,7 +725,7 @@ static void amdgpu_vcn_unified_ring_ib_checksum(uint32_t **ib_checksum,
 static int amdgpu_vcn_dec_sw_send_msg(struct amdgpu_ring *ring,
 				      struct amdgpu_ib *ib_msg,
 				      struct dma_fence **fence,
-					  uint64_t session_ctx_buf_gaddr)
+				      uint64_t session_ctx_buf_gaddr)
 {
 	struct amdgpu_vcn_decode_buffer *decode_buffer = NULL;
 	unsigned int ib_size_dw = 64;
-- 
2.25.1




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux