RE: [PATCH 2/2] drm/amdgpu/vcn: send session ctx along with msg buffer

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

 



[AMD Official Use Only - AMD Internal Distribution Only]

This series is

Reviewed-by: Ruijing Dong <ruijing.dong@xxxxxxx>

-----Original Message-----
From: amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> On Behalf Of boyuan.zhang@xxxxxxx
Sent: Friday, February 21, 2025 9:06 PM
To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx
Cc: Zhang, Boyuan <Boyuan.Zhang@xxxxxxx>; Yao, Yinjie <Yinjie.Yao@xxxxxxx>
Subject: [PATCH 2/2] drm/amdgpu/vcn: send session ctx along with msg buffer

From: Boyuan Zhang <boyuan.zhang@xxxxxxx>

Session context buffer is required to be sent along with message buffer

Signed-off-by: Boyuan Zhang <boyuan.zhang@xxxxxxx>
Tested-by: Yinjie Yao <yinjie.yao@xxxxxxx>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 43 ++++++++++++++++++-------
 1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 83faf6e6788a..8d2cce3ea7af 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -602,18 +602,29 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,  }

 static int amdgpu_vcn_dec_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
-               struct amdgpu_ib *ib)
+               struct amdgpu_ib *ib, struct amdgpu_ib *ctx)
 {
        struct amdgpu_device *adev = ring->adev;
        uint32_t *msg;
        int r, i;

-       memset(ib, 0, sizeof(*ib));
-       r = amdgpu_ib_get(adev, NULL, AMDGPU_GPU_PAGE_SIZE * 2,
-                       AMDGPU_IB_POOL_DIRECT,
-                       ib);
-       if (r)
-               return r;
+       if (ctx) {
+               memset(ctx, 0, sizeof(*ctx));
+               r = amdgpu_ib_get(adev, NULL, AMDGPU_GPU_PAGE_SIZE * 32,
+                               AMDGPU_IB_POOL_DIRECT,
+                               ctx);
+               if (r)
+                       return r;
+       }
+
+       if (ib) {
+               memset(ib, 0, sizeof(*ib));
+               r = amdgpu_ib_get(adev, NULL, AMDGPU_GPU_PAGE_SIZE * 2,
+                               AMDGPU_IB_POOL_DIRECT,
+                               ib);
+               if (r)
+                       return r;
+       }

        msg = (uint32_t *)AMDGPU_GPU_PAGE_ALIGN((unsigned long)ib->ptr);
        msg[0] = cpu_to_le32(0x00000028);
@@ -669,7 +680,7 @@ int amdgpu_vcn_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout)
        struct amdgpu_ib ib;
        long r;

-       r = amdgpu_vcn_dec_get_create_msg(ring, 1, &ib);
+       r = amdgpu_vcn_dec_get_create_msg(ring, 1, &ib, NULL);
        if (r)
                goto error;

@@ -727,6 +738,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 amdgpu_ib *ib_ctx,
                                      struct dma_fence **fence)
 {
        struct amdgpu_vcn_decode_buffer *decode_buffer = NULL; @@ -735,6 +747,7 @@ static int amdgpu_vcn_dec_sw_send_msg(struct amdgpu_ring *ring,
        struct dma_fence *f = NULL;
        struct amdgpu_job *job;
        struct amdgpu_ib *ib;
+       uint64_t addr_ctx = AMDGPU_GPU_PAGE_ALIGN(ib_ctx->gpu_addr);
        uint64_t addr = AMDGPU_GPU_PAGE_ALIGN(ib_msg->gpu_addr);
        uint32_t *ib_checksum;
        uint32_t ib_pack_in_dw;
@@ -765,6 +778,10 @@ 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));

+       decode_buffer->valid_buf_flag |= cpu_to_le32(AMDGPU_VCN_CMD_FLAG_SESSION_CONTEXT_BUFFER);
+       decode_buffer->session_ctx_buffer_address_hi = cpu_to_le32(addr_ctx >> 32);
+       decode_buffer->session_ctx_buffer_address_lo = cpu_to_le32(addr_ctx);
+
        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); @@ -780,6 +797,7 @@ static int amdgpu_vcn_dec_sw_send_msg(struct amdgpu_ring *ring,
                goto err_free;

        amdgpu_ib_free(ib_msg, f);
+       amdgpu_ib_free(ib_ctx, f);

        if (fence)
                *fence = dma_fence_get(f);
@@ -791,27 +809,28 @@ static int amdgpu_vcn_dec_sw_send_msg(struct amdgpu_ring *ring,
        amdgpu_job_free(job);
 err:
        amdgpu_ib_free(ib_msg, f);
+       amdgpu_ib_free(ib_ctx, f);
        return r;
 }

 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_ib ib, ctx;
        long r;

-       r = amdgpu_vcn_dec_get_create_msg(ring, 1, &ib);
+       r = amdgpu_vcn_dec_get_create_msg(ring, 1, &ib, &ctx);
        if (r)
                goto error;

-       r = amdgpu_vcn_dec_sw_send_msg(ring, &ib, NULL);
+       r = amdgpu_vcn_dec_sw_send_msg(ring, &ib, &ctx, NULL);
        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, &ctx, &fence);
        if (r)
                goto error;

--
2.34.1





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

  Powered by Linux