aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák2015-06-02 07:43:52 -0500
committerAlex Deucher2015-08-05 12:47:51 -0500
commit34e1250e3769f33b92a12f535f4fca755388ee10 (patch)
treec3a9e4a99c5d356f5e062ed4e7a176286deba0a9 /amdgpu/amdgpu_cs.c
parent908f34e70cc9a7cd46edee1737c652e0a59893aa (diff)
downloadexternal-libgbm-34e1250e3769f33b92a12f535f4fca755388ee10.tar.gz
external-libgbm-34e1250e3769f33b92a12f535f4fca755388ee10.tar.xz
external-libgbm-34e1250e3769f33b92a12f535f4fca755388ee10.zip
amdgpu: use alloca and malloc in critical codepaths (v2)
And don't clear the memory when it's unnecessary. v2: use malloc for arrays that can be big Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'amdgpu/amdgpu_cs.c')
-rw-r--r--amdgpu/amdgpu_cs.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index 0fa05ece..bf79df35 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -201,8 +201,8 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
201 sizeof(struct drm_amdgpu_cs_chunk) + 201 sizeof(struct drm_amdgpu_cs_chunk) +
202 sizeof(struct drm_amdgpu_cs_chunk_data)); 202 sizeof(struct drm_amdgpu_cs_chunk_data));
203 203
204 chunk_array = calloc(1, size); 204 chunk_array = alloca(size);
205 if (NULL == chunk_array) 205 if (!chunk_array)
206 return -ENOMEM; 206 return -ENOMEM;
207 207
208 chunks = (struct drm_amdgpu_cs_chunk *)(chunk_array + ibs_request->number_of_ibs + 1); 208 chunks = (struct drm_amdgpu_cs_chunk *)(chunk_array + ibs_request->number_of_ibs + 1);
@@ -262,7 +262,6 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
262 262
263error_unlock: 263error_unlock:
264 pthread_mutex_unlock(&context->sequence_mutex); 264 pthread_mutex_unlock(&context->sequence_mutex);
265 free(chunk_array);
266 return r; 265 return r;
267} 266}
268 267