// SPDX-License-Identifier: MIT /* * Copyright © 2021 Intel Corporation */ #include <drm/ttm/ttm_placement.h> #include <drm/ttm/ttm_tt.h> #include "i915_drv.h" #include "intel_memory_region.h" #include "intel_region_ttm.h" #include "gem/i915_gem_region.h" #include "gem/i915_gem_ttm.h" #include "gem/i915_gem_ttm_move.h" #include "gem/i915_gem_ttm_pm.h" /** * i915_ttm_backup_free - Free any backup attached to this object * @obj: The object whose backup is to be freed. */ void i915_ttm_backup_free(struct drm_i915_gem_object *obj) { … } /** * struct i915_gem_ttm_pm_apply - Apply-to-region subclass for restore * @base: The i915_gem_apply_to_region we derive from. * @allow_gpu: Whether using the gpu blitter is allowed. * @backup_pinned: On backup, backup also pinned objects. */ struct i915_gem_ttm_pm_apply { … }; static int i915_ttm_backup(struct i915_gem_apply_to_region *apply, struct drm_i915_gem_object *obj) { … } static int i915_ttm_recover(struct i915_gem_apply_to_region *apply, struct drm_i915_gem_object *obj) { … } /** * i915_ttm_recover_region - Free the backup of all objects of a region * @mr: The memory region * * Checks all objects of a region if there is backup attached and if so * frees that backup. Typically this is called to recover after a partially * performed backup. */ void i915_ttm_recover_region(struct intel_memory_region *mr) { … } /** * i915_ttm_backup_region - Back up all objects of a region to smem. * @mr: The memory region * @flags: TTM backup flags * * Loops over all objects of a region and either evicts them if they are * evictable or backs them up using a backup object if they are pinned. * * Return: Zero on success. Negative error code on error. */ int i915_ttm_backup_region(struct intel_memory_region *mr, u32 flags) { … } static int i915_ttm_restore(struct i915_gem_apply_to_region *apply, struct drm_i915_gem_object *obj) { … } /** * i915_ttm_restore_region - Restore backed-up objects of a region from smem. * @mr: The memory region * @flags: TTM backup flags * * Loops over all objects of a region and if they are backed-up, restores * them from smem. * * Return: Zero on success. Negative error code on error. */ int i915_ttm_restore_region(struct intel_memory_region *mr, u32 flags) { … }