mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 09:20:09 +01:00
amdgpu: use alloca for dependencies and sem_dependencies
Use alloca instead of malloc, then we don't need free them at the end of this function. Signed-off-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
d8731e9eec
commit
fca0849af3
1 changed files with 2 additions and 4 deletions
|
|
@ -295,7 +295,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ibs_request->number_of_dependencies) {
|
if (ibs_request->number_of_dependencies) {
|
||||||
dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) *
|
dependencies = alloca(sizeof(struct drm_amdgpu_cs_chunk_dep) *
|
||||||
ibs_request->number_of_dependencies);
|
ibs_request->number_of_dependencies);
|
||||||
if (!dependencies) {
|
if (!dependencies) {
|
||||||
r = -ENOMEM;
|
r = -ENOMEM;
|
||||||
|
|
@ -326,7 +326,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
|
||||||
LIST_FOR_EACH_ENTRY(sem, sem_list, list)
|
LIST_FOR_EACH_ENTRY(sem, sem_list, list)
|
||||||
sem_count++;
|
sem_count++;
|
||||||
if (sem_count) {
|
if (sem_count) {
|
||||||
sem_dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) * sem_count);
|
sem_dependencies = alloca(sizeof(struct drm_amdgpu_cs_chunk_dep) * sem_count);
|
||||||
if (!sem_dependencies) {
|
if (!sem_dependencies) {
|
||||||
r = -ENOMEM;
|
r = -ENOMEM;
|
||||||
goto error_unlock;
|
goto error_unlock;
|
||||||
|
|
@ -363,8 +363,6 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
|
||||||
context->last_seq[ibs_request->ip_type][ibs_request->ip_instance][ibs_request->ring] = ibs_request->seq_no;
|
context->last_seq[ibs_request->ip_type][ibs_request->ip_instance][ibs_request->ring] = ibs_request->seq_no;
|
||||||
error_unlock:
|
error_unlock:
|
||||||
pthread_mutex_unlock(&context->sequence_mutex);
|
pthread_mutex_unlock(&context->sequence_mutex);
|
||||||
free(dependencies);
|
|
||||||
free(sem_dependencies);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue