Commit 903e0387 authored by Matthew Auld's avatar Matthew Auld
Browse files

drm/i915/ttm: add unmap_virtual callback



Ensure we call ttm_bo_unmap_virtual when releasing the pages.
Importantly this should now handle the ttm swapping case, and all other
places that already call into i915_ttm_move_notify().

v2: fix up the selftest

Fixes: cf3e3e86 ("drm/i915: Use ttm mmap handling for ttm bo's.")
Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220106174910.280616-3-matthew.auld@intel.com
parent f3cb4a2d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -537,6 +537,9 @@ void i915_gem_object_release_mmap_offset(struct drm_i915_gem_object *obj)
{
	struct i915_mmap_offset *mmo, *mn;

	if (obj->ops->unmap_virtual)
		obj->ops->unmap_virtual(obj);

	spin_lock(&obj->mmo.lock);
	rbtree_postorder_for_each_entry_safe(mmo, mn,
					     &obj->mmo.offsets, offset) {
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ struct drm_i915_gem_object_ops {
	int (*pwrite)(struct drm_i915_gem_object *obj,
		      const struct drm_i915_gem_pwrite *arg);
	u64 (*mmap_offset)(struct drm_i915_gem_object *obj);
	void (*unmap_virtual)(struct drm_i915_gem_object *obj);

	int (*dmabuf_export)(struct drm_i915_gem_object *obj);

+6 −0
Original line number Diff line number Diff line
@@ -948,6 +948,11 @@ static u64 i915_ttm_mmap_offset(struct drm_i915_gem_object *obj)
	return drm_vma_node_offset_addr(&obj->base.vma_node);
}

static void i915_ttm_unmap_virtual(struct drm_i915_gem_object *obj)
{
	ttm_bo_unmap_virtual(i915_gem_to_ttm(obj));
}

static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = {
	.name = "i915_gem_object_ttm",
	.flags = I915_GEM_OBJECT_IS_SHRINKABLE |
@@ -963,6 +968,7 @@ static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = {
	.migrate = i915_ttm_migrate,

	.mmap_offset = i915_ttm_mmap_offset,
	.unmap_virtual = i915_ttm_unmap_virtual,
	.mmap_ops = &vm_ops_ttm,
};

+4 −14
Original line number Diff line number Diff line
@@ -1369,21 +1369,11 @@ static int __igt_mmap_revoke(struct drm_i915_private *i915,
		}
	}

	if (!obj->ops->mmap_ops) {
	err = check_absent(addr, obj->base.size);
	if (err) {
		pr_err("%s: was not absent\n", obj->mm.region->name);
		goto out_unmap;
	}
	} else {
		/* ttm allows access to evicted regions by design */

		err = check_present(addr, obj->base.size);
		if (err) {
			pr_err("%s: was not present\n", obj->mm.region->name);
			goto out_unmap;
		}
	}

out_unmap:
	vm_munmap(addr, obj->base.size);