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 * @apply: Embed this for private data. 27 * @obj: The current object. 28 * 29 * Note that if this function is part of a ww transaction, and 30 * if returns -EDEADLK for one of the objects, it may be 31 * rerun for that same object in the same pass. 32 */ 33 int (*process_obj)(struct i915_gem_apply_to_region *apply, 34 struct drm_i915_gem_object *obj); 35 }; 36 37 /** 38 * struct i915_gem_apply_to_region - Argument to the struct 39 * i915_gem_apply_to_region_ops functions. 40 * @ops: The ops for the operation. 41 * @ww: Locking context used for the transaction. 42 * @interruptible: Whether to perform object locking interruptible. 43 * 44 * This structure is intended to be embedded in a private struct if needed 45 */ 46 struct i915_gem_apply_to_region { 47 const struct i915_gem_apply_to_region_ops *ops; 48 struct i915_gem_ww_ctx *ww; 49 u32 interruptible:1; 50 }; 51 52 void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj, 53 struct intel_memory_region *mem); 54 void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj); 55 56 struct drm_i915_gem_object * 57 i915_gem_object_create_region(struct intel_memory_region *mem, 58 resource_size_t size, 59 resource_size_t page_size, 60 unsigned int flags); 61 struct drm_i915_gem_object * 62 i915_gem_object_create_region_at(struct intel_memory_region *mem, 63 resource_size_t offset, 64 resource_size_t size, 65 unsigned int flags); 66 67 int i915_gem_process_region(struct intel_memory_region *mr, 68 struct i915_gem_apply_to_region *apply); 69 #endif 70