Skip to contentSkip to conversation

drm/amdgpu/mes: refine for maximum packet execution

PATCH Superseded Jack Xiao 3 participants 4 messages Jul 23, 2024 – Aug 7, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jack Xiao

author
#0 lore raw

PATCH 1/1 drm/amdgpu/mes: refine for maximum packet execution

Only allow API_NUMBER_OF_COMMAND_MAX packet in mes ring buffer, refine the code for maximum packet execution.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 ++
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c   | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2 -0
index ad49cecb20b8..dfe487521a4a 100644
@@ -212,6 +212,8 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
 	 */
 	if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ)
 		sched_hw_submission = max(sched_hw_submission, 256);
+	else if (ring->funcs->type == AMDGPU_RING_TYPE_MES)
+		sched_hw_submission = 32;
 	else if (ring == &adev->sdma.instance[0].page)
 		sched_hw_submission = 256;
 
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -1
index 68c74adf79f1..951f13e01ee9 100644
@@ -198,7 +198,7 @@ static int mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,
 
 	seq = ++ring->fence_drv.sync_seq;
 	r = amdgpu_fence_wait_polling(ring,
-				      seq - ring->fence_drv.num_fences_mask,
+				      seq - (API_NUMBER_OF_COMMAND_MAX/2 - 1),
 				      timeout);
 	if (r < 1)
 		goto error_undo;
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1 -1
index 48e01206bcc4..dc65f28d1795 100644
@@ -184,7 +184,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,
 
 	seq = ++ring->fence_drv.sync_seq;
 	r = amdgpu_fence_wait_polling(ring,
-				      seq - ring->fence_drv.num_fences_mask,
+				      seq - (API_NUMBER_OF_COMMAND_MAX/2 - 1),
 				      timeout);
 	if (r < 1)
 		goto error_undo;
Signature · 1 line
2.41.0
#1 lore raw

Am 23.07.24 um 10:27 schrieb Jack Xiao:

Quoted 15 lines

Only allow API_NUMBER_OF_COMMAND_MAX packet in mes ring buffer, refine the code for maximum packet execution.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 ++
  drivers/gpu/drm/amd/amdgpu/mes_v11_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/mes_v12_0.c   | 2 +-
  3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -0
index ad49cecb20b8..dfe487521a4a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, · line 216

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2 -0
@@ -212,6 +212,8 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
  	 */
  	if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ)
  		sched_hw_submission = max(sched_hw_submission, 256);
+	else if (ring->funcs->type == AMDGPU_RING_TYPE_MES)
+		sched_hw_submission = 32;

Yeah that looks like it makes sense.

drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static int mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, · line 201

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -0
  	else if (ring == &adev->sdma.instance[0].page)
  		sched_hw_submission = 256;
 
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -1
index 68c74adf79f1..951f13e01ee9 100644
@@ -198,7 +198,7 @@ static int mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,
 
  	seq = ++ring->fence_drv.sync_seq;
  	r = amdgpu_fence_wait_polling(ring,
-				      seq - ring->fence_drv.num_fences_mask,
+				      seq - (API_NUMBER_OF_COMMAND_MAX/2 - 1),

This looks a bit questionable. amdgpu_fence_wait_polling() doesn't apply the fence mask to the polled value.

So what happens if that overruns?

Additional to that we should really keep that logic in amdgpu_fence_emit_polling() and not each individual MES generation.

Regards,
Christian.

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +0 -0
  				      timeout);
  	if (r < 1)
  		goto error_undo;
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1 -1
index 48e01206bcc4..dc65f28d1795 100644
@@ -184,7 +184,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,
 
  	seq = ++ring->fence_drv.sync_seq;
  	r = amdgpu_fence_wait_polling(ring,
-				      seq - ring->fence_drv.num_fences_mask,
+				      seq - (API_NUMBER_OF_COMMAND_MAX/2 - 1),
  				      timeout);
  	if (r < 1)
  		goto error_undo;
#2 lore raw
In reply to Jack Xiao

[Public]

Quoted 8 lines

-----Original Message-----
From: Xiao, Jack <[email protected]>
Sent: Tuesday, July 23, 2024 4:28 AM
To: [email protected]; Deucher, Alexander <[email protected]>; [email protected]
Cc: Xiao, Jack <[email protected]>
Subject: [PATCH] drm/amdgpu/mes: refine for maximum packet execution

