drm/i915: Don't back up pinned LMEM context images and rings during suspend
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Wed, 22 Sep 2021 06:25:24 +0000 (08:25 +0200)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Fri, 24 Sep 2021 06:19:15 +0000 (08:19 +0200)
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: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210922062527.865433-7-thomas.hellstrom@linux.intel.com
drivers/gpu/drm/i915/gem/i915_gem_object_types.h
drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c
drivers/gpu/drm/i915/gt/intel_lrc.c
drivers/gpu/drm/i915/gt/intel_ring.c

index 734cc8e1648177fb208344c17b3b6cdc5165f8a9..118691ce81d7df283bc06ae566d3867ebdabc76b 100644 (file)
@@ -288,16 +288,19 @@ struct drm_i915_gem_object {
        I915_SELFTEST_DECLARE(struct list_head st_link);
 
        unsigned long flags;
-#define I915_BO_ALLOC_CONTIGUOUS BIT(0)
-#define I915_BO_ALLOC_VOLATILE   BIT(1)
-#define I915_BO_ALLOC_CPU_CLEAR  BIT(2)
-#define I915_BO_ALLOC_USER       BIT(3)
+#define I915_BO_ALLOC_CONTIGUOUS  BIT(0)
+#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
index cb1c46724f70e7b317bc4def5e4c710f3fb5af2c..03a00d193f40b8df013ea76189e0a660f7af3db4 100644 (file)
@@ -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);
index 6ba8daea2f5690b24bda6ba642fd620a5d8f7848..3ef9eaf8c50e71064b97f7fbc874d1d11f6f8be3 100644 (file)
@@ -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))
index 7c4d5158e03bb850c4a0579af83209ef153cd769..2fdd52b620921eb732c39af27dccc0e16c22ccee 100644 (file)
@@ -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))