Skip to content

Commit 0a1ff88

Browse files
robclarkRob Clark
authored andcommitted
drm/msm: use trylock for debugfs
This resolves a potential deadlock vs msm_gem_vm_close(). Otherwise for _NO_SHARE buffers msm_gem_describe() could be trying to acquire the shared vm resv, while already holding priv->obj_lock. But _vm_close() might drop the last reference to a GEM obj while already holding the vm resv, and msm_gem_free_object() needs to grab priv->obj_lock, a locking inversion. OTOH this is only for debugfs and it isn't critical if we undercount by skipping a locked obj. So just use trylock() and move along if we can't get the lock. Signed-off-by: Rob Clark <robdclark@chromium.org> Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com> Tested-by: Antonino Maniscalco <antomani103@gmail.com> Reviewed-by: Antonino Maniscalco <antomani103@gmail.com> Patchwork: https://patchwork.freedesktop.org/patch/661525/
1 parent 05a2496 commit 0a1ff88

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/gpu/drm/msm/msm_gem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,8 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m,
938938
uint64_t off = drm_vma_node_start(&obj->vma_node);
939939
const char *madv;
940940

941-
msm_gem_lock(obj);
941+
if (!msm_gem_trylock(obj))
942+
return;
942943

943944
stats->all.count++;
944945
stats->all.size += obj->size;

drivers/gpu/drm/msm/msm_gem.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ msm_gem_lock(struct drm_gem_object *obj)
280280
dma_resv_lock(obj->resv, NULL);
281281
}
282282

283+
static inline bool __must_check
284+
msm_gem_trylock(struct drm_gem_object *obj)
285+
{
286+
return dma_resv_trylock(obj->resv);
287+
}
288+
283289
static inline int
284290
msm_gem_lock_interruptible(struct drm_gem_object *obj)
285291
{

0 commit comments

Comments
 (0)