aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu.h
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-11-05 13:49:48 -0500
committerAlex Deucher <alexander.deucher@amd.com>2015-11-16 11:05:58 -0500
commite284022163716ecf11c37fd1057c35d689ef2c11 (patch)
tree90269611e4360eab59eeb534fcf8725d4835ed42 /drivers/gpu/drm/amd/amdgpu/amdgpu.h
parent4a562283376197722b295d27633134401bbc80f5 (diff)
drm/amdgpu: fix incorrect mutex usage v3
Before this patch the scheduler fence was created when we push the job into the queue, so we could only get the fence after pushing it. The mutex now was necessary to prevent the thread pushing the jobs to the hardware from running faster than the thread pushing the jobs into the queue. Otherwise the thread pushing jobs into the queue would have accessed possible freed up memory when it tries to get a reference to the fence. So what you get in the end is thread A: mutex_lock(&job->lock); ... Kick of thread B. ... mutex_unlock(&job->lock); And thread B: mutex_lock(&job->lock); .... mutex_unlock(&job->lock); kfree(job); I'm actually not sure if I'm still up to date on this, but this usage pattern used to be not allowed with mutexes. See here as well https://lwn.net/Articles/575460/. v2: remove unrelated changes, fix missing owner v3: rebased, add more commit message Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu.h')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 7b02e3455172..0f187027c753 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1225,7 +1225,7 @@ struct amdgpu_job {
1225 struct amdgpu_device *adev; 1225 struct amdgpu_device *adev;
1226 struct amdgpu_ib *ibs; 1226 struct amdgpu_ib *ibs;
1227 uint32_t num_ibs; 1227 uint32_t num_ibs;
1228 struct mutex job_lock; 1228 void *owner;
1229 struct amdgpu_user_fence uf; 1229 struct amdgpu_user_fence uf;
1230 int (*free_job)(struct amdgpu_job *job); 1230 int (*free_job)(struct amdgpu_job *job);
1231}; 1231};