Commit e4a58a28 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: fix leaking the IBs on error

Fixing a memory leak when the scheduler is enabled.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarJunwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent f5617f9d
...@@ -499,16 +499,12 @@ static void amdgpu_cs_parser_fini_late(struct amdgpu_cs_parser *parser) ...@@ -499,16 +499,12 @@ static void amdgpu_cs_parser_fini_late(struct amdgpu_cs_parser *parser)
for (i = 0; i < parser->nchunks; i++) for (i = 0; i < parser->nchunks; i++)
drm_free_large(parser->chunks[i].kdata); drm_free_large(parser->chunks[i].kdata);
kfree(parser->chunks); kfree(parser->chunks);
if (!amdgpu_enable_scheduler) if (parser->ibs)
{ for (i = 0; i < parser->num_ibs; i++)
if (parser->ibs) amdgpu_ib_free(parser->adev, &parser->ibs[i]);
for (i = 0; i < parser->num_ibs; i++) kfree(parser->ibs);
amdgpu_ib_free(parser->adev, &parser->ibs[i]); if (parser->uf.bo)
kfree(parser->ibs); drm_gem_object_unreference_unlocked(&parser->uf.bo->gem_base);
if (parser->uf.bo)
drm_gem_object_unreference_unlocked(&parser->uf.bo->gem_base);
}
kfree(parser); kfree(parser);
} }
...@@ -888,11 +884,14 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -888,11 +884,14 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
job->base.owner = parser->filp; job->base.owner = parser->filp;
mutex_init(&job->job_lock); mutex_init(&job->job_lock);
if (job->ibs[job->num_ibs - 1].user) { if (job->ibs[job->num_ibs - 1].user) {
memcpy(&job->uf, &parser->uf, job->uf = parser->uf;
sizeof(struct amdgpu_user_fence));
job->ibs[job->num_ibs - 1].user = &job->uf; job->ibs[job->num_ibs - 1].user = &job->uf;
parser->uf.bo = NULL;
} }
parser->ibs = NULL;
parser->num_ibs = 0;
job->free_job = amdgpu_cs_free_job; job->free_job = amdgpu_cs_free_job;
mutex_lock(&job->job_lock); mutex_lock(&job->job_lock);
r = amd_sched_entity_push_job(&job->base); r = amd_sched_entity_push_job(&job->base);
...@@ -905,7 +904,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -905,7 +904,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
cs->out.handle = cs->out.handle =
amdgpu_ctx_add_fence(parser->ctx, ring, amdgpu_ctx_add_fence(parser->ctx, ring,
&job->base.s_fence->base); &job->base.s_fence->base);
parser->ibs[parser->num_ibs - 1].sequence = cs->out.handle; job->ibs[job->num_ibs - 1].sequence = cs->out.handle;
list_sort(NULL, &parser->validated, cmp_size_smaller_first); list_sort(NULL, &parser->validated, cmp_size_smaller_first);
ttm_eu_fence_buffer_objects(&parser->ticket, ttm_eu_fence_buffer_objects(&parser->ticket,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment