drm/gem: fix lockdep check for dma-resv lock
authorDanilo Krummrich <dakr@redhat.com>
Fri, 4 Aug 2023 18:23:41 +0000 (20:23 +0200)
committerDanilo Krummrich <dakr@redhat.com>
Fri, 4 Aug 2023 18:34:31 +0000 (20:34 +0200)
commit0c0816d68d963302a7f4a7a28cc685f73263b964
tree7593e11e40c647699126a533a5428da41cc02cee
parenta5ae331edb02b6645514f7632478733439e28b34
drm/gem: fix lockdep check for dma-resv lock

When no custom lock is set to protect a GEMs GPUVA list, lockdep checks
should fall back to the GEM objects dma-resv lock. With the current
implementation we're setting the lock_dep_map of the GEM objects 'resv'
pointer (in case no custom lock_dep_map is set yet) on
drm_gem_private_object_init().

However, the GEM objects 'resv' pointer might still change after
drm_gem_private_object_init() is called, e.g. through
ttm_bo_init_reserved(). This can result in the wrong lock being tracked.

To fix this, call dma_resv_held() directly from
drm_gem_gpuva_assert_lock_held() and fall back to the GEMs lock_dep_map
pointer only if an actual custom lock is set.

Fixes: e6303f323b1a ("drm: manager to keep track of GPUs VA mappings")
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230804182406.5222-2-dakr@redhat.com
include/drm/drm_gem.h