winsys/amdgpu: retry the CS ioctl on -ENOMEM only if GDS OA is used

It's not needed otherwise.

The loop was also duplicated. This removes the second one.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38798>
This commit is contained in:
Marek Olšák 2025-12-03 16:50:45 -05:00 committed by Marge Bot
parent f56e70f230
commit 0724428d55
3 changed files with 13 additions and 22 deletions

View file

@ -309,6 +309,8 @@ void amdgpu_bo_destroy(struct amdgpu_winsys *aws, struct pb_buffer_lean *_buf)
aws->allocated_vram -= align64(bo->b.base.size, aws->info.gart_page_size);
else if (bo->b.base.placement & RADEON_DOMAIN_GTT)
aws->allocated_gtt -= align64(bo->b.base.size, aws->info.gart_page_size);
else if (bo->b.base.placement & RADEON_DOMAIN_OA)
aws->allocated_oa -= bo->b.base.size;
simple_mtx_destroy(&bo->map_lock);
FREE(bo);
@ -716,6 +718,8 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct amdgpu_winsys *aws,
aws->allocated_vram += align64(size, aws->info.gart_page_size);
else if (initial_domain & RADEON_DOMAIN_GTT)
aws->allocated_gtt += align64(size, aws->info.gart_page_size);
else if (initial_domain & RADEON_DOMAIN_OA)
aws->allocated_oa += size;
amdgpu_add_buffer_to_global_list(aws, bo);

View file

@ -1392,12 +1392,7 @@ static int amdgpu_cs_submit_ib_kernelq(struct amdgpu_cs *acs,
assert(num_chunks <= 8);
/* Submit the command buffer.
*
* The kernel returns -ENOMEM with many parallel processes using GDS such as test suites
* quite often, but it eventually succeeds after enough attempts. This happens frequently
* with dEQP using NGG streamout.
*/
/* Submit the command buffer. */
int r = 0;
do {
@ -1406,7 +1401,12 @@ static int amdgpu_cs_submit_ib_kernelq(struct amdgpu_cs *acs,
os_time_sleep(1000);
r = ac_drm_cs_submit_raw2(aws->dev, acs->ctx->ctx_handle, 0, num_chunks, chunks, seq_no);
} while (r == -ENOMEM);
/* The kernel returns -ENOMEM with many parallel processes using GDS such as test suites
* quite often, but it eventually succeeds after enough attempts. This happens frequently
* with dEQP using NGG streamout.
*/
} while (r == -ENOMEM && aws->allocated_oa);
return r;
}
@ -2048,21 +2048,7 @@ static void amdgpu_cs_submit_ib(void *job, void *gdata, int thread_index)
r = 0;
} else {
if (queue_type != USERQ) {
/* Submit the command buffer.
*
* The kernel returns -ENOMEM with many parallel processes using GDS such as test suites
* quite often, but it eventually succeeds after enough attempts. This happens frequently
* with dEQP using NGG streamout.
*/
r = 0;
do {
/* Wait 1 ms and try again. */
if (r == -ENOMEM)
os_time_sleep(1000);
r = amdgpu_cs_submit_ib_kernelq(acs, num_submit_real_buffers, bo_list, &seq_no);
} while (r == -ENOMEM);
r = amdgpu_cs_submit_ib_kernelq(acs, num_submit_real_buffers, bo_list, &seq_no);
if (!r) {
/* Success. */

View file

@ -219,6 +219,7 @@ struct amdgpu_winsys {
uint32_t next_bo_unique_id;
uint64_t allocated_vram;
uint64_t allocated_gtt;
uint32_t allocated_oa;
uint64_t mapped_vram;
uint64_t mapped_gtt;
uint64_t slab_wasted_vram;