Skip to content

Commit

Permalink
drm/msm: Take the mutex before calling msm_gem_new_impl
Browse files Browse the repository at this point in the history
Amongst its other duties, msm_gem_new_impl adds the newly created
GEM object to the shared inactive list which may also be actively
modifiying the list during submission.  All the paths to modify
the list are protected by the mutex except for the one through
msm_gem_import which can end up causing list corruption.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
[add extra WARN_ON(!mutex_is_locked(&dev->struct_mutex))]
Signed-off-by: Rob Clark <robdclark@gmail.com>
  • Loading branch information
Jordan Crouse authored and Rob Clark committed May 27, 2017
1 parent 3cfac69 commit 90dd57d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/gpu/drm/msm/msm_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,8 @@ static int msm_gem_new_impl(struct drm_device *dev,
struct msm_gem_object *msm_obj;
bool use_vram = false;

WARN_ON(!mutex_is_locked(&dev->struct_mutex));

switch (flags & MSM_BO_CACHE_MASK) {
case MSM_BO_UNCACHED:
case MSM_BO_CACHED:
Expand Down Expand Up @@ -853,7 +855,11 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,

size = PAGE_ALIGN(dmabuf->size);

/* Take mutex so we can modify the inactive list in msm_gem_new_impl */
mutex_lock(&dev->struct_mutex);
ret = msm_gem_new_impl(dev, size, MSM_BO_WC, dmabuf->resv, &obj);
mutex_unlock(&dev->struct_mutex);

if (ret)
goto fail;

Expand Down

0 comments on commit 90dd57d

Please sign in to comment.