Skip to content

Commit 6ef295e

Browse files
matt-auldtursulin
authored andcommitted
drm/i915/ttm: ensure we unmap when purging
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. v2(Thomas): - add ttm_truncate helper, and just call into i915_ttm_move_notify() to handle the unmapping step Fixes: 213d509 ("drm/i915/ttm: Introduce a TTM i915 gem object backend") 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 ab4911b) Signed-off-by: Tvrtko Ursulin <[email protected]>
1 parent 8ee262b commit 6ef295e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,20 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj,
556556
return intel_region_ttm_resource_to_rsgt(obj->mm.region, res);
557557
}
558558

559+
static int i915_ttm_truncate(struct drm_i915_gem_object *obj)
560+
{
561+
struct ttm_buffer_object *bo = i915_gem_to_ttm(obj);
562+
int err;
563+
564+
WARN_ON_ONCE(obj->mm.madv == I915_MADV_WILLNEED);
565+
566+
err = i915_ttm_move_notify(bo);
567+
if (err)
568+
return err;
569+
570+
return i915_ttm_purge(obj);
571+
}
572+
559573
static void i915_ttm_swap_notify(struct ttm_buffer_object *bo)
560574
{
561575
struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
@@ -962,7 +976,7 @@ static const struct drm_i915_gem_object_ops i915_gem_ttm_obj_ops = {
962976

963977
.get_pages = i915_ttm_get_pages,
964978
.put_pages = i915_ttm_put_pages,
965-
.truncate = i915_ttm_purge,
979+
.truncate = i915_ttm_truncate,
966980
.shrinker_release_pages = i915_ttm_shrinker_release_pages,
967981

968982
.adjust_lru = i915_ttm_adjust_lru,

0 commit comments

Comments
 (0)