summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/msm/msm_gpu.c
diff options
context:
space:
mode:
authorRob Clark <robdclark@chromium.org>2020-11-16 09:48:49 -0800
committerRob Clark <robdclark@chromium.org>2020-11-21 09:50:23 -0800
commitab5c54cb88350e224632e5b0fcd7f86ece06beb9 (patch)
tree01cc4f34f02dd7815eb6cdb96ead692b569b793a /drivers/gpu/drm/msm/msm_gpu.c
parente8c765811b1064c200829eacf237ac8c25e79cd0 (diff)
drm/msm: Protect obj->active_count under obj lock
Previously we only held obj lock in the _active_get() path, and relied on atomic_dec_return() to not be racy in the _active_put() path where obj lock was not held. But this is a false sense of security. Unlike obj lifetime refcnt, where you do not expect to *increase* the refcnt after the last put (which would mean that something has gone horribly wrong with the object liveness reference counting), the active_count can increase again from zero. Racing _active_put()s and _active_get()s could leave the obj on the wrong mm list. But in the retire path, immediately after the _active_put(), the _unpin_iova() would acquire obj lock. So just move the locking earlier and rely on that to protect obj->active_count. Fixes: c5c1643cef7a ("drm/msm: Drop struct_mutex from the retire path") Signed-off-by: Rob Clark <robdclark@chromium.org>
Diffstat (limited to 'drivers/gpu/drm/msm/msm_gpu.c')
-rw-r--r--drivers/gpu/drm/msm/msm_gpu.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index dfa3b5ad2099..ab7c167b0623 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -719,11 +719,13 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
stats->alwayson_start, stats->alwayson_end);
for (i = 0; i < submit->nr_bos; i++) {
- struct msm_gem_object *msm_obj = submit->bos[i].obj;
+ struct drm_gem_object *obj = &submit->bos[i].obj->base;
- msm_gem_active_put(&msm_obj->base);
- msm_gem_unpin_iova(&msm_obj->base, submit->aspace);
- drm_gem_object_put(&msm_obj->base);
+ msm_gem_lock(obj);
+ msm_gem_active_put(obj);
+ msm_gem_unpin_iova_locked(obj, submit->aspace);
+ msm_gem_unlock(obj);
+ drm_gem_object_put(obj);
}
pm_runtime_mark_last_busy(&gpu->pdev->dev);