1232a6ebaSMatthew Auld /* SPDX-License-Identifier: MIT */ 2232a6ebaSMatthew Auld /* 3232a6ebaSMatthew Auld * Copyright © 2019 Intel Corporation 4232a6ebaSMatthew Auld */ 5232a6ebaSMatthew Auld 6232a6ebaSMatthew Auld #ifndef __I915_GEM_REGION_H__ 7232a6ebaSMatthew Auld #define __I915_GEM_REGION_H__ 8232a6ebaSMatthew Auld 9232a6ebaSMatthew Auld #include <linux/types.h> 10232a6ebaSMatthew Auld 11232a6ebaSMatthew Auld struct intel_memory_region; 12232a6ebaSMatthew Auld struct drm_i915_gem_object; 13232a6ebaSMatthew Auld struct sg_table; 14232a6ebaSMatthew Auld 15d80ee88eSThomas Hellström struct i915_gem_apply_to_region; 16d80ee88eSThomas Hellström 179b78b5daSMatthew Auld #define I915_BO_INVALID_OFFSET ((resource_size_t)-1) 189b78b5daSMatthew Auld 19d80ee88eSThomas Hellström /** 20d80ee88eSThomas Hellström * struct i915_gem_apply_to_region_ops - ops to use when iterating over all 21d80ee88eSThomas Hellström * region objects. 22d80ee88eSThomas Hellström */ 23d80ee88eSThomas Hellström struct i915_gem_apply_to_region_ops { 24d80ee88eSThomas Hellström /** 25*08272a5aSJani Nikula * @process_obj: Process the current object 26d80ee88eSThomas Hellström * 27d80ee88eSThomas Hellström * Note that if this function is part of a ww transaction, and 28d80ee88eSThomas Hellström * if returns -EDEADLK for one of the objects, it may be 29d80ee88eSThomas Hellström * rerun for that same object in the same pass. 30d80ee88eSThomas Hellström */ 31d80ee88eSThomas Hellström int (*process_obj)(struct i915_gem_apply_to_region *apply, 32d80ee88eSThomas Hellström struct drm_i915_gem_object *obj); 33d80ee88eSThomas Hellström }; 34d80ee88eSThomas Hellström 35d80ee88eSThomas Hellström /** 36d80ee88eSThomas Hellström * struct i915_gem_apply_to_region - Argument to the struct 37d80ee88eSThomas Hellström * i915_gem_apply_to_region_ops functions. 38d80ee88eSThomas Hellström * @ops: The ops for the operation. 39d80ee88eSThomas Hellström * @ww: Locking context used for the transaction. 40d80ee88eSThomas Hellström * @interruptible: Whether to perform object locking interruptible. 41d80ee88eSThomas Hellström * 42d80ee88eSThomas Hellström * This structure is intended to be embedded in a private struct if needed 43d80ee88eSThomas Hellström */ 44d80ee88eSThomas Hellström struct i915_gem_apply_to_region { 45d80ee88eSThomas Hellström const struct i915_gem_apply_to_region_ops *ops; 46d80ee88eSThomas Hellström struct i915_gem_ww_ctx *ww; 47d80ee88eSThomas Hellström u32 interruptible:1; 48d80ee88eSThomas Hellström }; 49d80ee88eSThomas Hellström 50232a6ebaSMatthew Auld void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj, 51c471748dSMaarten Lankhorst struct intel_memory_region *mem); 52232a6ebaSMatthew Auld void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj); 53232a6ebaSMatthew Auld 54232a6ebaSMatthew Auld struct drm_i915_gem_object * 55232a6ebaSMatthew Auld i915_gem_object_create_region(struct intel_memory_region *mem, 56232a6ebaSMatthew Auld resource_size_t size, 57d22632c8SMatthew Auld resource_size_t page_size, 58232a6ebaSMatthew Auld unsigned int flags); 599b78b5daSMatthew Auld struct drm_i915_gem_object * 609b78b5daSMatthew Auld i915_gem_object_create_region_at(struct intel_memory_region *mem, 619b78b5daSMatthew Auld resource_size_t offset, 629b78b5daSMatthew Auld resource_size_t size, 639b78b5daSMatthew Auld unsigned int flags); 64232a6ebaSMatthew Auld 65d80ee88eSThomas Hellström int i915_gem_process_region(struct intel_memory_region *mr, 66d80ee88eSThomas Hellström struct i915_gem_apply_to_region *apply); 67232a6ebaSMatthew Auld #endif 68