Quoted 4 lines

Only allow API_NUMBER_OF_COMMAND_MAX packet in mes ring buffer, refine the code for maximum packet execution.

Any updates on this patch?

Alex

Quoted 55 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 ++
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c   | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2 -0
index ad49cecb20b8..dfe487521a4a 100644
@@ -212,6 +212,8 @@ int amdgpu_ring_init(struct amdgpu_device *adev,
 struct amdgpu_ring *ring,
       */
      if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ)
              sched_hw_submission = max(sched_hw_submission, 256);
+     else if (ring->funcs->type == AMDGPU_RING_TYPE_MES)
+             sched_hw_submission = 32;
      else if (ring == &adev->sdma.instance[0].page)
              sched_hw_submission = 256;
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -1
index 68c74adf79f1..951f13e01ee9 100644
@@ -198,7 +198,7 @@ static int
 mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,
 
      seq = ++ring->fence_drv.sync_seq;
      r = amdgpu_fence_wait_polling(ring,
-                                   seq - ring->fence_drv.num_fences_mask,
+                                   seq -
 (API_NUMBER_OF_COMMAND_MAX/2 - 1),
                                    timeout);
      if (r < 1)
              goto error_undo;
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1 -1
index 48e01206bcc4..dc65f28d1795 100644
@@ -184,7 +184,7 @@ static int
 mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,
 
      seq = ++ring->fence_drv.sync_seq;
      r = amdgpu_fence_wait_polling(ring,
-                                   seq - ring->fence_drv.num_fences_mask,
+                                   seq -
 (API_NUMBER_OF_COMMAND_MAX/2 - 1),
                                    timeout);
      if (r < 1)
              goto error_undo;

--
2.41.0

author
#3 lore raw

[Public]

The maximum sched_hw_submission value will be set to 8. The value will result that the maximum number of packet execution which is not greater than firmware allowed.

Regards,
Jack

-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Tuesday, August 6, 2024 10:34 PM
To: Xiao, Jack <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH] drm/amdgpu/mes: refine for maximum packet execution

[Public]

Quoted 8 lines

-----Original Message-----
From: Xiao, Jack <[email protected]>
Sent: Tuesday, July 23, 2024 4:28 AM
To: [email protected]; Deucher, Alexander <[email protected]>; [email protected]
Cc: Xiao, Jack <[email protected]>
Subject: [PATCH] drm/amdgpu/mes: refine for maximum packet execution

Quoted 4 lines

Only allow API_NUMBER_OF_COMMAND_MAX packet in mes ring buffer, refine the code for maximum packet execution.

Any updates on this patch?

Alex

Quoted 55 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 ++
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c   | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2 -0
index ad49cecb20b8..dfe487521a4a 100644
@@ -212,6 +212,8 @@ int amdgpu_ring_init(struct amdgpu_device *adev,
 struct amdgpu_ring *ring,
       */
      if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ)
              sched_hw_submission = max(sched_hw_submission, 256);
+     else if (ring->funcs->type == AMDGPU_RING_TYPE_MES)
+             sched_hw_submission = 32;
      else if (ring == &adev->sdma.instance[0].page)
              sched_hw_submission = 256;
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -1
index 68c74adf79f1..951f13e01ee9 100644
@@ -198,7 +198,7 @@ static int
 mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,
 
      seq = ++ring->fence_drv.sync_seq;
      r = amdgpu_fence_wait_polling(ring,
-                                   seq - ring->fence_drv.num_fences_mask,
+                                   seq -
 (API_NUMBER_OF_COMMAND_MAX/2 - 1),
                                    timeout);
      if (r < 1)
              goto error_undo;
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1 -1
index 48e01206bcc4..dc65f28d1795 100644
@@ -184,7 +184,7 @@ static int
 mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,
 
      seq = ++ring->fence_drv.sync_seq;
      r = amdgpu_fence_wait_polling(ring,
-                                   seq - ring->fence_drv.num_fences_mask,
+                                   seq -
 (API_NUMBER_OF_COMMAND_MAX/2 - 1),
                                    timeout);
      if (r < 1)
              goto error_undo;

--
2.41.0