Skip to content

Commit ad0fca2

Browse files
matt-auldrodrigovivi
authored andcommitted
drm/i915/ttm: consider CCS for backup objects
It seems we can have one or more framebuffers that are still pinned when suspending lmem, in such a case we end up creating a shmem backup object, instead of evicting the object directly, but this will skip copying the CCS aux state, since we don't allocate the extra storage for the CCS pages as part of the ttm_tt construction. Since we can already deal with pinned objects just fine, it doesn't seem too nasty to just extend to support dealing with the CCS aux state, if the object is a pinned framebuffer. This fixes display corruption (like in gnome-shell) seen on DG2 when returning from suspend. Fixes: da0595a ("drm/i915/migrate: Evict and restore the flatccs capable lmem obj") Signed-off-by: Matthew Auld <[email protected]> Cc: Ville Syrjälä <[email protected]> Cc: Nirmoy Das <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Shuicheng Lin <[email protected]> Cc: <[email protected]> # v5.19+ Tested-by: Nirmoy Das <[email protected]> Reviewed-by: Nirmoy Das <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 95df9cc) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 952d191 commit ad0fca2

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@ bool i915_gem_object_needs_ccs_pages(struct drm_i915_gem_object *obj)
785785
if (!HAS_FLAT_CCS(to_i915(obj->base.dev)))
786786
return false;
787787

788+
if (obj->flags & I915_BO_ALLOC_CCS_AUX)
789+
return true;
790+
788791
for (i = 0; i < obj->mm.n_placements; i++) {
789792
/* Compression is not allowed for the objects with smem placement */
790793
if (obj->mm.placements[i]->type == INTEL_MEMORY_SYSTEM)

drivers/gpu/drm/i915/gem/i915_gem_object_types.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,18 @@ struct drm_i915_gem_object {
327327
* dealing with userspace objects the CPU fault handler is free to ignore this.
328328
*/
329329
#define I915_BO_ALLOC_GPU_ONLY BIT(6)
330+
#define I915_BO_ALLOC_CCS_AUX BIT(7)
330331
#define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS | \
331332
I915_BO_ALLOC_VOLATILE | \
332333
I915_BO_ALLOC_CPU_CLEAR | \
333334
I915_BO_ALLOC_USER | \
334335
I915_BO_ALLOC_PM_VOLATILE | \
335336
I915_BO_ALLOC_PM_EARLY | \
336-
I915_BO_ALLOC_GPU_ONLY)
337-
#define I915_BO_READONLY BIT(7)
338-
#define I915_TILING_QUIRK_BIT 8 /* unknown swizzling; do not release! */
339-
#define I915_BO_PROTECTED BIT(9)
337+
I915_BO_ALLOC_GPU_ONLY | \
338+
I915_BO_ALLOC_CCS_AUX)
339+
#define I915_BO_READONLY BIT(8)
340+
#define I915_TILING_QUIRK_BIT 9 /* unknown swizzling; do not release! */
341+
#define I915_BO_PROTECTED BIT(10)
340342
/**
341343
* @mem_flags - Mutable placement-related flags
342344
*

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static int i915_ttm_backup(struct i915_gem_apply_to_region *apply,
5050
container_of(bo->bdev, typeof(*i915), bdev);
5151
struct drm_i915_gem_object *backup;
5252
struct ttm_operation_ctx ctx = {};
53+
unsigned int flags;
5354
int err = 0;
5455

5556
if (bo->resource->mem_type == I915_PL_SYSTEM || obj->ttm.backup)
@@ -65,7 +66,22 @@ static int i915_ttm_backup(struct i915_gem_apply_to_region *apply,
6566
if (obj->flags & I915_BO_ALLOC_PM_VOLATILE)
6667
return 0;
6768

68-
backup = i915_gem_object_create_shmem(i915, obj->base.size);
69+
/*
70+
* It seems that we might have some framebuffers still pinned at this
71+
* stage, but for such objects we might also need to deal with the CCS
72+
* aux state. Make sure we force the save/restore of the CCS state,
73+
* otherwise we might observe display corruption, when returning from
74+
* suspend.
75+
*/
76+
flags = 0;
77+
if (i915_gem_object_needs_ccs_pages(obj)) {
78+
WARN_ON_ONCE(!i915_gem_object_is_framebuffer(obj));
79+
WARN_ON_ONCE(!pm_apply->allow_gpu);
80+
81+
flags = I915_BO_ALLOC_CCS_AUX;
82+
}
83+
backup = i915_gem_object_create_region(i915->mm.regions[INTEL_REGION_SMEM],
84+
obj->base.size, 0, flags);
6985
if (IS_ERR(backup))
7086
return PTR_ERR(backup);
7187

0 commit comments

Comments
 (0)