On Wed, 2022-01-05 at 14:58 +0000, Matthew Auld wrote: > Purging can happen during swapping out, or directly invoked with the > madvise ioctl. In such cases this doesn't involve a ttm move, which > skips umapping the object. > > Fixes: cf3e3e86d779 ("drm/i915: Use ttm mmap handling for ttm bo's.") > Signed-off-by: Matthew Auld <matthew.auld@xxxxxxxxx> > Cc: Thomas Hellström <thomas.hellstrom@xxxxxxxxxxxxxxx> > --- > drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c > b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c > index 8d61d4538a64..f148e7e48f86 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c > @@ -399,6 +399,8 @@ int i915_ttm_purge(struct drm_i915_gem_object > *obj) > if (obj->mm.madv == __I915_MADV_PURGED) > return 0; > > + ttm_bo_unmap_virtual(bo); > + > ret = ttm_bo_validate(bo, &place, &ctx); > if (ret) > return ret; The swap notifier and the move code both call i915_ttm_move_notify() to achieve this before calling i915_ttm_purge. This ensures both cpu- and gpu ptes are torn down, and also when we extend to dynamic dma-buf exporting, makes sure dma-buf importers unbind. So I suggest we make a i915_ttm_truncate wrapper function that calls i915_ttm_move_notify() and then ttm_bo_purge(), and use that as the truncate callback as well as from those places we call i915_ttm_purge without a prior call to i915_ttm_move_notify(), which seems to be the ones you've identified in patch 3 and 4, /Thomas