Skip to content

Commit

Permalink
drm/i915: Take object lock in i915_ggtt_pin if ww is not set
Browse files Browse the repository at this point in the history
i915_vma_wait_for_bind needs the vma lock held, fix the caller.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211216142749.1966107-5-maarten.lankhorst@linux.intel.com
  • Loading branch information
Maarten Lankhorst committed Dec 20, 2021
1 parent 0b4d1f0 commit 2abb619
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions drivers/gpu/drm/i915/i915_vma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1386,23 +1386,15 @@ static void flush_idle_contexts(struct intel_gt *gt)
intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
}

int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
u32 align, unsigned int flags)
static int __i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
u32 align, unsigned int flags)
{
struct i915_address_space *vm = vma->vm;
int err;

GEM_BUG_ON(!i915_vma_is_ggtt(vma));

#ifdef CONFIG_LOCKDEP
WARN_ON(!ww && dma_resv_held(vma->obj->base.resv));
#endif

do {
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);
err = i915_vma_pin_ww(vma, ww, 0, align, flags | PIN_GLOBAL);

if (err != -ENOSPC) {
if (!err) {
err = i915_vma_wait_for_bind(vma);
Expand All @@ -1421,6 +1413,30 @@ int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
} while (1);
}

int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
u32 align, unsigned int flags)
{
struct i915_gem_ww_ctx _ww;
int err;

GEM_BUG_ON(!i915_vma_is_ggtt(vma));

if (ww)
return __i915_ggtt_pin(vma, ww, align, flags);

#ifdef CONFIG_LOCKDEP
WARN_ON(dma_resv_held(vma->obj->base.resv));
#endif

for_i915_gem_ww(&_ww, err, true) {
err = i915_gem_object_lock(vma->obj, &_ww);
if (!err)
err = __i915_ggtt_pin(vma, &_ww, align, flags);
}

return err;
}

static void __vma_close(struct i915_vma *vma, struct intel_gt *gt)
{
/*
Expand Down

0 comments on commit 2abb619

Please sign in to comment.