1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2019 Intel Corporation 4 */ 5 6 #ifndef __I915_GEM_REGION_H__ 7 #define __I915_GEM_REGION_H__ 8 9 #include <linux/types.h> 10 11 struct intel_memory_region; 12 struct drm_i915_gem_object; 13 struct sg_table; 14 15 struct i915_gem_apply_to_region; 16 17 #define I915_BO_INVALID_OFFSET ((resource_size_t)-1) 18 19 /** 20 * struct i915_gem_apply_to_region_ops - ops to use when iterating over all 21 * region objects. 22 */ 23 struct i915_gem_apply_to_region_ops { 24 /** 25 * @process_obj: Process the current object 26 * 27 * Note that if this function is part of a ww transaction, and 28 * if returns -EDEADLK for one of the objects, it may be 29 * rerun for that same object in the same pass. 30 */ 31 int (*process_obj)(struct i915_gem_apply_to_region *apply, 32 struct drm_i915_gem_object *obj); 33 }; 34 35 /** 36 * struct i915_gem_apply_to_region - Argument to the struct 37 * i915_gem_apply_to_region_ops functions. 38 * @ops: The ops for the operation. 39 * @ww: Locking context used for the transaction. 40 * @interruptible: Whether to perform object locking interruptible. 41 * 42 * This structure is intended to be embedded in a private struct if needed 43 */ 44 struct i915_gem_apply_to_region { 45 const struct i915_gem_apply_to_region_ops *ops; 46 struct i915_gem_ww_ctx *ww; 47 u32 interruptible:1; 48 }; 49 50 void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj, 51 struct intel_memory_region *mem); 52 void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj); 53 54 struct drm_i915_gem_object * 55 i915_gem_object_create_region(struct intel_memory_region *mem, 56 resource_size_t size, 57 resource_size_t page_size, 58 unsigned int flags); 59 struct drm_i915_gem_object * 60 i915_gem_object_create_region_at(struct intel_memory_region *mem, 61 resource_size_t offset, 62 resource_size_t size, 63 unsigned int flags); 64 65 int i915_gem_process_region(struct intel_memory_region *mr, 66 struct i915_gem_apply_to_region *apply); 67 #endif 68