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

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

 



Am 26.06.23 um 16:50 schrieb Saleemkhan Jamadar:
add session context buffer to decoder ring test.

v2 - put the buffer at the end of the IB (Christian)

Signed-off-by: Saleemkhan Jamadar <saleemkhan.jamadar@xxxxxxx>
Acked-by: Leo Liu <leo.liu@xxxxxxx>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 30 ++++++++++++++++++++++---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h |  3 +++
  2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 2d94f1b63bd6..04daaaf6ab34 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -691,7 +691,8 @@ 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)
+				      struct dma_fence **fence,
+					  uint64_t session_ctx_buf_gaddr)

That looks like it isn't correctly indented.

  {
  	struct amdgpu_vcn_decode_buffer *decode_buffer = NULL;
  	unsigned int ib_size_dw = 64;
@@ -730,6 +731,14 @@ static int amdgpu_vcn_dec_sw_send_msg(struct amdgpu_ring *ring,
  	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);
+	}
  	decode_buffer->valid_buf_flag |= cpu_to_le32(AMDGPU_VCN_CMD_FLAG_MSG_BUFFER);
  	decode_buffer->msg_buffer_address_hi = cpu_to_le32(addr >> 32);
  	decode_buffer->msg_buffer_address_lo = cpu_to_le32(addr);
@@ -763,20 +772,34 @@ int amdgpu_vcn_dec_sw_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);

That still creates a buffer for the session ctx instead of putting it into the IB.

+	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_sw_send_msg(ring, &ib, NULL);
+	r = amdgpu_vcn_dec_sw_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_sw_send_msg(ring, &ib, &fence);
+	r = amdgpu_vcn_dec_sw_send_msg(ring, &ib, &fence, gpu_addr);
  	if (r)
  		goto error;
@@ -788,6 +811,7 @@ int amdgpu_vcn_dec_sw_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);ebd59851c796c

Which is freed here.

  	return r;
  }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
index f1397ef66fd7..06f9ee91a1e1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
@@ -166,6 +166,7 @@
#define AMDGPU_VCN_IB_FLAG_DECODE_BUFFER 0x00000001
  #define AMDGPU_VCN_CMD_FLAG_MSG_BUFFER		0x00000001
+#define AMDGPU_VCN_CMD_FLAG_SESSION_CONTEXT_BUFFER	0x00100000
#define VCN_CODEC_DISABLE_MASK_AV1 (1 << 0)
  #define VCN_CODEC_DISABLE_MASK_VP9  (1 << 1)
@@ -357,6 +358,8 @@ struct amdgpu_vcn_decode_buffer {
  	uint32_t valid_buf_flag;
  	uint32_t msg_buffer_address_hi;
  	uint32_t msg_buffer_address_lo;
+	unsigned int session_context_buffer_address_hi;
+	unsigned int session_context_buffer_address_lo;
  	uint32_t pad[30];

that here looks incorrect as well.

Christian.

  };




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

  Powered by Linux