Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Copyright © 2019 Intel Corporation
0004  */
0005 
0006 #ifndef __I915_GEM_REGION_H__
0007 #define __I915_GEM_REGION_H__
0008 
0009 #include <linux/types.h>
0010 
0011 struct intel_memory_region;
0012 struct drm_i915_gem_object;
0013 struct sg_table;
0014 
0015 struct i915_gem_apply_to_region;
0016 
0017 #define I915_BO_INVALID_OFFSET ((resource_size_t)-1)
0018 
0019 /**
0020  * struct i915_gem_apply_to_region_ops - ops to use when iterating over all
0021  * region objects.
0022  */
0023 struct i915_gem_apply_to_region_ops {
0024     /**
0025      * process_obj - Process the current object
0026      * @apply: Embed this for private data.
0027      * @obj: The current object.
0028      *
0029      * Note that if this function is part of a ww transaction, and
0030      * if returns -EDEADLK for one of the objects, it may be
0031      * rerun for that same object in the same pass.
0032      */
0033     int (*process_obj)(struct i915_gem_apply_to_region *apply,
0034                struct drm_i915_gem_object *obj);
0035 };
0036 
0037 /**
0038  * struct i915_gem_apply_to_region - Argument to the struct
0039  * i915_gem_apply_to_region_ops functions.
0040  * @ops: The ops for the operation.
0041  * @ww: Locking context used for the transaction.
0042  * @interruptible: Whether to perform object locking interruptible.
0043  *
0044  * This structure is intended to be embedded in a private struct if needed
0045  */
0046 struct i915_gem_apply_to_region {
0047     const struct i915_gem_apply_to_region_ops *ops;
0048     struct i915_gem_ww_ctx *ww;
0049     u32 interruptible:1;
0050 };
0051 
0052 void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj,
0053                     struct intel_memory_region *mem);
0054 void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj);
0055 
0056 struct drm_i915_gem_object *
0057 i915_gem_object_create_region(struct intel_memory_region *mem,
0058                   resource_size_t size,
0059                   resource_size_t page_size,
0060                   unsigned int flags);
0061 struct drm_i915_gem_object *
0062 i915_gem_object_create_region_at(struct intel_memory_region *mem,
0063                  resource_size_t offset,
0064                  resource_size_t size,
0065                  unsigned int flags);
0066 
0067 int i915_gem_process_region(struct intel_memory_region *mr,
0068                 struct i915_gem_apply_to_region *apply);
0069 #endif