Commit 0d8ee5ba authored by Thomas Hellström's avatar Thomas Hellström
Browse files

drm/i915: Don't back up pinned LMEM context images and rings during suspend



Pinned context images are now reset during resume. Don't back them up,
and assuming that rings can be assumed empty at suspend, don't back them
up either.

Introduce a new object flag, I915_BO_ALLOC_PM_VOLATILE meaning that an
object is allowed to lose its content on suspend.

v3:
- Slight documentation clarification (Matthew Auld)

Signed-off-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210922062527.865433-7-thomas.hellstrom@linux.intel.com
parent 3e42cc61
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -292,12 +292,15 @@ struct drm_i915_gem_object {
#define I915_BO_ALLOC_VOLATILE    BIT(1)
#define I915_BO_ALLOC_CPU_CLEAR   BIT(2)
#define I915_BO_ALLOC_USER        BIT(3)
/* Object is allowed to lose its contents on suspend / resume, even if pinned */
#define I915_BO_ALLOC_PM_VOLATILE BIT(4)
#define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS | \
			     I915_BO_ALLOC_VOLATILE | \
			     I915_BO_ALLOC_CPU_CLEAR | \
			     I915_BO_ALLOC_USER)
#define I915_BO_READONLY         BIT(4)
#define I915_TILING_QUIRK_BIT    5 /* unknown swizzling; do not release! */
			     I915_BO_ALLOC_USER | \
			     I915_BO_ALLOC_PM_VOLATILE)
#define I915_BO_READONLY          BIT(5)
#define I915_TILING_QUIRK_BIT     6 /* unknown swizzling; do not release! */

	/**
	 * @mem_flags - Mutable placement-related flags
+3 −0
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@ static int i915_ttm_backup(struct i915_gem_apply_to_region *apply,
	if (!pm_apply->backup_pinned)
		return 0;

	if (obj->flags & I915_BO_ALLOC_PM_VOLATILE)
		return 0;

	backup = i915_gem_object_create_shmem(i915, obj->base.size);
	if (IS_ERR(backup))
		return PTR_ERR(backup);
+2 −1
Original line number Diff line number Diff line
@@ -942,7 +942,8 @@ __lrc_alloc_state(struct intel_context *ce, struct intel_engine_cs *engine)
		context_size += PAGE_SIZE;
	}

	obj = i915_gem_object_create_lmem(engine->i915, context_size, 0);
	obj = i915_gem_object_create_lmem(engine->i915, context_size,
					  I915_BO_ALLOC_PM_VOLATILE);
	if (IS_ERR(obj))
		obj = i915_gem_object_create_shmem(engine->i915, context_size);
	if (IS_ERR(obj))
+2 −1
Original line number Diff line number Diff line
@@ -112,7 +112,8 @@ static struct i915_vma *create_ring_vma(struct i915_ggtt *ggtt, int size)
	struct drm_i915_gem_object *obj;
	struct i915_vma *vma;

	obj = i915_gem_object_create_lmem(i915, size, I915_BO_ALLOC_VOLATILE);
	obj = i915_gem_object_create_lmem(i915, size, I915_BO_ALLOC_VOLATILE |
					  I915_BO_ALLOC_PM_VOLATILE);
	if (IS_ERR(obj) && i915_ggtt_has_aperture(ggtt))
		obj = i915_gem_object_create_stolen(i915, size);
	if (IS_ERR(obj))