]> www.infradead.org Git - nvme.git/commitdiff
drm/i915: Ensure we hold the object mutex in pin correctly.
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Tue, 23 Mar 2021 15:49:54 +0000 (16:49 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 24 Mar 2021 10:43:25 +0000 (11:43 +0100)
Currently we have a lot of places where we hold the gem object lock,
but haven't yet been converted to the ww dance. Complain loudly about
those places.

i915_vma_pin shouldn't have the obj lock held, so we can do a ww dance,
while i915_vma_pin_ww should.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> #irc
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210323155059.628690-6-maarten.lankhorst@linux.intel.com
drivers/gpu/drm/i915/gt/intel_renderstate.c
drivers/gpu/drm/i915/i915_vma.c
drivers/gpu/drm/i915/i915_vma.h

index ca816ba22197123358cc8a032b1b02face075861..334c557673dda48de4bbdf523d9461e9bb76d8af 100644 (file)
@@ -197,7 +197,7 @@ retry:
        if (err)
                goto err_context;
 
-       err = i915_vma_pin(so->vma, 0, 0, PIN_GLOBAL | PIN_HIGH);
+       err = i915_vma_pin_ww(so->vma, &so->ww, 0, 0, PIN_GLOBAL | PIN_HIGH);
        if (err)
                goto err_context;
 
index ee0028c697f6750d8d42665326f540de6bfafe03..82b73dbc9737f9ad05f97989dbb9b036439c012d 100644 (file)
@@ -865,6 +865,8 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 #ifdef CONFIG_PROVE_LOCKING
        if (debug_locks && lockdep_is_held(&vma->vm->i915->drm.struct_mutex))
                WARN_ON(!ww);
+       if (debug_locks && ww && vma->resv)
+               assert_vma_held(vma);
 #endif
 
        BUILD_BUG_ON(PIN_GLOBAL != I915_VMA_GLOBAL_BIND);
@@ -1020,8 +1022,15 @@ int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 
        GEM_BUG_ON(!i915_vma_is_ggtt(vma));
 
+#ifdef CONFIG_LOCKDEP
+       WARN_ON(!ww && vma->resv && dma_resv_held(vma->resv));
+#endif
+
        do {
-               err = i915_vma_pin_ww(vma, ww, 0, align, flags | PIN_GLOBAL);
+               if (ww)
+                       err = i915_vma_pin_ww(vma, ww, 0, align, flags | PIN_GLOBAL);
+               else
+                       err = i915_vma_pin(vma, 0, align, flags | PIN_GLOBAL);
                if (err != -ENOSPC) {
                        if (!err) {
                                err = i915_vma_wait_for_bind(vma);
index a64adc8c883b01315b41a64a73b8079f533c7191..3c914c9de9a9ee52eebb90c06827d2564fa82e69 100644 (file)
@@ -243,6 +243,9 @@ i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
 static inline int __must_check
 i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
 {
+#ifdef CONFIG_LOCKDEP
+       WARN_ON_ONCE(vma->resv && dma_resv_held(vma->resv));
+#endif
        return i915_vma_pin_ww(vma, NULL, size, alignment, flags);
 }