Skip to contentSkip to conversation

drm/amdgpu: update kernel vcn ring test

PATCH In review Saleemkhan Jamadar 2 participants 3 messages Jul 10, 2023 – Jul 11, 2023

Subsystems (2)

v3 of 5 In review Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 drm/amdgpu: update kernel vcn ring test

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

v3 - correct the cmd for sesssion ctx buf
v2 - add the buffer into IB (Leo liu)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +14 -0
index 76e9a2418286..4ee5f933e420 100644
@@ -521,6 +521,7 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
 				   struct dma_fence **fence)
 {
 	u64 addr = AMDGPU_GPU_PAGE_ALIGN(ib_msg->gpu_addr);
+	uint64_t session_ctx_buf_gaddr = AMDGPU_GPU_PAGE_ALIGN(ib_msg->gpu_addr + 8192);
 	struct amdgpu_device *adev = ring->adev;
 	struct dma_fence *f = NULL;
 	struct amdgpu_job *job;
@@ -546,6 +547,19 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
 	}
 	ib->length_dw = 16;
 
+	ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.data0, 0);
+	ib->ptr[ib->length_dw++] = lower_32_bits(session_ctx_buf_gaddr);
+	ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.data1, 0);
+	ib->ptr[ib->length_dw++] = upper_32_bits(session_ctx_buf_gaddr);
+	/* session ctx buffer cmd */
+	ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.cmd, 0xa);
+	ib->ptr[ib->length_dw++] = 0;
+	for (i = ib->length_dw; i < 32; i += 2) {
+		ib->ptr[i] = PACKET0(adev->vcn.internal.nop, 0);
+		ib->ptr[i+1] = 0;
+	}
+	ib->length_dw = 32;
+
 	r = amdgpu_job_submit_direct(job, ring, &f);
 	if (r)
 		goto err_free;
Signature · 1 line
2.25.1
Reviewed-by on v3 2/2
#1 lore raw

[AMD Official Use Only - General]

-----Original Message-----
From: Jamadar, Saleemkhan <[email protected]>
Sent: Monday, July 10, 2023 12:54 PM
To: Jamadar, Saleemkhan <[email protected]>; [email protected]; Liu, Leo <[email protected]>; Gopalakrishnan, Veerabadhran (Veera) <[email protected]>; Sundararaju, Sathishkumar <[email protected]>
Cc: Koenig, Christian <[email protected]>; Rao, Srinath <[email protected]>
Subject: [PATCH v3 2/2] drm/amdgpu: update kernel vcn ring test

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

v3 - correct the cmd for sesssion ctx buf
v2 - add the buffer into IB (Leo liu)

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +1 -0
index 76e9a2418286..4ee5f933e420 100644
@@ -521,6 +521,7 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
                                   struct dma_fence **fence)
 {
        u64 addr = AMDGPU_GPU_PAGE_ALIGN(ib_msg->gpu_addr);
+       uint64_t session_ctx_buf_gaddr = AMDGPU_GPU_PAGE_ALIGN(ib_msg->gpu_addr + 8192);
        struct amdgpu_device *adev = ring->adev;
        struct dma_fence *f = NULL;
        struct amdgpu_job *job;
@@ -546,6 +547,19 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
        }
        ib->length_dw = 16;
 

This line above can be removed. With that the patch is:

+       ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.data0, 0);
+       ib->ptr[ib->length_dw++] = lower_32_bits(session_ctx_buf_gaddr);
+       ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.data1, 0);
+       ib->ptr[ib->length_dw++] = upper_32_bits(session_ctx_buf_gaddr);
+       /* session ctx buffer cmd */
+       ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.cmd, 0xa);
+       ib->ptr[ib->length_dw++] = 0;
+       for (i = ib->length_dw; i < 32; i += 2) {

+ ib->ptr[i] = PACKET0(adev->vcn.internal.nop, 0);
+ ib->ptr[i+1] = 0;
+ }
+ ib->length_dw = 32;
+

        r = amdgpu_job_submit_direct(job, ring, &f);
        if (r)
                goto err_free;

--
2.25.1

#2 lore raw
Quoted 38 lines · Leo

[AMD Official Use Only - General]

[AMD Official Use Only - General]

-----Original Message-----
From: Jamadar, Saleemkhan <[email protected]>
Sent: Monday, July 10, 2023 12:54 PM
To: Jamadar, Saleemkhan <[email protected]>; [email protected]; Liu, Leo <[email protected]>; Gopalakrishnan, Veerabadhran (Veera) <[email protected]>; Sundararaju, Sathishkumar <[email protected]>
Cc: Koenig, Christian <[email protected]>; Rao, Srinath <[email protected]>
Subject: [PATCH v3 2/2] drm/amdgpu: update kernel vcn ring test

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

v3 - correct the cmd for sesssion ctx buf
v2 - add the buffer into IB (Leo liu)

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +1 -0
index 76e9a2418286..4ee5f933e420 100644
@@ -521,6 +521,7 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
                                    struct dma_fence **fence)
  {
         u64 addr = AMDGPU_GPU_PAGE_ALIGN(ib_msg->gpu_addr);
+       uint64_t session_ctx_buf_gaddr = AMDGPU_GPU_PAGE_ALIGN(ib_msg->gpu_addr + 8192);
         struct amdgpu_device *adev = ring->adev;
         struct dma_fence *f = NULL;
         struct amdgpu_job *job;
@@ -546,6 +547,19 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
         }
         ib->length_dw = 16;
 

This line above can be removed. With that the patch is:

Quoted 1 line

I think we should rework the lines above of this line for msg buffer, put the session ctx buffer right behind it, and no need fill the nop command in between, so make the code cleaner.

Regards,

Leo

Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +13 -1
+       ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.data0, 0);
+       ib->ptr[ib->length_dw++] = lower_32_bits(session_ctx_buf_gaddr);
+       ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.data1, 0);
+       ib->ptr[ib->length_dw++] = upper_32_bits(session_ctx_buf_gaddr);
+       /* session ctx buffer cmd */
+       ib->ptr[ib->length_dw++] = PACKET0(adev->vcn.internal.cmd, 0xa);
+       ib->ptr[ib->length_dw++] = 0;
+       for (i = ib->length_dw; i < 32; i += 2) {
+               ib->ptr[i] = PACKET0(adev->vcn.internal.nop, 0);
+               ib->ptr[i+1] = 0;
+       }
+       ib->length_dw = 32;
+
         r = amdgpu_job_submit_direct(job, ring, &f);
         if (r)
                 goto err_free;
--

2.25.1