Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/gem: Convert to lockdep assert

Utilize the power of lockdep for our GEM locking related sanity
checking.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/496139/
Link: https://lore.kernel.org/r/20220802155152.1727594-16-robdclark@gmail.com

+6 -9
+6 -9
drivers/gpu/drm/msm/msm_gem.h
··· 197 197 dma_resv_unlock(obj->resv); 198 198 } 199 199 200 - static inline bool 201 - msm_gem_is_locked(struct drm_gem_object *obj) 200 + static inline void 201 + msm_gem_assert_locked(struct drm_gem_object *obj) 202 202 { 203 203 /* 204 204 * Destroying the object is a special case.. msm_gem_free_object() ··· 212 212 * Unfortunately lockdep is not aware of this detail. So when the 213 213 * refcount drops to zero, we pretend it is already locked. 214 214 */ 215 - return dma_resv_is_locked(obj->resv) || (kref_read(&obj->refcount) == 0); 216 - } 217 - 218 - static inline void 219 - msm_gem_assert_locked(struct drm_gem_object *obj) 220 - { 221 - GEM_WARN_ON(!msm_gem_is_locked(obj)); 215 + lockdep_assert_once( 216 + (kref_read(&obj->refcount) == 0) || 217 + (lockdep_is_held(&obj->resv->lock.base) != LOCK_STATE_NOT_HELD) 218 + ); 222 219 } 223 220 224 221 /* imported/exported objects are not purgeable: */