1 #ifndef __DRM_GEM_H__ 2 #define __DRM_GEM_H__ 3 4 /* 5 * GEM Graphics Execution Manager Driver Interfaces 6 * 7 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 8 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 9 * Copyright (c) 2009-2010, Code Aurora Forum. 10 * All rights reserved. 11 * Copyright © 2014 Intel Corporation 12 * Daniel Vetter <daniel.vetter@ffwll.ch> 13 * 14 * Author: Rickard E. (Rik) Faith <faith@valinux.com> 15 * Author: Gareth Hughes <gareth@valinux.com> 16 * 17 * Permission is hereby granted, free of charge, to any person obtaining a 18 * copy of this software and associated documentation files (the "Software"), 19 * to deal in the Software without restriction, including without limitation 20 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 21 * and/or sell copies of the Software, and to permit persons to whom the 22 * Software is furnished to do so, subject to the following conditions: 23 * 24 * The above copyright notice and this permission notice (including the next 25 * paragraph) shall be included in all copies or substantial portions of the 26 * Software. 27 * 28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 31 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 32 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 33 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 34 * OTHER DEALINGS IN THE SOFTWARE. 35 */ 36 37 #include <linux/kref.h> 38 #include <linux/dma-buf.h> 39 #include <linux/dma-resv.h> 40 #include <linux/list.h> 41 #include <linux/mutex.h> 42 43 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 44 #include <drm/drm_device.h> 45 #endif 46 #include <drm/drm_vma_manager.h> 47 48 struct iosys_map; 49 struct drm_gem_object; 50 51 /** 52 * enum drm_gem_object_status - bitmask of object state for fdinfo reporting 53 * @DRM_GEM_OBJECT_RESIDENT: object is resident in memory (ie. not unpinned) 54 * @DRM_GEM_OBJECT_PURGEABLE: object marked as purgeable by userspace 55 * @DRM_GEM_OBJECT_ACTIVE: object is currently used by an active submission 56 * 57 * Bitmask of status used for fdinfo memory stats, see &drm_gem_object_funcs.status 58 * and drm_show_fdinfo(). Note that an object can report DRM_GEM_OBJECT_PURGEABLE 59 * and be active or not resident, in which case drm_show_fdinfo() will not 60 * account for it as purgeable. So drivers do not need to check if the buffer 61 * is idle and resident to return this bit, i.e. userspace can mark a buffer as 62 * purgeable even while it is still busy on the GPU. It will not get reported in 63 * the puregeable stats until it becomes idle. The status gem object func does 64 * not need to consider this. 65 */ 66 enum drm_gem_object_status { 67 DRM_GEM_OBJECT_RESIDENT = BIT(0), 68 DRM_GEM_OBJECT_PURGEABLE = BIT(1), 69 DRM_GEM_OBJECT_ACTIVE = BIT(2), 70 }; 71 72 /** 73 * struct drm_gem_object_funcs - GEM object functions 74 */ 75 struct drm_gem_object_funcs { 76 /** 77 * @free: 78 * 79 * Deconstructor for drm_gem_objects. 80 * 81 * This callback is mandatory. 82 */ 83 void (*free)(struct drm_gem_object *obj); 84 85 /** 86 * @open: 87 * 88 * Called upon GEM handle creation. 89 * 90 * This callback is optional. 91 */ 92 int (*open)(struct drm_gem_object *obj, struct drm_file *file); 93 94 /** 95 * @close: 96 * 97 * Called upon GEM handle release. 98 * 99 * This callback is optional. 100 */ 101 void (*close)(struct drm_gem_object *obj, struct drm_file *file); 102 103 /** 104 * @print_info: 105 * 106 * If driver subclasses struct &drm_gem_object, it can implement this 107 * optional hook for printing additional driver specific info. 108 * 109 * drm_printf_indent() should be used in the callback passing it the 110 * indent argument. 111 * 112 * This callback is called from drm_gem_print_info(). 113 * 114 * This callback is optional. 115 */ 116 void (*print_info)(struct drm_printer *p, unsigned int indent, 117 const struct drm_gem_object *obj); 118 119 /** 120 * @export: 121 * 122 * Export backing buffer as a &dma_buf. 123 * If this is not set drm_gem_prime_export() is used. 124 * 125 * This callback is optional. 126 */ 127 struct dma_buf *(*export)(struct drm_gem_object *obj, int flags); 128 129 /** 130 * @pin: 131 * 132 * Pin backing buffer in memory, such that dma-buf importers can 133 * access it. Used by the drm_gem_map_attach() helper. 134 * 135 * This callback is optional. 136 */ 137 int (*pin)(struct drm_gem_object *obj); 138 139 /** 140 * @unpin: 141 * 142 * Unpin backing buffer. Used by the drm_gem_map_detach() helper. 143 * 144 * This callback is optional. 145 */ 146 void (*unpin)(struct drm_gem_object *obj); 147 148 /** 149 * @get_sg_table: 150 * 151 * Returns a Scatter-Gather table representation of the buffer. 152 * Used when exporting a buffer by the drm_gem_map_dma_buf() helper. 153 * Releasing is done by calling dma_unmap_sg_attrs() and sg_free_table() 154 * in drm_gem_unmap_buf(), therefore these helpers and this callback 155 * here cannot be used for sg tables pointing at driver private memory 156 * ranges. 157 * 158 * See also drm_prime_pages_to_sg(). 159 */ 160 struct sg_table *(*get_sg_table)(struct drm_gem_object *obj); 161 162 /** 163 * @vmap: 164 * 165 * Returns a virtual address for the buffer. Used by the 166 * drm_gem_dmabuf_vmap() helper. Called with a held GEM reservation 167 * lock. 168 * 169 * This callback is optional. 170 */ 171 int (*vmap)(struct drm_gem_object *obj, struct iosys_map *map); 172 173 /** 174 * @vunmap: 175 * 176 * Releases the address previously returned by @vmap. Used by the 177 * drm_gem_dmabuf_vunmap() helper. Called with a held GEM reservation 178 * lock. 179 * 180 * This callback is optional. 181 */ 182 void (*vunmap)(struct drm_gem_object *obj, struct iosys_map *map); 183 184 /** 185 * @mmap: 186 * 187 * Handle mmap() of the gem object, setup vma accordingly. 188 * 189 * This callback is optional. 190 * 191 * The callback is used by both drm_gem_mmap_obj() and 192 * drm_gem_prime_mmap(). When @mmap is present @vm_ops is not 193 * used, the @mmap callback must set vma->vm_ops instead. 194 */ 195 int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma); 196 197 /** 198 * @evict: 199 * 200 * Evicts gem object out from memory. Used by the drm_gem_object_evict() 201 * helper. Returns 0 on success, -errno otherwise. Called with a held 202 * GEM reservation lock. 203 * 204 * This callback is optional. 205 */ 206 int (*evict)(struct drm_gem_object *obj); 207 208 /** 209 * @status: 210 * 211 * The optional status callback can return additional object state 212 * which determines which stats the object is counted against. The 213 * callback is called under table_lock. Racing against object status 214 * change is "harmless", and the callback can expect to not race 215 * against object destruction. 216 * 217 * Called by drm_show_memory_stats(). 218 */ 219 enum drm_gem_object_status (*status)(struct drm_gem_object *obj); 220 221 /** 222 * @rss: 223 * 224 * Return resident size of the object in physical memory. 225 * 226 * Called by drm_show_memory_stats(). 227 */ 228 size_t (*rss)(struct drm_gem_object *obj); 229 230 /** 231 * @handle_free: 232 * 233 * This callback is called when the GEM handle count goes down to 0. 234 * It is currently used by AMDGPU driver to release their exported BO 235 * handles. 236 * 237 * This callback is optional. 238 */ 239 void (*handle_free)(struct drm_gem_object *obj); 240 241 /** 242 * @vm_ops: 243 * 244 * Virtual memory operations used with mmap. 245 * 246 * This is optional but necessary for mmap support. 247 */ 248 const struct vm_operations_struct *vm_ops; 249 }; 250 251 /** 252 * struct drm_gem_lru - A simple LRU helper 253 * 254 * A helper for tracking GEM objects in a given state, to aid in 255 * driver's shrinker implementation. Tracks the count of pages 256 * for lockless &shrinker.count_objects, and provides 257 * &drm_gem_lru_scan for driver's &shrinker.scan_objects 258 * implementation. 259 * 260 * Any access to this kind of object must be done with 261 * drm_device::gem_lru_mutex held. 262 */ 263 struct drm_gem_lru { 264 /** 265 * @count: 266 * 267 * The total number of backing pages of the GEM objects in 268 * this LRU. 269 */ 270 long count; 271 272 /** 273 * @list: 274 * 275 * The LRU list. 276 */ 277 struct list_head list; 278 }; 279 280 /** 281 * struct drm_gem_object - GEM buffer object 282 * 283 * This structure defines the generic parts for GEM buffer objects, which are 284 * mostly around handling mmap and userspace handles. 285 * 286 * Buffer objects are often abbreviated to BO. 287 */ 288 struct drm_gem_object { 289 /** 290 * @refcount: 291 * 292 * Reference count of this object 293 * 294 * Please use drm_gem_object_get() to acquire and drm_gem_object_put_locked() 295 * or drm_gem_object_put() to release a reference to a GEM 296 * buffer object. 297 */ 298 struct kref refcount; 299 300 /** 301 * @handle_count: 302 * 303 * This is the GEM file_priv handle count of this object. 304 * 305 * Each handle also holds a reference. Note that when the handle_count 306 * drops to 0 any global names (e.g. the id in the flink namespace) will 307 * be cleared. 308 * 309 * Protected by &drm_device.object_name_lock. 310 */ 311 unsigned handle_count; 312 313 /** 314 * @dev: DRM dev this object belongs to. 315 */ 316 struct drm_device *dev; 317 318 /** 319 * @filp: 320 * 321 * SHMEM file node used as backing storage for swappable buffer objects. 322 * GEM also supports driver private objects with driver-specific backing 323 * storage (contiguous DMA memory, special reserved blocks). In this 324 * case @filp is NULL. 325 */ 326 struct file *filp; 327 328 /** 329 * @vma_node: 330 * 331 * Mapping info for this object to support mmap. Drivers are supposed to 332 * allocate the mmap offset using drm_gem_create_mmap_offset(). The 333 * offset itself can be retrieved using drm_vma_node_offset_addr(). 334 * 335 * Memory mapping itself is handled by drm_gem_mmap(), which also checks 336 * that userspace is allowed to access the object. 337 */ 338 struct drm_vma_offset_node vma_node; 339 340 /** 341 * @size: 342 * 343 * Size of the object, in bytes. Immutable over the object's 344 * lifetime. 345 */ 346 size_t size; 347 348 /** 349 * @name: 350 * 351 * Global name for this object, starts at 1. 0 means unnamed. 352 * Access is covered by &drm_device.object_name_lock. This is used by 353 * the GEM_FLINK and GEM_OPEN ioctls. 354 */ 355 int name; 356 357 /** 358 * @dma_buf: 359 * 360 * dma-buf associated with this GEM object. 361 * 362 * Pointer to the dma-buf associated with this gem object (either 363 * through importing or exporting). We break the resulting reference 364 * loop when the last gem handle for this object is released. 365 * 366 * Protected by &drm_device.object_name_lock. 367 */ 368 struct dma_buf *dma_buf; 369 370 /** 371 * @import_attach: 372 * 373 * dma-buf attachment backing this object. 374 * 375 * Any foreign dma_buf imported as a gem object has this set to the 376 * attachment point for the device. This is invariant over the lifetime 377 * of a gem object. 378 * 379 * The &drm_gem_object_funcs.free callback is responsible for 380 * cleaning up the dma_buf attachment and references acquired at import 381 * time. 382 * 383 * Note that the drm gem/prime core does not depend upon drivers setting 384 * this field any more. So for drivers where this doesn't make sense 385 * (e.g. virtual devices or a displaylink behind an usb bus) they can 386 * simply leave it as NULL. 387 */ 388 struct dma_buf_attachment *import_attach; 389 390 /** 391 * @resv: 392 * 393 * Pointer to reservation object associated with the this GEM object. 394 * 395 * Normally (@resv == &@_resv) except for imported GEM objects. 396 */ 397 struct dma_resv *resv; 398 399 /** 400 * @_resv: 401 * 402 * A reservation object for this GEM object. 403 * 404 * This is unused for imported GEM objects. 405 */ 406 struct dma_resv _resv; 407 408 /** 409 * @gpuva: Fields used by GPUVM to manage mappings pointing to this GEM object. 410 * 411 * When DRM_GPUVM_IMMEDIATE_MODE is set, this list is protected by the 412 * mutex. Otherwise, the list is protected by the GEMs &dma_resv lock. 413 * 414 * Note that all entries in this list must agree on whether 415 * DRM_GPUVM_IMMEDIATE_MODE is set. 416 */ 417 struct { 418 /** 419 * @gpuva.list: list of GPUVM mappings attached to this GEM object. 420 * 421 * Drivers should lock list accesses with either the GEMs 422 * &dma_resv lock (&drm_gem_object.resv) or the 423 * &drm_gem_object.gpuva.lock mutex. 424 */ 425 struct list_head list; 426 427 /** 428 * @gpuva.lock: lock protecting access to &drm_gem_object.gpuva.list 429 * when DRM_GPUVM_IMMEDIATE_MODE is used. 430 * 431 * Only used when DRM_GPUVM_IMMEDIATE_MODE is set. It should be 432 * safe to take this mutex during the fence signalling path, so 433 * do not allocate memory while holding this lock. Otherwise, 434 * the &dma_resv lock should be used. 435 */ 436 struct mutex lock; 437 } gpuva; 438 439 /** 440 * @funcs: 441 * 442 * Optional GEM object functions. If this is set, it will be used instead of the 443 * corresponding &drm_driver GEM callbacks. 444 * 445 * New drivers should use this. 446 * 447 */ 448 const struct drm_gem_object_funcs *funcs; 449 450 /** 451 * @lru_node: 452 * 453 * List node in a &drm_gem_lru. 454 */ 455 struct list_head lru_node; 456 457 /** 458 * @lru: 459 * 460 * The current LRU list that the GEM object is on. 461 * 462 * Access to this field must be done with drm_device::gem_lru_mutex 463 * held. 464 */ 465 struct drm_gem_lru *lru; 466 }; 467 468 /** 469 * DRM_GEM_FOPS - Default drm GEM file operations 470 * 471 * This macro provides a shorthand for setting the GEM file ops in the 472 * &file_operations structure. If all you need are the default ops, use 473 * DEFINE_DRM_GEM_FOPS instead. 474 */ 475 #define DRM_GEM_FOPS \ 476 .open = drm_open,\ 477 .release = drm_release,\ 478 .unlocked_ioctl = drm_ioctl,\ 479 .compat_ioctl = drm_compat_ioctl,\ 480 .poll = drm_poll,\ 481 .read = drm_read,\ 482 .llseek = noop_llseek,\ 483 .get_unmapped_area = drm_gem_get_unmapped_area,\ 484 .mmap = drm_gem_mmap, \ 485 .fop_flags = FOP_UNSIGNED_OFFSET 486 487 /** 488 * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers 489 * @name: name for the generated structure 490 * 491 * This macro autogenerates a suitable &struct file_operations for GEM based 492 * drivers, which can be assigned to &drm_driver.fops. Note that this structure 493 * cannot be shared between drivers, because it contains a reference to the 494 * current module using THIS_MODULE. 495 * 496 * Note that the declaration is already marked as static - if you need a 497 * non-static version of this you're probably doing it wrong and will break the 498 * THIS_MODULE reference by accident. 499 */ 500 #define DEFINE_DRM_GEM_FOPS(name) \ 501 static const struct file_operations name = {\ 502 .owner = THIS_MODULE,\ 503 DRM_GEM_FOPS,\ 504 } 505 506 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 507 int drm_gem_huge_mnt_create(struct drm_device *dev, const char *value); 508 #else 509 static inline int drm_gem_huge_mnt_create(struct drm_device *dev, 510 const char *value) 511 { 512 return 0; 513 } 514 #endif 515 516 /** 517 * drm_gem_get_huge_mnt - Get the huge tmpfs mountpoint used by a DRM device 518 * @dev: DRM device 519 * 520 * This function gets the huge tmpfs mountpoint used by DRM device @dev. A huge 521 * tmpfs mountpoint is used instead of `shm_mnt` after a successful call to 522 * drm_gem_huge_mnt_create() when CONFIG_TRANSPARENT_HUGEPAGE is enabled. 523 * 524 * Returns: 525 * The huge tmpfs mountpoint in use, NULL otherwise. 526 */ 527 static inline struct vfsmount *drm_gem_get_huge_mnt(struct drm_device *dev) 528 { 529 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 530 return dev->huge_mnt; 531 #else 532 return NULL; 533 #endif 534 } 535 536 void drm_gem_object_release(struct drm_gem_object *obj); 537 void drm_gem_object_free(struct kref *kref); 538 int drm_gem_object_init(struct drm_device *dev, 539 struct drm_gem_object *obj, size_t size); 540 void drm_gem_private_object_init(struct drm_device *dev, 541 struct drm_gem_object *obj, size_t size); 542 void drm_gem_private_object_fini(struct drm_gem_object *obj); 543 void drm_gem_vm_open(struct vm_area_struct *vma); 544 void drm_gem_vm_close(struct vm_area_struct *vma); 545 int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, 546 struct vm_area_struct *vma); 547 int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); 548 549 #ifdef CONFIG_MMU 550 unsigned long drm_gem_get_unmapped_area(struct file *filp, unsigned long uaddr, 551 unsigned long len, unsigned long pgoff, 552 unsigned long flags); 553 #else 554 #define drm_gem_get_unmapped_area NULL 555 #endif 556 557 /** 558 * drm_gem_object_get - acquire a GEM buffer object reference 559 * @obj: GEM buffer object 560 * 561 * This function acquires an additional reference to @obj. It is illegal to 562 * call this without already holding a reference. No locks required. 563 */ 564 static inline void drm_gem_object_get(struct drm_gem_object *obj) 565 { 566 kref_get(&obj->refcount); 567 } 568 569 __attribute__((nonnull)) 570 static inline void 571 __drm_gem_object_put(struct drm_gem_object *obj) 572 { 573 kref_put(&obj->refcount, drm_gem_object_free); 574 } 575 576 /** 577 * drm_gem_object_put - drop a GEM buffer object reference 578 * @obj: GEM buffer object 579 * 580 * This releases a reference to @obj. 581 */ 582 static inline void 583 drm_gem_object_put(struct drm_gem_object *obj) 584 { 585 if (obj) 586 __drm_gem_object_put(obj); 587 } 588 589 int drm_gem_handle_create(struct drm_file *file_priv, 590 struct drm_gem_object *obj, 591 u32 *handlep); 592 int drm_gem_handle_delete(struct drm_file *filp, u32 handle); 593 594 595 void drm_gem_free_mmap_offset(struct drm_gem_object *obj); 596 int drm_gem_create_mmap_offset(struct drm_gem_object *obj); 597 int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); 598 599 struct page **drm_gem_get_pages(struct drm_gem_object *obj); 600 void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, 601 bool dirty, bool accessed); 602 603 void drm_gem_lock(struct drm_gem_object *obj); 604 void drm_gem_unlock(struct drm_gem_object *obj); 605 606 int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map); 607 void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map); 608 609 int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles, 610 int count, struct drm_gem_object ***objs_out); 611 struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle); 612 long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle, 613 bool wait_all, unsigned long timeout); 614 int drm_gem_lock_reservations(struct drm_gem_object **objs, int count, 615 struct ww_acquire_ctx *acquire_ctx); 616 void drm_gem_unlock_reservations(struct drm_gem_object **objs, int count, 617 struct ww_acquire_ctx *acquire_ctx); 618 int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, 619 u32 handle, u64 *offset); 620 621 void drm_gem_lru_init(struct drm_gem_lru *lru); 622 void drm_gem_lru_remove(struct drm_gem_object *obj); 623 void drm_gem_lru_move_tail_locked(struct drm_gem_lru *lru, struct drm_gem_object *obj); 624 void drm_gem_lru_move_tail(struct drm_gem_lru *lru, struct drm_gem_object *obj); 625 unsigned long 626 drm_gem_lru_scan(struct drm_device *dev, 627 struct drm_gem_lru *lru, 628 unsigned int nr_to_scan, 629 unsigned long *remaining, 630 bool (*shrink)(struct drm_gem_object *obj)); 631 632 int drm_gem_evict_locked(struct drm_gem_object *obj); 633 634 /** 635 * drm_gem_object_is_shared_for_memory_stats - helper for shared memory stats 636 * 637 * This helper should only be used for fdinfo shared memory stats to determine 638 * if a GEM object is shared. 639 * 640 * @obj: obj in question 641 */ 642 static inline bool drm_gem_object_is_shared_for_memory_stats(struct drm_gem_object *obj) 643 { 644 return (obj->handle_count > 1) || obj->dma_buf; 645 } 646 647 /** 648 * drm_gem_is_imported() - Tests if GEM object's buffer has been imported 649 * @obj: the GEM object 650 * 651 * Returns: 652 * True if the GEM object's buffer has been imported, false otherwise 653 */ 654 static inline bool drm_gem_is_imported(const struct drm_gem_object *obj) 655 { 656 return !!obj->import_attach; 657 } 658 659 #ifdef CONFIG_LOCKDEP 660 #define drm_gem_gpuva_assert_lock_held(gpuvm, obj) \ 661 lockdep_assert(drm_gpuvm_immediate_mode(gpuvm) ? \ 662 lockdep_is_held(&(obj)->gpuva.lock) : \ 663 dma_resv_held((obj)->resv)) 664 #else 665 #define drm_gem_gpuva_assert_lock_held(gpuvm, obj) do {} while (0) 666 #endif 667 668 /** 669 * drm_gem_gpuva_init() - initialize the gpuva list of a GEM object 670 * @obj: the &drm_gem_object 671 * 672 * This initializes the &drm_gem_object's &drm_gpuvm_bo list. 673 * 674 * See also drm_gem_gpuva_set_lock(). 675 */ 676 static inline void drm_gem_gpuva_init(struct drm_gem_object *obj) 677 { 678 INIT_LIST_HEAD(&obj->gpuva.list); 679 } 680 681 /** 682 * drm_gem_for_each_gpuvm_bo() - iterator to walk over a list of &drm_gpuvm_bo 683 * @entry__: &drm_gpuvm_bo structure to assign to in each iteration step 684 * @obj__: the &drm_gem_object the &drm_gpuvm_bo to walk are associated with 685 * 686 * This iterator walks over all &drm_gpuvm_bo structures associated with the 687 * &drm_gem_object. 688 */ 689 #define drm_gem_for_each_gpuvm_bo(entry__, obj__) \ 690 list_for_each_entry(entry__, &(obj__)->gpuva.list, list.entry.gem) 691 692 /** 693 * drm_gem_for_each_gpuvm_bo_safe() - iterator to safely walk over a list of 694 * &drm_gpuvm_bo 695 * @entry__: &drm_gpuvm_bostructure to assign to in each iteration step 696 * @next__: &next &drm_gpuvm_bo to store the next step 697 * @obj__: the &drm_gem_object the &drm_gpuvm_bo to walk are associated with 698 * 699 * This iterator walks over all &drm_gpuvm_bo structures associated with the 700 * &drm_gem_object. It is implemented with list_for_each_entry_safe(), hence 701 * it is save against removal of elements. 702 */ 703 #define drm_gem_for_each_gpuvm_bo_safe(entry__, next__, obj__) \ 704 list_for_each_entry_safe(entry__, next__, &(obj__)->gpuva.list, list.entry.gem) 705 706 #endif /* __DRM_GEM_H__ */ 707