Skip to content

Commit 8777d17

Browse files
icklematt-auld
authored andcommitted
drm/i915/gem: Pin the L-shape quirked object as unshrinkable
When instantiating a tiled object on an L-shaped memory machine, we mark the object as unshrinkable to prevent the shrinker from trying to swap out the pages. We have to do this as we do not know the swizzling on the individual pages, and so the data will be scrambled across swap out/in. Not only do we need to move the object off the shrinker list, we need to mark the object with shrink_pin so that the counter is consistent across calls to madvise. v2: in the madvise ioctl we need to check if the object is currently shrinkable/purgeable, not if the object type supports shrinking Fixes: 0175969 ("drm/i915/gem: Use shrinkable status for unknown swizzle quirks") References: https://gitlab.freedesktop.org/drm/intel/-/issues/3293 References: https://gitlab.freedesktop.org/drm/intel/-/issues/3450 Reported-by: Ville Syrjälä <[email protected]> Tested-by: Ville Syrjälä <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Signed-off-by: Matthew Auld <[email protected]> Cc: <[email protected]> # v5.12+ Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 727ecd9 commit 8777d17

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
6363
i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
6464
GEM_BUG_ON(i915_gem_object_has_tiling_quirk(obj));
6565
i915_gem_object_set_tiling_quirk(obj);
66+
GEM_BUG_ON(!list_empty(&obj->mm.link));
67+
atomic_inc(&obj->mm.shrink_pin);
6668
shrinkable = false;
6769
}
6870

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,21 +1009,20 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
10091009
obj->mm.madv = args->madv;
10101010

10111011
if (i915_gem_object_has_pages(obj)) {
1012-
struct list_head *list;
1012+
unsigned long flags;
10131013

1014-
if (i915_gem_object_is_shrinkable(obj)) {
1015-
unsigned long flags;
1016-
1017-
spin_lock_irqsave(&i915->mm.obj_lock, flags);
1014+
spin_lock_irqsave(&i915->mm.obj_lock, flags);
1015+
if (!list_empty(&obj->mm.link)) {
1016+
struct list_head *list;
10181017

10191018
if (obj->mm.madv != I915_MADV_WILLNEED)
10201019
list = &i915->mm.purge_list;
10211020
else
10221021
list = &i915->mm.shrink_list;
10231022
list_move_tail(&obj->mm.link, list);
10241023

1025-
spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
10261024
}
1025+
spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
10271026
}
10281027

10291028
/* if the object is no longer attached, discard its backing storage */

0 commit comments

Comments
 (0)