Skip to content

Commit 581ab1f

Browse files
committed
drm/i915: Unwind conversion to i915_gem_phys_ops on failure
The physical object is treated as permanently pinned. If we fail to take this initial pin during i915_gem_object_attach_phys() we need to revert it back to an ordinary shmemfs object before reporting the failure. v2: git-add Reported-by: Mika Kuoppala <mika.kuoppala@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Mika Kuoppala <mika.kuoppala@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20170215163900.11606-1-chris@chris-wilson.co.uk Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
1 parent c1d2061 commit 581ab1f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ static const struct drm_i915_gem_object_ops i915_gem_phys_ops = {
313313
.release = i915_gem_object_release_phys,
314314
};
315315

316+
static const struct drm_i915_gem_object_ops i915_gem_object_ops;
317+
316318
int i915_gem_object_unbind(struct drm_i915_gem_object *obj)
317319
{
318320
struct i915_vma *vma;
@@ -586,9 +588,18 @@ i915_gem_object_attach_phys(struct drm_i915_gem_object *obj,
586588
if (obj->mm.pages)
587589
return -EBUSY;
588590

591+
GEM_BUG_ON(obj->ops != &i915_gem_object_ops);
589592
obj->ops = &i915_gem_phys_ops;
590593

591-
return i915_gem_object_pin_pages(obj);
594+
ret = i915_gem_object_pin_pages(obj);
595+
if (ret)
596+
goto err_xfer;
597+
598+
return 0;
599+
600+
err_xfer:
601+
obj->ops = &i915_gem_object_ops;
602+
return ret;
592603
}
593604

594605
static int

0 commit comments

Comments
 (0)