[Mesa-dev] [PATCH 4/9] winsys/amdgpu: use alloca when using global_bo_list
Marek Olšák
maraeo at gmail.com
Thu Jul 12 05:26:35 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
index 1aaa0667310..ec164175dbc 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
@@ -1293,37 +1293,29 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
/* Create the buffer list.
* Use a buffer list containing all allocated buffers if requested.
*/
if (ws->debug_all_bos) {
struct amdgpu_winsys_bo *bo;
amdgpu_bo_handle *handles;
unsigned num = 0;
simple_mtx_lock(&ws->global_bo_list_lock);
-
- handles = malloc(sizeof(handles[0]) * ws->num_buffers);
- if (!handles) {
- simple_mtx_unlock(&ws->global_bo_list_lock);
- amdgpu_cs_context_cleanup(cs);
- cs->error_code = -ENOMEM;
- return;
- }
+ handles = alloca(sizeof(handles[0]) * ws->num_buffers);
LIST_FOR_EACH_ENTRY(bo, &ws->global_bo_list, u.real.global_list_item) {
assert(num < ws->num_buffers);
handles[num++] = bo->bo;
}
r = amdgpu_bo_list_create(ws->dev, ws->num_buffers,
handles, NULL, &bo_list);
- free(handles);
simple_mtx_unlock(&ws->global_bo_list_lock);
if (r) {
fprintf(stderr, "amdgpu: buffer list creation failed (%d)\n", r);
amdgpu_fence_signalled(cs->fence);
cs->error_code = r;
goto cleanup;
}
} else {
unsigned num_handles;
--
2.17.1
More information about the mesa-dev
mailing list