mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 13:34:10 +08:00
drm/i915/gem: Use shrinkable status for unknown swizzle quirks
Give obj->mm.quirked a name much more reflective of its purpose (i915_gem_object_has_tiling_quirk) and move it from the obj->mm field as it doesn't denote a quirk of the backing store, but a quirk in the object in its treatment of the backing pages, similar to tiling modes. Then instead of abusing the pinned status of the buffer to protect it from the shrinker, we can instead hide the buffer from the shrinker so it is never considered for being swapped. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210119214336.1463-4-chris@chris-wilson.co.uk
This commit is contained in:
parent
41a9c75d0a
commit
0175969e48
@ -187,6 +187,24 @@ i915_gem_object_set_volatile(struct drm_i915_gem_object *obj)
|
||||
obj->flags |= I915_BO_ALLOC_VOLATILE;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
i915_gem_object_has_tiling_quirk(struct drm_i915_gem_object *obj)
|
||||
{
|
||||
return test_bit(I915_TILING_QUIRK_BIT, &obj->flags);
|
||||
}
|
||||
|
||||
static inline void
|
||||
i915_gem_object_set_tiling_quirk(struct drm_i915_gem_object *obj)
|
||||
{
|
||||
set_bit(I915_TILING_QUIRK_BIT, &obj->flags);
|
||||
}
|
||||
|
||||
static inline void
|
||||
i915_gem_object_clear_tiling_quirk(struct drm_i915_gem_object *obj)
|
||||
{
|
||||
clear_bit(I915_TILING_QUIRK_BIT, &obj->flags);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
i915_gem_object_type_has(const struct drm_i915_gem_object *obj,
|
||||
unsigned long flags)
|
||||
|
@ -173,6 +173,7 @@ struct drm_i915_gem_object {
|
||||
#define I915_BO_ALLOC_VOLATILE BIT(1)
|
||||
#define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS | I915_BO_ALLOC_VOLATILE)
|
||||
#define I915_BO_READONLY BIT(2)
|
||||
#define I915_TILING_QUIRK_BIT 3 /* unknown swizzling; do not release! */
|
||||
|
||||
/*
|
||||
* Is the object to be mapped as read-only to the GPU
|
||||
@ -281,12 +282,6 @@ struct drm_i915_gem_object {
|
||||
* pages were last acquired.
|
||||
*/
|
||||
bool dirty:1;
|
||||
|
||||
/**
|
||||
* This is set if the object has been pinned due to unknown
|
||||
* swizzling.
|
||||
*/
|
||||
bool quirked:1;
|
||||
} mm;
|
||||
|
||||
/** Record of address bit 17 of each page at last unbind. */
|
||||
|
@ -16,6 +16,7 @@ void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
|
||||
{
|
||||
struct drm_i915_private *i915 = to_i915(obj->base.dev);
|
||||
unsigned long supported = INTEL_INFO(i915)->page_sizes;
|
||||
bool shrinkable;
|
||||
int i;
|
||||
|
||||
lockdep_assert_held(&obj->mm.lock);
|
||||
@ -38,13 +39,6 @@ void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
|
||||
|
||||
obj->mm.pages = pages;
|
||||
|
||||
if (i915_gem_object_is_tiled(obj) &&
|
||||
i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
|
||||
GEM_BUG_ON(obj->mm.quirked);
|
||||
__i915_gem_object_pin_pages(obj);
|
||||
obj->mm.quirked = true;
|
||||
}
|
||||
|
||||
GEM_BUG_ON(!sg_page_sizes);
|
||||
obj->mm.page_sizes.phys = sg_page_sizes;
|
||||
|
||||
@ -63,7 +57,16 @@ void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
|
||||
}
|
||||
GEM_BUG_ON(!HAS_PAGE_SIZES(i915, obj->mm.page_sizes.sg));
|
||||
|
||||
if (i915_gem_object_is_shrinkable(obj)) {
|
||||
shrinkable = i915_gem_object_is_shrinkable(obj);
|
||||
|
||||
if (i915_gem_object_is_tiled(obj) &&
|
||||
i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
|
||||
GEM_BUG_ON(i915_gem_object_has_tiling_quirk(obj));
|
||||
i915_gem_object_set_tiling_quirk(obj);
|
||||
shrinkable = false;
|
||||
}
|
||||
|
||||
if (shrinkable) {
|
||||
struct list_head *list;
|
||||
unsigned long flags;
|
||||
|
||||
|
@ -227,7 +227,7 @@ int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align)
|
||||
goto err_unlock;
|
||||
}
|
||||
|
||||
if (obj->mm.quirked) {
|
||||
if (i915_gem_object_has_tiling_quirk(obj)) {
|
||||
err = -EFAULT;
|
||||
goto err_unlock;
|
||||
}
|
||||
|
@ -270,14 +270,14 @@ i915_gem_object_set_tiling(struct drm_i915_gem_object *obj,
|
||||
obj->mm.madv == I915_MADV_WILLNEED &&
|
||||
i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
|
||||
if (tiling == I915_TILING_NONE) {
|
||||
GEM_BUG_ON(!obj->mm.quirked);
|
||||
__i915_gem_object_unpin_pages(obj);
|
||||
obj->mm.quirked = false;
|
||||
GEM_BUG_ON(!i915_gem_object_has_tiling_quirk(obj));
|
||||
i915_gem_object_clear_tiling_quirk(obj);
|
||||
i915_gem_object_make_shrinkable(obj);
|
||||
}
|
||||
if (!i915_gem_object_is_tiled(obj)) {
|
||||
GEM_BUG_ON(obj->mm.quirked);
|
||||
__i915_gem_object_pin_pages(obj);
|
||||
obj->mm.quirked = true;
|
||||
GEM_BUG_ON(i915_gem_object_has_tiling_quirk(obj));
|
||||
i915_gem_object_make_unshrinkable(obj);
|
||||
i915_gem_object_set_tiling_quirk(obj);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&obj->mm.lock);
|
||||
|
@ -957,14 +957,14 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
|
||||
i915_gem_object_is_tiled(obj) &&
|
||||
i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
|
||||
if (obj->mm.madv == I915_MADV_WILLNEED) {
|
||||
GEM_BUG_ON(!obj->mm.quirked);
|
||||
__i915_gem_object_unpin_pages(obj);
|
||||
obj->mm.quirked = false;
|
||||
GEM_BUG_ON(!i915_gem_object_has_tiling_quirk(obj));
|
||||
i915_gem_object_clear_tiling_quirk(obj);
|
||||
i915_gem_object_make_shrinkable(obj);
|
||||
}
|
||||
if (args->madv == I915_MADV_WILLNEED) {
|
||||
GEM_BUG_ON(obj->mm.quirked);
|
||||
__i915_gem_object_pin_pages(obj);
|
||||
obj->mm.quirked = true;
|
||||
GEM_BUG_ON(i915_gem_object_has_tiling_quirk(obj));
|
||||
i915_gem_object_make_unshrinkable(obj);
|
||||
i915_gem_object_set_tiling_quirk(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,8 @@ static void quirk_add(struct drm_i915_gem_object *obj,
|
||||
struct list_head *objects)
|
||||
{
|
||||
/* quirk is only for live tiled objects, use it to declare ownership */
|
||||
GEM_BUG_ON(obj->mm.quirked);
|
||||
obj->mm.quirked = true;
|
||||
GEM_BUG_ON(i915_gem_object_has_tiling_quirk(obj));
|
||||
i915_gem_object_set_tiling_quirk(obj);
|
||||
list_add(&obj->st_link, objects);
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ static void unpin_ggtt(struct i915_ggtt *ggtt)
|
||||
struct i915_vma *vma;
|
||||
|
||||
list_for_each_entry(vma, &ggtt->vm.bound_list, vm_link)
|
||||
if (vma->obj->mm.quirked)
|
||||
if (i915_gem_object_has_tiling_quirk(vma->obj))
|
||||
i915_vma_unpin(vma);
|
||||
}
|
||||
|
||||
@ -94,8 +94,8 @@ static void cleanup_objects(struct i915_ggtt *ggtt, struct list_head *list)
|
||||
struct drm_i915_gem_object *obj, *on;
|
||||
|
||||
list_for_each_entry_safe(obj, on, list, st_link) {
|
||||
GEM_BUG_ON(!obj->mm.quirked);
|
||||
obj->mm.quirked = false;
|
||||
GEM_BUG_ON(!i915_gem_object_has_tiling_quirk(obj));
|
||||
i915_gem_object_set_tiling_quirk(obj);
|
||||
i915_gem_object_put(obj);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user