]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/msm: use trylock for debugfs
authorRob Clark <robdclark@chromium.org>
Sun, 29 Jun 2025 20:13:22 +0000 (13:13 -0700)
committerRob Clark <robin.clark@oss.qualcomm.com>
Sat, 5 Jul 2025 00:48:38 +0000 (17:48 -0700)
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/

drivers/gpu/drm/msm/msm_gem.c
drivers/gpu/drm/msm/msm_gem.h

index e3ccda777ef36ea56b0b522d4d565f76315af2f1..3e87d27dfcb6069b6922020035068a1799e8df99 100644 (file)
@@ -938,7 +938,8 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m,
        uint64_t off = drm_vma_node_start(&obj->vma_node);
        const char *madv;
 
-       msm_gem_lock(obj);
+       if (!msm_gem_trylock(obj))
+               return;
 
        stats->all.count++;
        stats->all.size += obj->size;
index ce5e90ba935b4562f4cf75f66dcc5e53de9c2a64..1ce97f8a30bbbca5f52af48057804de85ad6a384 100644 (file)
@@ -280,6 +280,12 @@ msm_gem_lock(struct drm_gem_object *obj)
        dma_resv_lock(obj->resv, NULL);
 }
 
+static inline bool __must_check
+msm_gem_trylock(struct drm_gem_object *obj)
+{
+       return dma_resv_trylock(obj->resv);
+}
+
 static inline int
 msm_gem_lock_interruptible(struct drm_gem_object *obj)
 {