diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-01-09 04:13:34 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-01-09 04:13:34 +0000 |
commit | 1bcb61ed6760b01a745fcfabc8b551df27f7a965 (patch) | |
tree | 1d80a4103083eb9b77cae8a3d5bf6bee20cf2337 /sys/dev | |
parent | cb26b4fae77a9d12b9937e2a9dcb2b00958c688e (diff) |
drm/i915/ttm: consider CCS for backup objects
From Matthew Auld
218f8fe668240f2ec95dcb000f61904dcdc83271 in linux-6.1.y/6.1.4
ad0fca2dceeab8fdd8e1135f4b4ef2dc46c2ead9 in mainline linux
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/i915/gem/i915_gem_object.c | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gem/i915_gem_object_types.h | 10 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/gem/i915_gem_ttm_pm.c | 18 |
3 files changed, 26 insertions, 5 deletions
diff --git a/sys/dev/pci/drm/i915/gem/i915_gem_object.c b/sys/dev/pci/drm/i915/gem/i915_gem_object.c index b690bbd8229..02ac8aa035e 100644 --- a/sys/dev/pci/drm/i915/gem/i915_gem_object.c +++ b/sys/dev/pci/drm/i915/gem/i915_gem_object.c @@ -777,6 +777,9 @@ bool i915_gem_object_needs_ccs_pages(struct drm_i915_gem_object *obj) if (!HAS_FLAT_CCS(to_i915(obj->base.dev))) return false; + if (obj->flags & I915_BO_ALLOC_CCS_AUX) + return true; + for (i = 0; i < obj->mm.n_placements; i++) { /* Compression is not allowed for the objects with smem placement */ if (obj->mm.placements[i]->type == INTEL_MEMORY_SYSTEM) diff --git a/sys/dev/pci/drm/i915/gem/i915_gem_object_types.h b/sys/dev/pci/drm/i915/gem/i915_gem_object_types.h index 1878eed6221..13effa97e62 100644 --- a/sys/dev/pci/drm/i915/gem/i915_gem_object_types.h +++ b/sys/dev/pci/drm/i915/gem/i915_gem_object_types.h @@ -327,16 +327,18 @@ struct drm_i915_gem_object { * dealing with userspace objects the CPU fault handler is free to ignore this. */ #define I915_BO_ALLOC_GPU_ONLY BIT(6) +#define I915_BO_ALLOC_CCS_AUX BIT(7) #define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS | \ I915_BO_ALLOC_VOLATILE | \ I915_BO_ALLOC_CPU_CLEAR | \ I915_BO_ALLOC_USER | \ I915_BO_ALLOC_PM_VOLATILE | \ I915_BO_ALLOC_PM_EARLY | \ - I915_BO_ALLOC_GPU_ONLY) -#define I915_BO_READONLY BIT(7) -#define I915_TILING_QUIRK_BIT 8 /* unknown swizzling; do not release! */ -#define I915_BO_PROTECTED BIT(9) + I915_BO_ALLOC_GPU_ONLY | \ + I915_BO_ALLOC_CCS_AUX) +#define I915_BO_READONLY BIT(8) +#define I915_TILING_QUIRK_BIT 9 /* unknown swizzling; do not release! */ +#define I915_BO_PROTECTED BIT(10) /** * @mem_flags - Mutable placement-related flags * diff --git a/sys/dev/pci/drm/i915/gem/i915_gem_ttm_pm.c b/sys/dev/pci/drm/i915/gem/i915_gem_ttm_pm.c index 07e49f22f2d..7e67742bc65 100644 --- a/sys/dev/pci/drm/i915/gem/i915_gem_ttm_pm.c +++ b/sys/dev/pci/drm/i915/gem/i915_gem_ttm_pm.c @@ -50,6 +50,7 @@ static int i915_ttm_backup(struct i915_gem_apply_to_region *apply, container_of(bo->bdev, typeof(*i915), bdev); struct drm_i915_gem_object *backup; struct ttm_operation_ctx ctx = {}; + unsigned int flags; int err = 0; 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, if (obj->flags & I915_BO_ALLOC_PM_VOLATILE) return 0; - backup = i915_gem_object_create_shmem(i915, obj->base.size); + /* + * It seems that we might have some framebuffers still pinned at this + * stage, but for such objects we might also need to deal with the CCS + * aux state. Make sure we force the save/restore of the CCS state, + * otherwise we might observe display corruption, when returning from + * suspend. + */ + flags = 0; + if (i915_gem_object_needs_ccs_pages(obj)) { + WARN_ON_ONCE(!i915_gem_object_is_framebuffer(obj)); + WARN_ON_ONCE(!pm_apply->allow_gpu); + + flags = I915_BO_ALLOC_CCS_AUX; + } + backup = i915_gem_object_create_region(i915->mm.regions[INTEL_REGION_SMEM], + obj->base.size, 0, flags); if (IS_ERR(backup)) return PTR_ERR(backup); |