Skip to content

Commit 8ee262b

Browse files
matt-auldtursulin
authored andcommitted
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: cf3e3e8 ("drm/i915: Use ttm mmap handling for ttm bo's.") Signed-off-by: Matthew Auld <[email protected]> Cc: Thomas Hellström <[email protected]> Reviewed-by: Thomas Hellström <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 903e038) Signed-off-by: Tvrtko Ursulin <[email protected]>
1 parent 03ee595 commit 8ee262b

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

drivers/gpu/drm/i915/gem/i915_gem_mman.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,9 @@ void i915_gem_object_release_mmap_offset(struct drm_i915_gem_object *obj)
538538
{
539539
struct i915_mmap_offset *mmo, *mn;
540540

541+
if (obj->ops->unmap_virtual)
542+
obj->ops->unmap_virtual(obj);
543+
541544
spin_lock(&obj->mmo.lock);
542545
rbtree_postorder_for_each_entry_safe(mmo, mn,
543546
&obj->mmo.offsets, offset) {

drivers/gpu/drm/i915/gem/i915_gem_object_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct drm_i915_gem_object_ops {
6767
int (*pwrite)(struct drm_i915_gem_object *obj,
6868
const struct drm_i915_gem_pwrite *arg);
6969
u64 (*mmap_offset)(struct drm_i915_gem_object *obj);
70+
void (*unmap_virtual)(struct drm_i915_gem_object *obj);
7071

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

drivers/gpu/drm/i915/gem/i915_gem_ttm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,11 @@ static u64 i915_ttm_mmap_offset(struct drm_i915_gem_object *obj)
950950
return drm_vma_node_offset_addr(&obj->base.vma_node);
951951
}
952952

953+
static void i915_ttm_unmap_virtual(struct drm_i915_gem_object *obj)
954+
{
955+
ttm_bo_unmap_virtual(i915_gem_to_ttm(obj));
956+
}
957+
953958
static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = {
954959
.name = "i915_gem_object_ttm",
955960
.flags = I915_GEM_OBJECT_IS_SHRINKABLE |
@@ -965,6 +970,7 @@ static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = {
965970
.migrate = i915_ttm_migrate,
966971

967972
.mmap_offset = i915_ttm_mmap_offset,
973+
.unmap_virtual = i915_ttm_unmap_virtual,
968974
.mmap_ops = &vm_ops_ttm,
969975
};
970976

drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,20 +1368,10 @@ static int __igt_mmap_revoke(struct drm_i915_private *i915,
13681368
}
13691369
}
13701370

1371-
if (!obj->ops->mmap_ops) {
1372-
err = check_absent(addr, obj->base.size);
1373-
if (err) {
1374-
pr_err("%s: was not absent\n", obj->mm.region->name);
1375-
goto out_unmap;
1376-
}
1377-
} else {
1378-
/* ttm allows access to evicted regions by design */
1379-
1380-
err = check_present(addr, obj->base.size);
1381-
if (err) {
1382-
pr_err("%s: was not present\n", obj->mm.region->name);
1383-
goto out_unmap;
1384-
}
1371+
err = check_absent(addr, obj->base.size);
1372+
if (err) {
1373+
pr_err("%s: was not absent\n", obj->mm.region->name);
1374+
goto out_unmap;
13851375
}
13861376

13871377
out_unmap:

0 commit comments

Comments
 (0)