[Mesa-dev] [PATCH 09/26] winsys/amdpgu: retry after ENOMEM to work around a GDS memory management bug
Marek Olšák
maraeo at gmail.com
Wed Feb 13 05:16:04 UTC 2019
From: Marek Olšák <marek.olsak at amd.com>
If GDS/GWS/OA resources are being used by IBs that are currently busy,
the kernel driver returns -ENOMEM instead of waiting until those resources
are idle.
---
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
index 1438b1ffe76..edb90c1a734 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
@@ -1596,8 +1596,13 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
chunks[num_chunks].chunk_data = (uintptr_t)&cs->ib[IB_PARALLEL_COMPUTE];
num_chunks++;
- r = amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
- num_chunks, chunks, NULL);
+ /* The memory manager can return -ENOMEM for GDS when all GDS resources
+ * are busy. The workaround is to wait until they are idle.
+ */
+ while ((r = amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
+ num_chunks, chunks, NULL)) == -ENOMEM)
+ usleep(2000);
+
if (r)
goto finalize;
@@ -1643,8 +1648,12 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
assert(num_chunks <= ARRAY_SIZE(chunks));
- r = amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
- num_chunks, chunks, &seq_no);
+ /* The memory manager can return -ENOMEM for GDS when all GDS resources
+ * are busy. The workaround is to wait until they are idle.
+ */
+ while ((r = amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
+ num_chunks, chunks, &seq_no)) == -ENOMEM)
+ usleep(2000);
}
finalize:
--
2.17.1
More information about the mesa-dev
mailing list