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 /** 18 * struct i915_gem_apply_to_region_ops - ops to use when iterating over all 19 * region objects. 20 */ 21 struct i915_gem_apply_to_region_ops { 22 /** 23 * process_obj - Process the current object 24 * @apply: Embed this for private data. 25 * @obj: 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 60 int i915_gem_process_region(struct intel_memory_region *mr, 61 struct i915_gem_apply_to_region *apply); 62 #endif 63