| 1 | /* SPDX-License-Identifier: MIT */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Copyright © 2016 Intel Corporation | 
|---|
| 4 | */ | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef __I915_GEM_OBJECT_H__ | 
|---|
| 7 | #define __I915_GEM_OBJECT_H__ | 
|---|
| 8 |  | 
|---|
| 9 | #include <drm/drm_gem.h> | 
|---|
| 10 | #include <drm/drm_file.h> | 
|---|
| 11 | #include <drm/drm_device.h> | 
|---|
| 12 |  | 
|---|
| 13 | #include "intel_memory_region.h" | 
|---|
| 14 | #include "i915_gem_object_types.h" | 
|---|
| 15 | #include "i915_gem_gtt.h" | 
|---|
| 16 | #include "i915_gem_ww.h" | 
|---|
| 17 | #include "i915_vma_types.h" | 
|---|
| 18 |  | 
|---|
| 19 | enum intel_region_id; | 
|---|
| 20 | struct drm_scanout_buffer; | 
|---|
| 21 | struct intel_panic; | 
|---|
| 22 |  | 
|---|
| 23 | #define obj_to_i915(obj__) to_i915((obj__)->base.dev) | 
|---|
| 24 |  | 
|---|
| 25 | static inline bool i915_gem_object_size_2big(u64 size) | 
|---|
| 26 | { | 
|---|
| 27 | struct drm_i915_gem_object *obj; | 
|---|
| 28 |  | 
|---|
| 29 | if (overflows_type(size, obj->base.size)) | 
|---|
| 30 | return true; | 
|---|
| 31 |  | 
|---|
| 32 | return false; | 
|---|
| 33 | } | 
|---|
| 34 |  | 
|---|
| 35 | unsigned int i915_gem_get_pat_index(struct drm_i915_private *i915, | 
|---|
| 36 | enum i915_cache_level level); | 
|---|
| 37 | bool i915_gem_object_has_cache_level(const struct drm_i915_gem_object *obj, | 
|---|
| 38 | enum i915_cache_level lvl); | 
|---|
| 39 | void i915_gem_init__objects(struct drm_i915_private *i915); | 
|---|
| 40 |  | 
|---|
| 41 | void i915_objects_module_exit(void); | 
|---|
| 42 | int i915_objects_module_init(void); | 
|---|
| 43 |  | 
|---|
| 44 | struct drm_i915_gem_object *i915_gem_object_alloc(void); | 
|---|
| 45 | void i915_gem_object_free(struct drm_i915_gem_object *obj); | 
|---|
| 46 |  | 
|---|
| 47 | void i915_gem_object_init(struct drm_i915_gem_object *obj, | 
|---|
| 48 | const struct drm_i915_gem_object_ops *ops, | 
|---|
| 49 | struct lock_class_key *key, | 
|---|
| 50 | unsigned alloc_flags); | 
|---|
| 51 |  | 
|---|
| 52 | void __i915_gem_object_fini(struct drm_i915_gem_object *obj); | 
|---|
| 53 |  | 
|---|
| 54 | struct drm_i915_gem_object * | 
|---|
| 55 | i915_gem_object_create_shmem(struct drm_i915_private *i915, | 
|---|
| 56 | resource_size_t size); | 
|---|
| 57 | struct drm_i915_gem_object * | 
|---|
| 58 | i915_gem_object_create_shmem_from_data(struct drm_i915_private *i915, | 
|---|
| 59 | const void *data, resource_size_t size); | 
|---|
| 60 | struct drm_i915_gem_object * | 
|---|
| 61 | __i915_gem_object_create_user(struct drm_i915_private *i915, u64 size, | 
|---|
| 62 | struct intel_memory_region **placements, | 
|---|
| 63 | unsigned int n_placements); | 
|---|
| 64 |  | 
|---|
| 65 | extern const struct drm_i915_gem_object_ops i915_gem_shmem_ops; | 
|---|
| 66 |  | 
|---|
| 67 | void __i915_gem_object_release_shmem(struct drm_i915_gem_object *obj, | 
|---|
| 68 | struct sg_table *pages, | 
|---|
| 69 | bool needs_clflush); | 
|---|
| 70 |  | 
|---|
| 71 | int i915_gem_object_pwrite_phys(struct drm_i915_gem_object *obj, | 
|---|
| 72 | const struct drm_i915_gem_pwrite *args); | 
|---|
| 73 | int i915_gem_object_pread_phys(struct drm_i915_gem_object *obj, | 
|---|
| 74 | const struct drm_i915_gem_pread *args); | 
|---|
| 75 |  | 
|---|
| 76 | int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align); | 
|---|
| 77 | void i915_gem_object_put_pages_shmem(struct drm_i915_gem_object *obj, | 
|---|
| 78 | struct sg_table *pages); | 
|---|
| 79 | void i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj, | 
|---|
| 80 | struct sg_table *pages); | 
|---|
| 81 |  | 
|---|
| 82 | void i915_gem_flush_free_objects(struct drm_i915_private *i915); | 
|---|
| 83 |  | 
|---|
| 84 | struct sg_table * | 
|---|
| 85 | __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj); | 
|---|
| 86 |  | 
|---|
| 87 | /** | 
|---|
| 88 | * i915_gem_object_lookup_rcu - look up a temporary GEM object from its handle | 
|---|
| 89 | * @file: DRM file private date | 
|---|
| 90 | * @handle: userspace handle | 
|---|
| 91 | * | 
|---|
| 92 | * Returns: | 
|---|
| 93 | * A pointer to the object named by the handle if such exists on @filp, NULL | 
|---|
| 94 | * otherwise. This object is only valid whilst under the RCU read lock, and | 
|---|
| 95 | * note carefully the object may be in the process of being destroyed. | 
|---|
| 96 | */ | 
|---|
| 97 | static inline struct drm_i915_gem_object * | 
|---|
| 98 | i915_gem_object_lookup_rcu(struct drm_file *file, u32 handle) | 
|---|
| 99 | { | 
|---|
| 100 | #ifdef CONFIG_LOCKDEP | 
|---|
| 101 | WARN_ON(debug_locks && !lock_is_held(&rcu_lock_map)); | 
|---|
| 102 | #endif | 
|---|
| 103 | return idr_find(&file->object_idr, id: handle); | 
|---|
| 104 | } | 
|---|
| 105 |  | 
|---|
| 106 | static inline struct drm_i915_gem_object * | 
|---|
| 107 | i915_gem_object_get_rcu(struct drm_i915_gem_object *obj) | 
|---|
| 108 | { | 
|---|
| 109 | if (obj && !kref_get_unless_zero(kref: &obj->base.refcount)) | 
|---|
| 110 | obj = NULL; | 
|---|
| 111 |  | 
|---|
| 112 | return obj; | 
|---|
| 113 | } | 
|---|
| 114 |  | 
|---|
| 115 | static inline struct drm_i915_gem_object * | 
|---|
| 116 | i915_gem_object_lookup(struct drm_file *file, u32 handle) | 
|---|
| 117 | { | 
|---|
| 118 | struct drm_i915_gem_object *obj; | 
|---|
| 119 |  | 
|---|
| 120 | rcu_read_lock(); | 
|---|
| 121 | obj = i915_gem_object_lookup_rcu(file, handle); | 
|---|
| 122 | obj = i915_gem_object_get_rcu(obj); | 
|---|
| 123 | rcu_read_unlock(); | 
|---|
| 124 |  | 
|---|
| 125 | return obj; | 
|---|
| 126 | } | 
|---|
| 127 |  | 
|---|
| 128 | __deprecated | 
|---|
| 129 | struct drm_gem_object * | 
|---|
| 130 | drm_gem_object_lookup(struct drm_file *file, u32 handle); | 
|---|
| 131 |  | 
|---|
| 132 | __attribute__((nonnull)) | 
|---|
| 133 | static inline struct drm_i915_gem_object * | 
|---|
| 134 | i915_gem_object_get(struct drm_i915_gem_object *obj) | 
|---|
| 135 | { | 
|---|
| 136 | drm_gem_object_get(obj: &obj->base); | 
|---|
| 137 | return obj; | 
|---|
| 138 | } | 
|---|
| 139 |  | 
|---|
| 140 | __attribute__((nonnull)) | 
|---|
| 141 | static inline void | 
|---|
| 142 | i915_gem_object_put(struct drm_i915_gem_object *obj) | 
|---|
| 143 | { | 
|---|
| 144 | __drm_gem_object_put(obj: &obj->base); | 
|---|
| 145 | } | 
|---|
| 146 |  | 
|---|
| 147 | #define assert_object_held(obj) dma_resv_assert_held((obj)->base.resv) | 
|---|
| 148 |  | 
|---|
| 149 | /* | 
|---|
| 150 | * If more than one potential simultaneous locker, assert held. | 
|---|
| 151 | */ | 
|---|
| 152 | static inline void assert_object_held_shared(const struct drm_i915_gem_object *obj) | 
|---|
| 153 | { | 
|---|
| 154 | /* | 
|---|
| 155 | * Note mm list lookup is protected by | 
|---|
| 156 | * kref_get_unless_zero(). | 
|---|
| 157 | */ | 
|---|
| 158 | if (IS_ENABLED(CONFIG_LOCKDEP) && | 
|---|
| 159 | kref_read(kref: &obj->base.refcount) > 0) | 
|---|
| 160 | assert_object_held(obj); | 
|---|
| 161 | } | 
|---|
| 162 |  | 
|---|
| 163 | static inline int __i915_gem_object_lock(struct drm_i915_gem_object *obj, | 
|---|
| 164 | struct i915_gem_ww_ctx *ww, | 
|---|
| 165 | bool intr) | 
|---|
| 166 | { | 
|---|
| 167 | int ret; | 
|---|
| 168 |  | 
|---|
| 169 | if (intr) | 
|---|
| 170 | ret = dma_resv_lock_interruptible(obj: obj->base.resv, ctx: ww ? &ww->ctx : NULL); | 
|---|
| 171 | else | 
|---|
| 172 | ret = dma_resv_lock(obj: obj->base.resv, ctx: ww ? &ww->ctx : NULL); | 
|---|
| 173 |  | 
|---|
| 174 | if (!ret && ww) { | 
|---|
| 175 | i915_gem_object_get(obj); | 
|---|
| 176 | list_add_tail(new: &obj->obj_link, head: &ww->obj_list); | 
|---|
| 177 | } | 
|---|
| 178 | if (ret == -EALREADY) | 
|---|
| 179 | ret = 0; | 
|---|
| 180 |  | 
|---|
| 181 | if (ret == -EDEADLK) { | 
|---|
| 182 | i915_gem_object_get(obj); | 
|---|
| 183 | ww->contended = obj; | 
|---|
| 184 | } | 
|---|
| 185 |  | 
|---|
| 186 | return ret; | 
|---|
| 187 | } | 
|---|
| 188 |  | 
|---|
| 189 | static inline int i915_gem_object_lock(struct drm_i915_gem_object *obj, | 
|---|
| 190 | struct i915_gem_ww_ctx *ww) | 
|---|
| 191 | { | 
|---|
| 192 | return __i915_gem_object_lock(obj, ww, intr: ww && ww->intr); | 
|---|
| 193 | } | 
|---|
| 194 |  | 
|---|
| 195 | static inline int i915_gem_object_lock_interruptible(struct drm_i915_gem_object *obj, | 
|---|
| 196 | struct i915_gem_ww_ctx *ww) | 
|---|
| 197 | { | 
|---|
| 198 | WARN_ON(ww && !ww->intr); | 
|---|
| 199 | return __i915_gem_object_lock(obj, ww, intr: true); | 
|---|
| 200 | } | 
|---|
| 201 |  | 
|---|
| 202 | static inline bool i915_gem_object_trylock(struct drm_i915_gem_object *obj, | 
|---|
| 203 | struct i915_gem_ww_ctx *ww) | 
|---|
| 204 | { | 
|---|
| 205 | if (!ww) | 
|---|
| 206 | return dma_resv_trylock(obj: obj->base.resv); | 
|---|
| 207 | else | 
|---|
| 208 | return ww_mutex_trylock(lock: &obj->base.resv->lock, ctx: &ww->ctx); | 
|---|
| 209 | } | 
|---|
| 210 |  | 
|---|
| 211 | static inline void i915_gem_object_unlock(struct drm_i915_gem_object *obj) | 
|---|
| 212 | { | 
|---|
| 213 | if (obj->ops->adjust_lru) | 
|---|
| 214 | obj->ops->adjust_lru(obj); | 
|---|
| 215 |  | 
|---|
| 216 | dma_resv_unlock(obj: obj->base.resv); | 
|---|
| 217 | } | 
|---|
| 218 |  | 
|---|
| 219 | static inline void | 
|---|
| 220 | i915_gem_object_set_readonly(struct drm_i915_gem_object *obj) | 
|---|
| 221 | { | 
|---|
| 222 | obj->flags |= I915_BO_READONLY; | 
|---|
| 223 | } | 
|---|
| 224 |  | 
|---|
| 225 | static inline bool | 
|---|
| 226 | i915_gem_object_is_readonly(const struct drm_i915_gem_object *obj) | 
|---|
| 227 | { | 
|---|
| 228 | return obj->flags & I915_BO_READONLY; | 
|---|
| 229 | } | 
|---|
| 230 |  | 
|---|
| 231 | static inline bool | 
|---|
| 232 | i915_gem_object_is_contiguous(const struct drm_i915_gem_object *obj) | 
|---|
| 233 | { | 
|---|
| 234 | return obj->flags & I915_BO_ALLOC_CONTIGUOUS; | 
|---|
| 235 | } | 
|---|
| 236 |  | 
|---|
| 237 | static inline bool | 
|---|
| 238 | i915_gem_object_is_volatile(const struct drm_i915_gem_object *obj) | 
|---|
| 239 | { | 
|---|
| 240 | return obj->flags & I915_BO_ALLOC_VOLATILE; | 
|---|
| 241 | } | 
|---|
| 242 |  | 
|---|
| 243 | static inline void | 
|---|
| 244 | i915_gem_object_set_volatile(struct drm_i915_gem_object *obj) | 
|---|
| 245 | { | 
|---|
| 246 | obj->flags |= I915_BO_ALLOC_VOLATILE; | 
|---|
| 247 | } | 
|---|
| 248 |  | 
|---|
| 249 | static inline bool | 
|---|
| 250 | i915_gem_object_has_tiling_quirk(struct drm_i915_gem_object *obj) | 
|---|
| 251 | { | 
|---|
| 252 | return test_bit(I915_TILING_QUIRK_BIT, &obj->flags); | 
|---|
| 253 | } | 
|---|
| 254 |  | 
|---|
| 255 | static inline void | 
|---|
| 256 | i915_gem_object_set_tiling_quirk(struct drm_i915_gem_object *obj) | 
|---|
| 257 | { | 
|---|
| 258 | set_bit(I915_TILING_QUIRK_BIT, addr: &obj->flags); | 
|---|
| 259 | } | 
|---|
| 260 |  | 
|---|
| 261 | static inline void | 
|---|
| 262 | i915_gem_object_clear_tiling_quirk(struct drm_i915_gem_object *obj) | 
|---|
| 263 | { | 
|---|
| 264 | clear_bit(I915_TILING_QUIRK_BIT, addr: &obj->flags); | 
|---|
| 265 | } | 
|---|
| 266 |  | 
|---|
| 267 | static inline bool | 
|---|
| 268 | i915_gem_object_is_protected(const struct drm_i915_gem_object *obj) | 
|---|
| 269 | { | 
|---|
| 270 | return obj->flags & I915_BO_PROTECTED; | 
|---|
| 271 | } | 
|---|
| 272 |  | 
|---|
| 273 | static inline bool | 
|---|
| 274 | i915_gem_object_type_has(const struct drm_i915_gem_object *obj, | 
|---|
| 275 | unsigned long flags) | 
|---|
| 276 | { | 
|---|
| 277 | return obj->ops->flags & flags; | 
|---|
| 278 | } | 
|---|
| 279 |  | 
|---|
| 280 | bool i915_gem_object_has_struct_page(const struct drm_i915_gem_object *obj); | 
|---|
| 281 |  | 
|---|
| 282 | bool i915_gem_object_has_iomem(const struct drm_i915_gem_object *obj); | 
|---|
| 283 |  | 
|---|
| 284 | static inline bool | 
|---|
| 285 | i915_gem_object_is_shrinkable(const struct drm_i915_gem_object *obj) | 
|---|
| 286 | { | 
|---|
| 287 | return i915_gem_object_type_has(obj, I915_GEM_OBJECT_IS_SHRINKABLE); | 
|---|
| 288 | } | 
|---|
| 289 |  | 
|---|
| 290 | static inline bool | 
|---|
| 291 | i915_gem_object_has_self_managed_shrink_list(const struct drm_i915_gem_object *obj) | 
|---|
| 292 | { | 
|---|
| 293 | return i915_gem_object_type_has(obj, I915_GEM_OBJECT_SELF_MANAGED_SHRINK_LIST); | 
|---|
| 294 | } | 
|---|
| 295 |  | 
|---|
| 296 | static inline bool | 
|---|
| 297 | i915_gem_object_is_proxy(const struct drm_i915_gem_object *obj) | 
|---|
| 298 | { | 
|---|
| 299 | return i915_gem_object_type_has(obj, I915_GEM_OBJECT_IS_PROXY); | 
|---|
| 300 | } | 
|---|
| 301 |  | 
|---|
| 302 | static inline bool | 
|---|
| 303 | i915_gem_object_never_mmap(const struct drm_i915_gem_object *obj) | 
|---|
| 304 | { | 
|---|
| 305 | return i915_gem_object_type_has(obj, I915_GEM_OBJECT_NO_MMAP); | 
|---|
| 306 | } | 
|---|
| 307 |  | 
|---|
| 308 | static inline bool | 
|---|
| 309 | i915_gem_object_is_framebuffer(const struct drm_i915_gem_object *obj) | 
|---|
| 310 | { | 
|---|
| 311 | return READ_ONCE(obj->frontbuffer) || obj->is_dpt; | 
|---|
| 312 | } | 
|---|
| 313 |  | 
|---|
| 314 | static inline unsigned int | 
|---|
| 315 | i915_gem_object_get_tiling(const struct drm_i915_gem_object *obj) | 
|---|
| 316 | { | 
|---|
| 317 | return obj->tiling_and_stride & TILING_MASK; | 
|---|
| 318 | } | 
|---|
| 319 |  | 
|---|
| 320 | static inline bool | 
|---|
| 321 | i915_gem_object_is_tiled(const struct drm_i915_gem_object *obj) | 
|---|
| 322 | { | 
|---|
| 323 | return i915_gem_object_get_tiling(obj) != I915_TILING_NONE; | 
|---|
| 324 | } | 
|---|
| 325 |  | 
|---|
| 326 | static inline unsigned int | 
|---|
| 327 | i915_gem_object_get_stride(const struct drm_i915_gem_object *obj) | 
|---|
| 328 | { | 
|---|
| 329 | return obj->tiling_and_stride & STRIDE_MASK; | 
|---|
| 330 | } | 
|---|
| 331 |  | 
|---|
| 332 | static inline unsigned int | 
|---|
| 333 | i915_gem_tile_height(unsigned int tiling) | 
|---|
| 334 | { | 
|---|
| 335 | GEM_BUG_ON(!tiling); | 
|---|
| 336 | return tiling == I915_TILING_Y ? 32 : 8; | 
|---|
| 337 | } | 
|---|
| 338 |  | 
|---|
| 339 | static inline unsigned int | 
|---|
| 340 | i915_gem_object_get_tile_height(const struct drm_i915_gem_object *obj) | 
|---|
| 341 | { | 
|---|
| 342 | return i915_gem_tile_height(tiling: i915_gem_object_get_tiling(obj)); | 
|---|
| 343 | } | 
|---|
| 344 |  | 
|---|
| 345 | static inline unsigned int | 
|---|
| 346 | i915_gem_object_get_tile_row_size(const struct drm_i915_gem_object *obj) | 
|---|
| 347 | { | 
|---|
| 348 | return (i915_gem_object_get_stride(obj) * | 
|---|
| 349 | i915_gem_object_get_tile_height(obj)); | 
|---|
| 350 | } | 
|---|
| 351 |  | 
|---|
| 352 | int i915_gem_object_set_tiling(struct drm_i915_gem_object *obj, | 
|---|
| 353 | unsigned int tiling, unsigned int stride); | 
|---|
| 354 |  | 
|---|
| 355 | /** | 
|---|
| 356 | * __i915_gem_object_page_iter_get_sg - helper to find the target scatterlist | 
|---|
| 357 | * pointer and the target page position using pgoff_t n input argument and | 
|---|
| 358 | * i915_gem_object_page_iter | 
|---|
| 359 | * @obj: i915 GEM buffer object | 
|---|
| 360 | * @iter: i915 GEM buffer object page iterator | 
|---|
| 361 | * @n: page offset | 
|---|
| 362 | * @offset: searched physical offset, | 
|---|
| 363 | *          it will be used for returning physical page offset value | 
|---|
| 364 | * | 
|---|
| 365 | * Context: Takes and releases the mutex lock of the i915_gem_object_page_iter. | 
|---|
| 366 | *          Takes and releases the RCU lock to search the radix_tree of | 
|---|
| 367 | *          i915_gem_object_page_iter. | 
|---|
| 368 | * | 
|---|
| 369 | * Returns: | 
|---|
| 370 | * The target scatterlist pointer and the target page position. | 
|---|
| 371 | * | 
|---|
| 372 | * Recommended to use wrapper macro: i915_gem_object_page_iter_get_sg() | 
|---|
| 373 | */ | 
|---|
| 374 | struct scatterlist * | 
|---|
| 375 | __i915_gem_object_page_iter_get_sg(struct drm_i915_gem_object *obj, | 
|---|
| 376 | struct i915_gem_object_page_iter *iter, | 
|---|
| 377 | pgoff_t  n, | 
|---|
| 378 | unsigned int *offset); | 
|---|
| 379 |  | 
|---|
| 380 | /** | 
|---|
| 381 | * i915_gem_object_page_iter_get_sg - wrapper macro for | 
|---|
| 382 | * __i915_gem_object_page_iter_get_sg() | 
|---|
| 383 | * @obj: i915 GEM buffer object | 
|---|
| 384 | * @it: i915 GEM buffer object page iterator | 
|---|
| 385 | * @n: page offset | 
|---|
| 386 | * @offset: searched physical offset, | 
|---|
| 387 | *          it will be used for returning physical page offset value | 
|---|
| 388 | * | 
|---|
| 389 | * Context: Takes and releases the mutex lock of the i915_gem_object_page_iter. | 
|---|
| 390 | *          Takes and releases the RCU lock to search the radix_tree of | 
|---|
| 391 | *          i915_gem_object_page_iter. | 
|---|
| 392 | * | 
|---|
| 393 | * Returns: | 
|---|
| 394 | * The target scatterlist pointer and the target page position. | 
|---|
| 395 | * | 
|---|
| 396 | * In order to avoid the truncation of the input parameter, it checks the page | 
|---|
| 397 | * offset n's type from the input parameter before calling | 
|---|
| 398 | * __i915_gem_object_page_iter_get_sg(). | 
|---|
| 399 | */ | 
|---|
| 400 | #define i915_gem_object_page_iter_get_sg(obj, it, n, offset) ({	\ | 
|---|
| 401 | static_assert(castable_to_type(n, pgoff_t));		\ | 
|---|
| 402 | __i915_gem_object_page_iter_get_sg(obj, it, n, offset);	\ | 
|---|
| 403 | }) | 
|---|
| 404 |  | 
|---|
| 405 | /** | 
|---|
| 406 | * __i915_gem_object_get_sg - helper to find the target scatterlist | 
|---|
| 407 | * pointer and the target page position using pgoff_t n input argument and | 
|---|
| 408 | * drm_i915_gem_object. It uses an internal shmem scatterlist lookup function. | 
|---|
| 409 | * @obj: i915 GEM buffer object | 
|---|
| 410 | * @n: page offset | 
|---|
| 411 | * @offset: searched physical offset, | 
|---|
| 412 | *          it will be used for returning physical page offset value | 
|---|
| 413 | * | 
|---|
| 414 | * It uses drm_i915_gem_object's internal shmem scatterlist lookup function as | 
|---|
| 415 | * i915_gem_object_page_iter and calls __i915_gem_object_page_iter_get_sg(). | 
|---|
| 416 | * | 
|---|
| 417 | * Returns: | 
|---|
| 418 | * The target scatterlist pointer and the target page position. | 
|---|
| 419 | * | 
|---|
| 420 | * Recommended to use wrapper macro: i915_gem_object_get_sg() | 
|---|
| 421 | * See also __i915_gem_object_page_iter_get_sg() | 
|---|
| 422 | */ | 
|---|
| 423 | static inline struct scatterlist * | 
|---|
| 424 | __i915_gem_object_get_sg(struct drm_i915_gem_object *obj, pgoff_t n, | 
|---|
| 425 | unsigned int *offset) | 
|---|
| 426 | { | 
|---|
| 427 | return __i915_gem_object_page_iter_get_sg(obj, iter: &obj->mm.get_page, n, offset); | 
|---|
| 428 | } | 
|---|
| 429 |  | 
|---|
| 430 | /** | 
|---|
| 431 | * i915_gem_object_get_sg - wrapper macro for __i915_gem_object_get_sg() | 
|---|
| 432 | * @obj: i915 GEM buffer object | 
|---|
| 433 | * @n: page offset | 
|---|
| 434 | * @offset: searched physical offset, | 
|---|
| 435 | *          it will be used for returning physical page offset value | 
|---|
| 436 | * | 
|---|
| 437 | * Returns: | 
|---|
| 438 | * The target scatterlist pointer and the target page position. | 
|---|
| 439 | * | 
|---|
| 440 | * In order to avoid the truncation of the input parameter, it checks the page | 
|---|
| 441 | * offset n's type from the input parameter before calling | 
|---|
| 442 | * __i915_gem_object_get_sg(). | 
|---|
| 443 | * See also __i915_gem_object_page_iter_get_sg() | 
|---|
| 444 | */ | 
|---|
| 445 | #define i915_gem_object_get_sg(obj, n, offset) ({	\ | 
|---|
| 446 | static_assert(castable_to_type(n, pgoff_t));	\ | 
|---|
| 447 | __i915_gem_object_get_sg(obj, n, offset);	\ | 
|---|
| 448 | }) | 
|---|
| 449 |  | 
|---|
| 450 | /** | 
|---|
| 451 | * __i915_gem_object_get_sg_dma - helper to find the target scatterlist | 
|---|
| 452 | * pointer and the target page position using pgoff_t n input argument and | 
|---|
| 453 | * drm_i915_gem_object. It uses an internal DMA mapped scatterlist lookup function | 
|---|
| 454 | * @obj: i915 GEM buffer object | 
|---|
| 455 | * @n: page offset | 
|---|
| 456 | * @offset: searched physical offset, | 
|---|
| 457 | *          it will be used for returning physical page offset value | 
|---|
| 458 | * | 
|---|
| 459 | * It uses drm_i915_gem_object's internal DMA mapped scatterlist lookup function | 
|---|
| 460 | * as i915_gem_object_page_iter and calls __i915_gem_object_page_iter_get_sg(). | 
|---|
| 461 | * | 
|---|
| 462 | * Returns: | 
|---|
| 463 | * The target scatterlist pointer and the target page position. | 
|---|
| 464 | * | 
|---|
| 465 | * Recommended to use wrapper macro: i915_gem_object_get_sg_dma() | 
|---|
| 466 | * See also __i915_gem_object_page_iter_get_sg() | 
|---|
| 467 | */ | 
|---|
| 468 | static inline struct scatterlist * | 
|---|
| 469 | __i915_gem_object_get_sg_dma(struct drm_i915_gem_object *obj, pgoff_t n, | 
|---|
| 470 | unsigned int *offset) | 
|---|
| 471 | { | 
|---|
| 472 | return __i915_gem_object_page_iter_get_sg(obj, iter: &obj->mm.get_dma_page, n, offset); | 
|---|
| 473 | } | 
|---|
| 474 |  | 
|---|
| 475 | /** | 
|---|
| 476 | * i915_gem_object_get_sg_dma - wrapper macro for __i915_gem_object_get_sg_dma() | 
|---|
| 477 | * @obj: i915 GEM buffer object | 
|---|
| 478 | * @n: page offset | 
|---|
| 479 | * @offset: searched physical offset, | 
|---|
| 480 | *          it will be used for returning physical page offset value | 
|---|
| 481 | * | 
|---|
| 482 | * Returns: | 
|---|
| 483 | * The target scatterlist pointer and the target page position. | 
|---|
| 484 | * | 
|---|
| 485 | * In order to avoid the truncation of the input parameter, it checks the page | 
|---|
| 486 | * offset n's type from the input parameter before calling | 
|---|
| 487 | * __i915_gem_object_get_sg_dma(). | 
|---|
| 488 | * See also __i915_gem_object_page_iter_get_sg() | 
|---|
| 489 | */ | 
|---|
| 490 | #define i915_gem_object_get_sg_dma(obj, n, offset) ({	\ | 
|---|
| 491 | static_assert(castable_to_type(n, pgoff_t));	\ | 
|---|
| 492 | __i915_gem_object_get_sg_dma(obj, n, offset);	\ | 
|---|
| 493 | }) | 
|---|
| 494 |  | 
|---|
| 495 | /** | 
|---|
| 496 | * __i915_gem_object_get_page - helper to find the target page with a page offset | 
|---|
| 497 | * @obj: i915 GEM buffer object | 
|---|
| 498 | * @n: page offset | 
|---|
| 499 | * | 
|---|
| 500 | * It uses drm_i915_gem_object's internal shmem scatterlist lookup function as | 
|---|
| 501 | * i915_gem_object_page_iter and calls __i915_gem_object_page_iter_get_sg() | 
|---|
| 502 | * internally. | 
|---|
| 503 | * | 
|---|
| 504 | * Returns: | 
|---|
| 505 | * The target page pointer. | 
|---|
| 506 | * | 
|---|
| 507 | * Recommended to use wrapper macro: i915_gem_object_get_page() | 
|---|
| 508 | * See also __i915_gem_object_page_iter_get_sg() | 
|---|
| 509 | */ | 
|---|
| 510 | struct page * | 
|---|
| 511 | __i915_gem_object_get_page(struct drm_i915_gem_object *obj, pgoff_t n); | 
|---|
| 512 |  | 
|---|
| 513 | /** | 
|---|
| 514 | * i915_gem_object_get_page - wrapper macro for __i915_gem_object_get_page | 
|---|
| 515 | * @obj: i915 GEM buffer object | 
|---|
| 516 | * @n: page offset | 
|---|
| 517 | * | 
|---|
| 518 | * Returns: | 
|---|
| 519 | * The target page pointer. | 
|---|
| 520 | * | 
|---|
| 521 | * In order to avoid the truncation of the input parameter, it checks the page | 
|---|
| 522 | * offset n's type from the input parameter before calling | 
|---|
| 523 | * __i915_gem_object_get_page(). | 
|---|
| 524 | * See also __i915_gem_object_page_iter_get_sg() | 
|---|
| 525 | */ | 
|---|
| 526 | #define i915_gem_object_get_page(obj, n) ({		\ | 
|---|
| 527 | static_assert(castable_to_type(n, pgoff_t));	\ | 
|---|
| 528 | __i915_gem_object_get_page(obj, n);		\ | 
|---|
| 529 | }) | 
|---|
| 530 |  | 
|---|
| 531 | /** | 
|---|
| 532 | * __i915_gem_object_get_dirty_page - helper to find the target page with a page | 
|---|
| 533 | * offset | 
|---|
| 534 | * @obj: i915 GEM buffer object | 
|---|
| 535 | * @n: page offset | 
|---|
| 536 | * | 
|---|
| 537 | * It works like i915_gem_object_get_page(), but it marks the returned page dirty. | 
|---|
| 538 | * | 
|---|
| 539 | * Returns: | 
|---|
| 540 | * The target page pointer. | 
|---|
| 541 | * | 
|---|
| 542 | * Recommended to use wrapper macro: i915_gem_object_get_dirty_page() | 
|---|
| 543 | * See also __i915_gem_object_page_iter_get_sg() and __i915_gem_object_get_page() | 
|---|
| 544 | */ | 
|---|
| 545 | struct page * | 
|---|
| 546 | __i915_gem_object_get_dirty_page(struct drm_i915_gem_object *obj, pgoff_t n); | 
|---|
| 547 |  | 
|---|
| 548 | /** | 
|---|
| 549 | * i915_gem_object_get_dirty_page - wrapper macro for __i915_gem_object_get_dirty_page | 
|---|
| 550 | * @obj: i915 GEM buffer object | 
|---|
| 551 | * @n: page offset | 
|---|
| 552 | * | 
|---|
| 553 | * Returns: | 
|---|
| 554 | * The target page pointer. | 
|---|
| 555 | * | 
|---|
| 556 | * In order to avoid the truncation of the input parameter, it checks the page | 
|---|
| 557 | * offset n's type from the input parameter before calling | 
|---|
| 558 | * __i915_gem_object_get_dirty_page(). | 
|---|
| 559 | * See also __i915_gem_object_page_iter_get_sg() and __i915_gem_object_get_page() | 
|---|
| 560 | */ | 
|---|
| 561 | #define i915_gem_object_get_dirty_page(obj, n) ({	\ | 
|---|
| 562 | static_assert(castable_to_type(n, pgoff_t));	\ | 
|---|
| 563 | __i915_gem_object_get_dirty_page(obj, n);	\ | 
|---|
| 564 | }) | 
|---|
| 565 |  | 
|---|
| 566 | /** | 
|---|
| 567 | * __i915_gem_object_get_dma_address_len - helper to get bus addresses of | 
|---|
| 568 | * targeted DMA mapped scatterlist from i915 GEM buffer object and it's length | 
|---|
| 569 | * @obj: i915 GEM buffer object | 
|---|
| 570 | * @n: page offset | 
|---|
| 571 | * @len: DMA mapped scatterlist's DMA bus addresses length to return | 
|---|
| 572 | * | 
|---|
| 573 | * Returns: | 
|---|
| 574 | * Bus addresses of targeted DMA mapped scatterlist | 
|---|
| 575 | * | 
|---|
| 576 | * Recommended to use wrapper macro: i915_gem_object_get_dma_address_len() | 
|---|
| 577 | * See also __i915_gem_object_page_iter_get_sg() and __i915_gem_object_get_sg_dma() | 
|---|
| 578 | */ | 
|---|
| 579 | dma_addr_t | 
|---|
| 580 | __i915_gem_object_get_dma_address_len(struct drm_i915_gem_object *obj, pgoff_t n, | 
|---|
| 581 | unsigned int *len); | 
|---|
| 582 |  | 
|---|
| 583 | /** | 
|---|
| 584 | * i915_gem_object_get_dma_address_len - wrapper macro for | 
|---|
| 585 | * __i915_gem_object_get_dma_address_len | 
|---|
| 586 | * @obj: i915 GEM buffer object | 
|---|
| 587 | * @n: page offset | 
|---|
| 588 | * @len: DMA mapped scatterlist's DMA bus addresses length to return | 
|---|
| 589 | * | 
|---|
| 590 | * Returns: | 
|---|
| 591 | * Bus addresses of targeted DMA mapped scatterlist | 
|---|
| 592 | * | 
|---|
| 593 | * In order to avoid the truncation of the input parameter, it checks the page | 
|---|
| 594 | * offset n's type from the input parameter before calling | 
|---|
| 595 | * __i915_gem_object_get_dma_address_len(). | 
|---|
| 596 | * See also __i915_gem_object_page_iter_get_sg() and | 
|---|
| 597 | * __i915_gem_object_get_dma_address_len() | 
|---|
| 598 | */ | 
|---|
| 599 | #define i915_gem_object_get_dma_address_len(obj, n, len) ({	\ | 
|---|
| 600 | static_assert(castable_to_type(n, pgoff_t));		\ | 
|---|
| 601 | __i915_gem_object_get_dma_address_len(obj, n, len);	\ | 
|---|
| 602 | }) | 
|---|
| 603 |  | 
|---|
| 604 | /** | 
|---|
| 605 | * __i915_gem_object_get_dma_address - helper to get bus addresses of | 
|---|
| 606 | * targeted DMA mapped scatterlist from i915 GEM buffer object | 
|---|
| 607 | * @obj: i915 GEM buffer object | 
|---|
| 608 | * @n: page offset | 
|---|
| 609 | * | 
|---|
| 610 | * Returns: | 
|---|
| 611 | * Bus addresses of targeted DMA mapped scatterlis | 
|---|
| 612 | * | 
|---|
| 613 | * Recommended to use wrapper macro: i915_gem_object_get_dma_address() | 
|---|
| 614 | * See also __i915_gem_object_page_iter_get_sg() and __i915_gem_object_get_sg_dma() | 
|---|
| 615 | */ | 
|---|
| 616 | dma_addr_t | 
|---|
| 617 | __i915_gem_object_get_dma_address(struct drm_i915_gem_object *obj, pgoff_t n); | 
|---|
| 618 |  | 
|---|
| 619 | /** | 
|---|
| 620 | * i915_gem_object_get_dma_address - wrapper macro for | 
|---|
| 621 | * __i915_gem_object_get_dma_address | 
|---|
| 622 | * @obj: i915 GEM buffer object | 
|---|
| 623 | * @n: page offset | 
|---|
| 624 | * | 
|---|
| 625 | * Returns: | 
|---|
| 626 | * Bus addresses of targeted DMA mapped scatterlist | 
|---|
| 627 | * | 
|---|
| 628 | * In order to avoid the truncation of the input parameter, it checks the page | 
|---|
| 629 | * offset n's type from the input parameter before calling | 
|---|
| 630 | * __i915_gem_object_get_dma_address(). | 
|---|
| 631 | * See also __i915_gem_object_page_iter_get_sg() and | 
|---|
| 632 | * __i915_gem_object_get_dma_address() | 
|---|
| 633 | */ | 
|---|
| 634 | #define i915_gem_object_get_dma_address(obj, n) ({	\ | 
|---|
| 635 | static_assert(castable_to_type(n, pgoff_t));	\ | 
|---|
| 636 | __i915_gem_object_get_dma_address(obj, n);	\ | 
|---|
| 637 | }) | 
|---|
| 638 |  | 
|---|
| 639 | void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj, | 
|---|
| 640 | struct sg_table *pages); | 
|---|
| 641 |  | 
|---|
| 642 | int ____i915_gem_object_get_pages(struct drm_i915_gem_object *obj); | 
|---|
| 643 | int __i915_gem_object_get_pages(struct drm_i915_gem_object *obj); | 
|---|
| 644 |  | 
|---|
| 645 | static inline int __must_check | 
|---|
| 646 | i915_gem_object_pin_pages(struct drm_i915_gem_object *obj) | 
|---|
| 647 | { | 
|---|
| 648 | assert_object_held(obj); | 
|---|
| 649 |  | 
|---|
| 650 | if (atomic_inc_not_zero(v: &obj->mm.pages_pin_count)) | 
|---|
| 651 | return 0; | 
|---|
| 652 |  | 
|---|
| 653 | return __i915_gem_object_get_pages(obj); | 
|---|
| 654 | } | 
|---|
| 655 |  | 
|---|
| 656 | int i915_gem_object_pin_pages_unlocked(struct drm_i915_gem_object *obj); | 
|---|
| 657 |  | 
|---|
| 658 | static inline bool | 
|---|
| 659 | i915_gem_object_has_pages(struct drm_i915_gem_object *obj) | 
|---|
| 660 | { | 
|---|
| 661 | return !IS_ERR_OR_NULL(READ_ONCE(obj->mm.pages)); | 
|---|
| 662 | } | 
|---|
| 663 |  | 
|---|
| 664 | static inline void | 
|---|
| 665 | __i915_gem_object_pin_pages(struct drm_i915_gem_object *obj) | 
|---|
| 666 | { | 
|---|
| 667 | GEM_BUG_ON(!i915_gem_object_has_pages(obj)); | 
|---|
| 668 |  | 
|---|
| 669 | atomic_inc(v: &obj->mm.pages_pin_count); | 
|---|
| 670 | } | 
|---|
| 671 |  | 
|---|
| 672 | static inline bool | 
|---|
| 673 | i915_gem_object_has_pinned_pages(struct drm_i915_gem_object *obj) | 
|---|
| 674 | { | 
|---|
| 675 | return atomic_read(v: &obj->mm.pages_pin_count); | 
|---|
| 676 | } | 
|---|
| 677 |  | 
|---|
| 678 | static inline void | 
|---|
| 679 | __i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj) | 
|---|
| 680 | { | 
|---|
| 681 | GEM_BUG_ON(!i915_gem_object_has_pages(obj)); | 
|---|
| 682 | GEM_BUG_ON(!i915_gem_object_has_pinned_pages(obj)); | 
|---|
| 683 |  | 
|---|
| 684 | atomic_dec(v: &obj->mm.pages_pin_count); | 
|---|
| 685 | } | 
|---|
| 686 |  | 
|---|
| 687 | static inline void | 
|---|
| 688 | i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj) | 
|---|
| 689 | { | 
|---|
| 690 | __i915_gem_object_unpin_pages(obj); | 
|---|
| 691 | } | 
|---|
| 692 |  | 
|---|
| 693 | int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj); | 
|---|
| 694 | int i915_gem_object_truncate(struct drm_i915_gem_object *obj); | 
|---|
| 695 |  | 
|---|
| 696 | struct intel_panic *i915_gem_object_alloc_panic(void); | 
|---|
| 697 | int i915_gem_object_panic_setup(struct intel_panic *panic, struct drm_scanout_buffer *sb, | 
|---|
| 698 | struct drm_gem_object *_obj, bool panic_tiling); | 
|---|
| 699 | void i915_gem_object_panic_finish(struct intel_panic *panic); | 
|---|
| 700 |  | 
|---|
| 701 | /** | 
|---|
| 702 | * i915_gem_object_pin_map - return a contiguous mapping of the entire object | 
|---|
| 703 | * @obj: the object to map into kernel address space | 
|---|
| 704 | * @type: the type of mapping, used to select pgprot_t | 
|---|
| 705 | * | 
|---|
| 706 | * Calls i915_gem_object_pin_pages() to prevent reaping of the object's | 
|---|
| 707 | * pages and then returns a contiguous mapping of the backing storage into | 
|---|
| 708 | * the kernel address space. Based on the @type of mapping, the PTE will be | 
|---|
| 709 | * set to either WriteBack or WriteCombine (via pgprot_t). | 
|---|
| 710 | * | 
|---|
| 711 | * The caller is responsible for calling i915_gem_object_unpin_map() when the | 
|---|
| 712 | * mapping is no longer required. | 
|---|
| 713 | * | 
|---|
| 714 | * Returns the pointer through which to access the mapped object, or an | 
|---|
| 715 | * ERR_PTR() on error. | 
|---|
| 716 | */ | 
|---|
| 717 | void *__must_check i915_gem_object_pin_map(struct drm_i915_gem_object *obj, | 
|---|
| 718 | enum i915_map_type type); | 
|---|
| 719 |  | 
|---|
| 720 | void *__must_check i915_gem_object_pin_map_unlocked(struct drm_i915_gem_object *obj, | 
|---|
| 721 | enum i915_map_type type); | 
|---|
| 722 |  | 
|---|
| 723 | void __i915_gem_object_flush_map(struct drm_i915_gem_object *obj, | 
|---|
| 724 | unsigned long offset, | 
|---|
| 725 | unsigned long size); | 
|---|
| 726 | static inline void i915_gem_object_flush_map(struct drm_i915_gem_object *obj) | 
|---|
| 727 | { | 
|---|
| 728 | __i915_gem_object_flush_map(obj, offset: 0, size: obj->base.size); | 
|---|
| 729 | } | 
|---|
| 730 |  | 
|---|
| 731 | /** | 
|---|
| 732 | * i915_gem_object_unpin_map - releases an earlier mapping | 
|---|
| 733 | * @obj: the object to unmap | 
|---|
| 734 | * | 
|---|
| 735 | * After pinning the object and mapping its pages, once you are finished | 
|---|
| 736 | * with your access, call i915_gem_object_unpin_map() to release the pin | 
|---|
| 737 | * upon the mapping. Once the pin count reaches zero, that mapping may be | 
|---|
| 738 | * removed. | 
|---|
| 739 | */ | 
|---|
| 740 | static inline void i915_gem_object_unpin_map(struct drm_i915_gem_object *obj) | 
|---|
| 741 | { | 
|---|
| 742 | i915_gem_object_unpin_pages(obj); | 
|---|
| 743 | } | 
|---|
| 744 |  | 
|---|
| 745 | void __i915_gem_object_release_map(struct drm_i915_gem_object *obj); | 
|---|
| 746 |  | 
|---|
| 747 | int i915_gem_object_prepare_read(struct drm_i915_gem_object *obj, | 
|---|
| 748 | unsigned int *needs_clflush); | 
|---|
| 749 | int i915_gem_object_prepare_write(struct drm_i915_gem_object *obj, | 
|---|
| 750 | unsigned int *needs_clflush); | 
|---|
| 751 | #define CLFLUSH_BEFORE	BIT(0) | 
|---|
| 752 | #define CLFLUSH_AFTER	BIT(1) | 
|---|
| 753 | #define CLFLUSH_FLAGS	(CLFLUSH_BEFORE | CLFLUSH_AFTER) | 
|---|
| 754 |  | 
|---|
| 755 | static inline void | 
|---|
| 756 | i915_gem_object_finish_access(struct drm_i915_gem_object *obj) | 
|---|
| 757 | { | 
|---|
| 758 | i915_gem_object_unpin_pages(obj); | 
|---|
| 759 | } | 
|---|
| 760 |  | 
|---|
| 761 | int i915_gem_object_get_moving_fence(struct drm_i915_gem_object *obj, | 
|---|
| 762 | struct dma_fence **fence); | 
|---|
| 763 | int i915_gem_object_wait_moving_fence(struct drm_i915_gem_object *obj, | 
|---|
| 764 | bool intr); | 
|---|
| 765 | bool i915_gem_object_has_unknown_state(struct drm_i915_gem_object *obj); | 
|---|
| 766 |  | 
|---|
| 767 | void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj, | 
|---|
| 768 | unsigned int cache_level); | 
|---|
| 769 | void i915_gem_object_set_pat_index(struct drm_i915_gem_object *obj, | 
|---|
| 770 | unsigned int pat_index); | 
|---|
| 771 | bool i915_gem_object_can_bypass_llc(struct drm_i915_gem_object *obj); | 
|---|
| 772 | void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj); | 
|---|
| 773 | void i915_gem_object_flush_if_display_locked(struct drm_i915_gem_object *obj); | 
|---|
| 774 | bool i915_gem_cpu_write_needs_clflush(struct drm_i915_gem_object *obj); | 
|---|
| 775 |  | 
|---|
| 776 | int __must_check | 
|---|
| 777 | i915_gem_object_set_to_wc_domain(struct drm_i915_gem_object *obj, bool write); | 
|---|
| 778 | int __must_check | 
|---|
| 779 | i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write); | 
|---|
| 780 | int __must_check | 
|---|
| 781 | i915_gem_object_set_to_cpu_domain(struct drm_i915_gem_object *obj, bool write); | 
|---|
| 782 | struct i915_vma * __must_check | 
|---|
| 783 | i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, | 
|---|
| 784 | struct i915_gem_ww_ctx *ww, | 
|---|
| 785 | u32 alignment, unsigned int guard, | 
|---|
| 786 | const struct i915_gtt_view *view, | 
|---|
| 787 | unsigned int flags); | 
|---|
| 788 |  | 
|---|
| 789 | void i915_gem_object_make_unshrinkable(struct drm_i915_gem_object *obj); | 
|---|
| 790 | void i915_gem_object_make_shrinkable(struct drm_i915_gem_object *obj); | 
|---|
| 791 | void __i915_gem_object_make_shrinkable(struct drm_i915_gem_object *obj); | 
|---|
| 792 | void __i915_gem_object_make_purgeable(struct drm_i915_gem_object *obj); | 
|---|
| 793 | void i915_gem_object_make_purgeable(struct drm_i915_gem_object *obj); | 
|---|
| 794 |  | 
|---|
| 795 | static inline void __start_cpu_write(struct drm_i915_gem_object *obj) | 
|---|
| 796 | { | 
|---|
| 797 | obj->read_domains = I915_GEM_DOMAIN_CPU; | 
|---|
| 798 | obj->write_domain = I915_GEM_DOMAIN_CPU; | 
|---|
| 799 | if (i915_gem_cpu_write_needs_clflush(obj)) | 
|---|
| 800 | obj->cache_dirty = true; | 
|---|
| 801 | } | 
|---|
| 802 |  | 
|---|
| 803 | void i915_gem_fence_wait_priority(struct dma_fence *fence, | 
|---|
| 804 | const struct i915_sched_attr *attr); | 
|---|
| 805 |  | 
|---|
| 806 | int i915_gem_object_wait(struct drm_i915_gem_object *obj, | 
|---|
| 807 | unsigned int flags, | 
|---|
| 808 | long timeout); | 
|---|
| 809 | int i915_gem_object_wait_priority(struct drm_i915_gem_object *obj, | 
|---|
| 810 | unsigned int flags, | 
|---|
| 811 | const struct i915_sched_attr *attr); | 
|---|
| 812 |  | 
|---|
| 813 | int i915_gem_object_read_from_page(struct drm_i915_gem_object *obj, u64 offset, void *dst, int size); | 
|---|
| 814 |  | 
|---|
| 815 | bool i915_gem_object_is_shmem(const struct drm_i915_gem_object *obj); | 
|---|
| 816 |  | 
|---|
| 817 | void __i915_gem_free_object_rcu(struct rcu_head *head); | 
|---|
| 818 |  | 
|---|
| 819 | void __i915_gem_object_pages_fini(struct drm_i915_gem_object *obj); | 
|---|
| 820 |  | 
|---|
| 821 | void __i915_gem_free_object(struct drm_i915_gem_object *obj); | 
|---|
| 822 |  | 
|---|
| 823 | bool i915_gem_object_evictable(struct drm_i915_gem_object *obj); | 
|---|
| 824 |  | 
|---|
| 825 | bool i915_gem_object_migratable(struct drm_i915_gem_object *obj); | 
|---|
| 826 |  | 
|---|
| 827 | int i915_gem_object_migrate(struct drm_i915_gem_object *obj, | 
|---|
| 828 | struct i915_gem_ww_ctx *ww, | 
|---|
| 829 | enum intel_region_id id); | 
|---|
| 830 | int __i915_gem_object_migrate(struct drm_i915_gem_object *obj, | 
|---|
| 831 | struct i915_gem_ww_ctx *ww, | 
|---|
| 832 | enum intel_region_id id, | 
|---|
| 833 | unsigned int flags); | 
|---|
| 834 |  | 
|---|
| 835 | bool i915_gem_object_can_migrate(struct drm_i915_gem_object *obj, | 
|---|
| 836 | enum intel_region_id id); | 
|---|
| 837 |  | 
|---|
| 838 | int i915_gem_object_wait_migration(struct drm_i915_gem_object *obj, | 
|---|
| 839 | unsigned int flags); | 
|---|
| 840 |  | 
|---|
| 841 | bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj, | 
|---|
| 842 | enum intel_memory_type type); | 
|---|
| 843 |  | 
|---|
| 844 | bool i915_gem_object_needs_ccs_pages(struct drm_i915_gem_object *obj); | 
|---|
| 845 |  | 
|---|
| 846 | int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st, | 
|---|
| 847 | size_t size, struct intel_memory_region *mr, | 
|---|
| 848 | struct address_space *mapping, | 
|---|
| 849 | unsigned int max_segment); | 
|---|
| 850 | void shmem_sg_free_table(struct sg_table *st, struct address_space *mapping, | 
|---|
| 851 | bool dirty, bool backup); | 
|---|
| 852 | void __shmem_writeback(size_t size, struct address_space *mapping); | 
|---|
| 853 |  | 
|---|
| 854 | #ifdef CONFIG_MMU_NOTIFIER | 
|---|
| 855 | static inline bool | 
|---|
| 856 | i915_gem_object_is_userptr(struct drm_i915_gem_object *obj) | 
|---|
| 857 | { | 
|---|
| 858 | return obj->userptr.notifier.mm; | 
|---|
| 859 | } | 
|---|
| 860 |  | 
|---|
| 861 | int i915_gem_object_userptr_submit_init(struct drm_i915_gem_object *obj); | 
|---|
| 862 | int i915_gem_object_userptr_submit_done(struct drm_i915_gem_object *obj); | 
|---|
| 863 | int i915_gem_object_userptr_validate(struct drm_i915_gem_object *obj); | 
|---|
| 864 | #else | 
|---|
| 865 | static inline bool i915_gem_object_is_userptr(struct drm_i915_gem_object *obj) { return false; } | 
|---|
| 866 |  | 
|---|
| 867 | static inline int i915_gem_object_userptr_submit_init(struct drm_i915_gem_object *obj) { GEM_BUG_ON(1); return -ENODEV; } | 
|---|
| 868 | static inline int i915_gem_object_userptr_submit_done(struct drm_i915_gem_object *obj) { GEM_BUG_ON(1); return -ENODEV; } | 
|---|
| 869 | static inline int i915_gem_object_userptr_validate(struct drm_i915_gem_object *obj) { GEM_BUG_ON(1); return -ENODEV; } | 
|---|
| 870 |  | 
|---|
| 871 | #endif | 
|---|
| 872 |  | 
|---|
| 873 | #endif | 
|---|
| 874 |  | 
|---|