drm/i915/ttm: remove node usage in our naming
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / gem / i915_gem_object_types.h
index 8e485cb..3a2d9ec 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/mmu_notifier.h>
 
 #include <drm/drm_gem.h>
+#include <drm/ttm/ttm_bo_api.h>
 #include <uapi/drm/i915_drm.h>
 
 #include "i915_active.h"
@@ -60,10 +61,26 @@ struct drm_i915_gem_object_ops {
                     const struct drm_i915_gem_pread *arg);
        int (*pwrite)(struct drm_i915_gem_object *obj,
                      const struct drm_i915_gem_pwrite *arg);
+       u64 (*mmap_offset)(struct drm_i915_gem_object *obj);
 
        int (*dmabuf_export)(struct drm_i915_gem_object *obj);
+
+       /**
+        * adjust_lru - notify that the madvise value was updated
+        * @obj: The gem object
+        *
+        * The madvise value may have been updated, or object was recently
+        * referenced so act accordingly (Perhaps changing an LRU list etc).
+        */
+       void (*adjust_lru)(struct drm_i915_gem_object *obj);
+
+       /**
+        * delayed_free - Override the default delayed free implementation
+        */
+       void (*delayed_free)(struct drm_i915_gem_object *obj);
        void (*release)(struct drm_i915_gem_object *obj);
 
+       const struct vm_operations_struct *mmap_ops;
        const char *name; /* friendly name for debug, e.g. lockdep classes */
 };
 
@@ -99,7 +116,16 @@ struct i915_gem_object_page_iter {
 };
 
 struct drm_i915_gem_object {
-       struct drm_gem_object base;
+       /*
+        * We might have reason to revisit the below since it wastes
+        * a lot of space for non-ttm gem objects.
+        * In any case, always use the accessors for the ttm_buffer_object
+        * when accessing it.
+        */
+       union {
+               struct drm_gem_object base;
+               struct ttm_buffer_object __do_not_access;
+       };
 
        const struct drm_i915_gem_object_ops *ops;
 
@@ -149,6 +175,10 @@ struct drm_i915_gem_object {
         * when i915_gem_ww_ctx_backoff() or i915_gem_ww_ctx_fini() are called.
         */
        struct list_head obj_link;
+       /**
+        * @shared_resv_from: The object shares the resv from this vm.
+        */
+       struct i915_address_space *shares_resv_from;
 
        union {
                struct rcu_head rcu;
@@ -172,11 +202,15 @@ struct drm_i915_gem_object {
 #define I915_BO_ALLOC_CONTIGUOUS BIT(0)
 #define I915_BO_ALLOC_VOLATILE   BIT(1)
 #define I915_BO_ALLOC_STRUCT_PAGE BIT(2)
+#define I915_BO_ALLOC_CPU_CLEAR  BIT(3)
+#define I915_BO_ALLOC_USER       BIT(4)
 #define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS | \
                             I915_BO_ALLOC_VOLATILE | \
-                            I915_BO_ALLOC_STRUCT_PAGE)
-#define I915_BO_READONLY         BIT(3)
-#define I915_TILING_QUIRK_BIT    4 /* unknown swizzling; do not release! */
+                            I915_BO_ALLOC_STRUCT_PAGE | \
+                            I915_BO_ALLOC_CPU_CLEAR | \
+                            I915_BO_ALLOC_USER)
+#define I915_BO_READONLY         BIT(5)
+#define I915_TILING_QUIRK_BIT    6 /* unknown swizzling; do not release! */
 
        /*
         * Is the object to be mapped as read-only to the GPU
@@ -219,14 +253,23 @@ struct drm_i915_gem_object {
                atomic_t pages_pin_count;
                atomic_t shrink_pin;
 
+               /**
+                * Priority list of potential placements for this object.
+                */
+               struct intel_memory_region **placements;
+               int n_placements;
+
                /**
                 * Memory region for this object.
                 */
                struct intel_memory_region *region;
+
                /**
-                * List of memory region blocks allocated for this object.
+                * Memory manager resource allocated for this object. Only
+                * needed for the mock region.
                 */
-               struct list_head blocks;
+               struct ttm_resource *res;
+
                /**
                 * Element within memory_region->objects or region->purgeable
                 * if the object is marked as DONTNEED. Access is protected by
@@ -286,6 +329,12 @@ struct drm_i915_gem_object {
                bool dirty:1;
        } mm;
 
+       struct {
+               struct sg_table *cached_io_st;
+               struct i915_gem_object_page_iter get_io_page;
+               bool created:1;
+       } ttm;
+
        /** Record of address bit 17 of each page at last unbind. */
        unsigned long *bit_17;