<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Sorry if I read this completely wrong, but the other patch says "radv currently has<br>a limit of 192 which seems to work for most gfx submissions, but<br>is way too high for e.g. compute or sdma.", while you return 192 for AMDGPU_RING_TYPE_COMPUTE</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">here still?</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Regards</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">//Ernst<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Den ons 12 apr. 2023 kl 14:20 skrev Bas Nieuwenhuizen <<a href="mailto:bas@basnieuwenhuizen.nl">bas@basnieuwenhuizen.nl</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">And ensure each ring supports that many submissions. This makes<br>
sure that we don't get surprises after the submission has been<br>
scheduled where the ring allocation actually gets rejected.<br>
<br>
Link: <a href="https://gitlab.freedesktop.org/drm/amd/-/issues/2498" rel="noreferrer" target="_blank">https://gitlab.freedesktop.org/drm/amd/-/issues/2498</a><br>
Signed-off-by: Bas Nieuwenhuizen <<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank">bas@basnieuwenhuizen.nl</a>><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 +++<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 25 ++++++++++++++++++++++++<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 +<br>
3 files changed, 29 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
index 7af3041ccd0e..8362738974c8 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
@@ -110,6 +110,9 @@ static int amdgpu_cs_p1_ib(struct amdgpu_cs_parser *p,<br>
if (r < 0)<br>
return r;<br>
<br>
+ if (num_ibs[r] >= amdgpu_ring_max_ibs(chunk_ib->ip_type))<br>
+ return -EINVAL;<br>
+<br>
++(num_ibs[r]);<br>
p->gang_leader_idx = r;<br>
return 0;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
index dc474b809604..abd70d2f26f6 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
@@ -49,6 +49,25 @@<br>
* them until the pointers are equal again.<br>
*/<br>
<br>
+/**<br>
+ * amdgpu_ring_max_ibs - Return max IBs that fit in a single submission.<br>
+ *<br>
+ * @type: ring type for which to return the limit.<br>
+ */<br>
+unsigned int amdgpu_ring_max_ibs(enum amdgpu_ring_type type)<br>
+{<br>
+ switch (type) {<br>
+ case AMDGPU_RING_TYPE_GFX:<br>
+ case AMDGPU_RING_TYPE_COMPUTE:<br>
+ /* gfx/compute are often used more extensively and radv<br>
+ * has historically assumed the limit was 192.<br>
+ */<br>
+ return 192;<br>
+ default:<br>
+ return 50;<br>
+ }<br>
+}<br>
+<br>
/**<br>
* amdgpu_ring_alloc - allocate space on the ring buffer<br>
*<br>
@@ -182,6 +201,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,<br>
int sched_hw_submission = amdgpu_sched_hw_submission;<br>
u32 *num_sched;<br>
u32 hw_ip;<br>
+ unsigned int max_ibs_dw;<br>
<br>
/* Set the hw submission limit higher for KIQ because<br>
* it's used for a number of gfx/compute tasks by both<br>
@@ -290,6 +310,11 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,<br>
return r;<br>
}<br>
<br>
+ max_ibs_dw = ring->funcs->emit_frame_size +<br>
+ amdgpu_ring_max_ibs(ring->funcs->type) * ring->funcs->emit_ib_size;<br>
+ max_ibs_dw = (max_ibs_dw + ring->funcs->align_mask) & ~ring->funcs->align_mask;<br>
+ max_dw = max(max_dw, max_ibs_dw);<br>
+<br>
ring->ring_size = roundup_pow_of_two(max_dw * 4 * sched_hw_submission);<br>
<br>
ring->buf_mask = (ring->ring_size / 4) - 1;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
index 3989e755a5b4..e6e672727529 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
@@ -317,6 +317,7 @@ struct amdgpu_ring {<br>
#define amdgpu_ring_patch_cond_exec(r,o) (r)->funcs->patch_cond_exec((r),(o))<br>
#define amdgpu_ring_preempt_ib(r) (r)->funcs->preempt_ib(r)<br>
<br>
+unsigned int amdgpu_ring_max_ibs(enum amdgpu_ring_type type);<br>
int amdgpu_ring_alloc(struct amdgpu_ring *ring, unsigned ndw);<br>
void amdgpu_ring_ib_begin(struct amdgpu_ring *ring);<br>
void amdgpu_ring_ib_end(struct amdgpu_ring *ring);<br>
-- <br>
2.40.0<br>
<br>
</blockquote></div>