OSDN Git Service

Revert "Replace NO_MOVE/NO_EVICT flags to buffer objects with an ioctl to set pinning."
[android-x86/external-libdrm.git] / linux-core / drm_objects.h
1 /**************************************************************************
2  *
3  * Copyright (c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24  * USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 /*
28  * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
29  */
30
31 #ifndef _DRM_OBJECTS_H
32 #define _DRM_OBJECTS_H
33
34 struct drm_device;
35 struct drm_bo_mem_reg;
36
37 /***************************************************
38  * User space objects. (drm_object.c)
39  */
40
41 #define drm_user_object_entry(_ptr, _type, _member) container_of(_ptr, _type, _member)
42
43 enum drm_object_type {
44         drm_fence_type,
45         drm_buffer_type,
46             /*
47              * Add other user space object types here.
48              */
49         drm_driver_type0 = 256,
50         drm_driver_type1,
51         drm_driver_type2,
52         drm_driver_type3,
53         drm_driver_type4
54 };
55
56 /*
57  * A user object is a structure that helps the drm give out user handles
58  * to kernel internal objects and to keep track of these objects so that
59  * they can be destroyed, for example when the user space process exits.
60  * Designed to be accessible using a user space 32-bit handle.
61  */
62
63 struct drm_user_object {
64         struct drm_hash_item hash;
65         struct list_head list;
66         enum drm_object_type type;
67         atomic_t refcount;
68         int shareable;
69         struct drm_file *owner;
70         void (*ref_struct_locked) (struct drm_file * priv,
71                                    struct drm_user_object * obj,
72                                    enum drm_ref_type ref_action);
73         void (*unref) (struct drm_file * priv, struct drm_user_object * obj,
74                        enum drm_ref_type unref_action);
75         void (*remove) (struct drm_file * priv, struct drm_user_object * obj);
76 };
77
78 /*
79  * A ref object is a structure which is used to
80  * keep track of references to user objects and to keep track of these
81  * references so that they can be destroyed for example when the user space
82  * process exits. Designed to be accessible using a pointer to the _user_ object.
83  */
84
85 struct drm_ref_object {
86         struct drm_hash_item hash;
87         struct list_head list;
88         atomic_t refcount;
89         enum drm_ref_type unref_action;
90 };
91
92 /**
93  * Must be called with the struct_mutex held.
94  */
95
96 extern int drm_add_user_object(struct drm_file * priv, struct drm_user_object * item,
97                                int shareable);
98 /**
99  * Must be called with the struct_mutex held.
100  */
101
102 extern struct drm_user_object *drm_lookup_user_object(struct drm_file * priv,
103                                                  uint32_t key);
104
105 /*
106  * Must be called with the struct_mutex held. May temporarily release it.
107  */
108
109 extern int drm_add_ref_object(struct drm_file * priv,
110                               struct drm_user_object * referenced_object,
111                               enum drm_ref_type ref_action);
112
113 /*
114  * Must be called with the struct_mutex held.
115  */
116
117 struct drm_ref_object *drm_lookup_ref_object(struct drm_file * priv,
118                                         struct drm_user_object * referenced_object,
119                                         enum drm_ref_type ref_action);
120 /*
121  * Must be called with the struct_mutex held.
122  * If "item" has been obtained by a call to drm_lookup_ref_object. You may not
123  * release the struct_mutex before calling drm_remove_ref_object.
124  * This function may temporarily release the struct_mutex.
125  */
126
127 extern void drm_remove_ref_object(struct drm_file * priv, struct drm_ref_object * item);
128 extern int drm_user_object_ref(struct drm_file * priv, uint32_t user_token,
129                                enum drm_object_type type,
130                                struct drm_user_object ** object);
131 extern int drm_user_object_unref(struct drm_file * priv, uint32_t user_token,
132                                  enum drm_object_type type);
133
134 /***************************************************
135  * Fence objects. (drm_fence.c)
136  */
137
138 struct drm_fence_object {
139         struct drm_user_object base;
140         struct drm_device *dev;
141         atomic_t usage;
142
143         /*
144          * The below three fields are protected by the fence manager spinlock.
145          */
146
147         struct list_head ring;
148         int fence_class;
149         uint32_t native_type;
150         uint32_t type;
151         uint32_t signaled;
152         uint32_t sequence;
153         uint32_t flush_mask;
154         uint32_t submitted_flush;
155         uint32_t error;
156 };
157
158 #define _DRM_FENCE_CLASSES 8
159 #define _DRM_FENCE_TYPE_EXE 0x00
160
161 struct drm_fence_class_manager {
162         struct list_head ring;
163         uint32_t pending_flush;
164         wait_queue_head_t fence_queue;
165         int pending_exe_flush;
166         uint32_t last_exe_flush;
167         uint32_t exe_flush_sequence;
168 };
169
170 struct drm_fence_manager {
171         int initialized;
172         rwlock_t lock;
173         struct drm_fence_class_manager fence_class[_DRM_FENCE_CLASSES];
174         uint32_t num_classes;
175         atomic_t count;
176 };
177
178 struct drm_fence_driver {
179         uint32_t num_classes;
180         uint32_t wrap_diff;
181         uint32_t flush_diff;
182         uint32_t sequence_mask;
183         int lazy_capable;
184         int (*has_irq) (struct drm_device * dev, uint32_t fence_class,
185                         uint32_t flags);
186         int (*emit) (struct drm_device * dev, uint32_t fence_class, uint32_t flags,
187                      uint32_t * breadcrumb, uint32_t * native_type);
188         void (*poke_flush) (struct drm_device * dev, uint32_t fence_class);
189 };
190
191 extern void drm_fence_handler(struct drm_device *dev, uint32_t fence_class,
192                               uint32_t sequence, uint32_t type, uint32_t error);
193 extern void drm_fence_manager_init(struct drm_device *dev);
194 extern void drm_fence_manager_takedown(struct drm_device *dev);
195 extern void drm_fence_flush_old(struct drm_device *dev, uint32_t fence_class,
196                                 uint32_t sequence);
197 extern int drm_fence_object_flush(struct drm_fence_object * fence, uint32_t type);
198 extern int drm_fence_object_signaled(struct drm_fence_object * fence,
199                                      uint32_t type, int flush);
200 extern void drm_fence_usage_deref_locked(struct drm_fence_object ** fence);
201 extern void drm_fence_usage_deref_unlocked(struct drm_fence_object ** fence);
202 extern struct drm_fence_object *drm_fence_reference_locked(struct drm_fence_object *src);
203 extern void drm_fence_reference_unlocked(struct drm_fence_object **dst,
204                                          struct drm_fence_object *src);
205 extern int drm_fence_object_wait(struct drm_fence_object * fence,
206                                  int lazy, int ignore_signals, uint32_t mask);
207 extern int drm_fence_object_create(struct drm_device *dev, uint32_t type,
208                                    uint32_t fence_flags, uint32_t fence_class,
209                                    struct drm_fence_object ** c_fence);
210 extern int drm_fence_object_emit(struct drm_fence_object * fence,
211                                  uint32_t fence_flags, uint32_t class,
212                                  uint32_t type);
213 extern void drm_fence_fill_arg(struct drm_fence_object *fence,
214                                struct drm_fence_arg *arg);
215
216 extern int drm_fence_add_user_object(struct drm_file * priv,
217                                      struct drm_fence_object * fence, int shareable);
218
219 extern int drm_fence_create_ioctl(struct drm_device *dev, void *data,
220                                   struct drm_file *file_priv);
221 extern int drm_fence_destroy_ioctl(struct drm_device *dev, void *data,
222                                    struct drm_file *file_priv);
223 extern int drm_fence_reference_ioctl(struct drm_device *dev, void *data,
224                                      struct drm_file *file_priv);
225 extern int drm_fence_unreference_ioctl(struct drm_device *dev, void *data,
226                                        struct drm_file *file_priv);
227 extern int drm_fence_signaled_ioctl(struct drm_device *dev, void *data,
228                                     struct drm_file *file_priv);
229 extern int drm_fence_flush_ioctl(struct drm_device *dev, void *data,
230                                  struct drm_file *file_priv);
231 extern int drm_fence_wait_ioctl(struct drm_device *dev, void *data,
232                                 struct drm_file *file_priv);
233 extern int drm_fence_emit_ioctl(struct drm_device *dev, void *data,
234                                 struct drm_file *file_priv);
235 extern int drm_fence_buffers_ioctl(struct drm_device *dev, void *data,
236                                    struct drm_file *file_priv);
237 /**************************************************
238  *TTMs
239  */
240
241 /*
242  * The ttm backend GTT interface. (In our case AGP).
243  * Any similar type of device (PCIE?)
244  * needs only to implement these functions to be usable with the "TTM" interface.
245  * The AGP backend implementation lives in drm_agpsupport.c
246  * basically maps these calls to available functions in agpgart.
247  * Each drm device driver gets an
248  * additional function pointer that creates these types,
249  * so that the device can choose the correct aperture.
250  * (Multiple AGP apertures, etc.)
251  * Most device drivers will let this point to the standard AGP implementation.
252  */
253
254 #define DRM_BE_FLAG_NEEDS_FREE     0x00000001
255 #define DRM_BE_FLAG_BOUND_CACHED   0x00000002
256
257 struct drm_ttm_backend;
258 struct drm_ttm_backend_func {
259         int (*needs_ub_cache_adjust) (struct drm_ttm_backend * backend);
260         int (*populate) (struct drm_ttm_backend * backend,
261                          unsigned long num_pages, struct page ** pages);
262         void (*clear) (struct drm_ttm_backend * backend);
263         int (*bind) (struct drm_ttm_backend * backend,
264                      struct drm_bo_mem_reg * bo_mem);
265         int (*unbind) (struct drm_ttm_backend * backend);
266         void (*destroy) (struct drm_ttm_backend * backend);
267 };
268
269
270 typedef struct drm_ttm_backend {
271         struct drm_device *dev;
272         uint32_t flags;
273         struct drm_ttm_backend_func *func;
274 } drm_ttm_backend_t;
275
276 struct drm_ttm {
277         struct page **pages;
278         uint32_t page_flags;
279         unsigned long num_pages;
280         atomic_t vma_count;
281         struct drm_device *dev;
282         int destroy;
283         uint32_t mapping_offset;
284         struct drm_ttm_backend *be;
285         enum {
286                 ttm_bound,
287                 ttm_evicted,
288                 ttm_unbound,
289                 ttm_unpopulated,
290         } state;
291
292 };
293
294 extern struct drm_ttm *drm_ttm_init(struct drm_device *dev, unsigned long size);
295 extern int drm_bind_ttm(struct drm_ttm * ttm, struct drm_bo_mem_reg *bo_mem);
296 extern void drm_ttm_unbind(struct drm_ttm * ttm);
297 extern void drm_ttm_evict(struct drm_ttm * ttm);
298 extern void drm_ttm_fixup_caching(struct drm_ttm * ttm);
299 extern struct page *drm_ttm_get_page(struct drm_ttm * ttm, int index);
300 extern void drm_ttm_cache_flush(void);
301 extern int drm_ttm_populate(struct drm_ttm * ttm);
302
303 /*
304  * Destroy a ttm. The user normally calls drmRmMap or a similar IOCTL to do this,
305  * which calls this function iff there are no vmas referencing it anymore. Otherwise it is called
306  * when the last vma exits.
307  */
308
309 extern int drm_destroy_ttm(struct drm_ttm * ttm);
310
311 #define DRM_FLAG_MASKED(_old, _new, _mask) {\
312 (_old) ^= (((_old) ^ (_new)) & (_mask)); \
313 }
314
315 #define DRM_TTM_MASK_FLAGS ((1 << PAGE_SHIFT) - 1)
316 #define DRM_TTM_MASK_PFN (0xFFFFFFFFU - DRM_TTM_MASK_FLAGS)
317
318 /*
319  * Page flags.
320  */
321
322 #define DRM_TTM_PAGE_UNCACHED 0x01
323 #define DRM_TTM_PAGE_USED     0x02
324 #define DRM_TTM_PAGE_BOUND    0x04
325 #define DRM_TTM_PAGE_PRESENT  0x08
326 #define DRM_TTM_PAGE_VMALLOC  0x10
327
328 /***************************************************
329  * Buffer objects. (drm_bo.c, drm_bo_move.c)
330  */
331
332 struct drm_bo_mem_reg {
333         struct drm_mm_node *mm_node;
334         unsigned long size;
335         unsigned long num_pages;
336         uint32_t page_alignment;
337         uint32_t mem_type;
338         uint64_t flags;
339         uint64_t mask;
340         uint32_t desired_tile_stride;
341         uint32_t hw_tile_stride;
342 };
343
344 enum drm_bo_type {
345         drm_bo_type_dc,
346         drm_bo_type_user,
347         drm_bo_type_kernel, /* for initial kernel allocations */
348 };
349
350 struct drm_buffer_object {
351         struct drm_device *dev;
352         struct drm_user_object base;
353
354         /*
355          * If there is a possibility that the usage variable is zero,
356          * then dev->struct_mutext should be locked before incrementing it.
357          */
358
359         atomic_t usage;
360         unsigned long buffer_start;
361         enum drm_bo_type type;
362         unsigned long offset;
363         atomic_t mapped;
364         struct drm_bo_mem_reg mem;
365
366         struct list_head lru;
367         struct list_head ddestroy;
368
369         uint32_t fence_type;
370         uint32_t fence_class;
371         uint32_t new_fence_type;
372         uint32_t new_fence_class;
373         struct drm_fence_object *fence;
374         uint32_t priv_flags;
375         wait_queue_head_t event_queue;
376         struct mutex mutex;
377         unsigned long num_pages;
378
379         /* For pinned buffers */
380         struct drm_mm_node *pinned_node;
381         uint32_t pinned_mem_type;
382         struct list_head pinned_lru;
383
384         /* For vm */
385         struct drm_ttm *ttm;
386         struct drm_map_list map_list;
387         uint32_t memory_type;
388         unsigned long bus_offset;
389         uint32_t vm_flags;
390         void *iomap;
391
392 #ifdef DRM_ODD_MM_COMPAT
393         /* dev->struct_mutex only protected. */
394         struct list_head vma_list;
395         struct list_head p_mm_list;
396 #endif
397
398 };
399
400 #define _DRM_BO_FLAG_UNFENCED 0x00000001
401 #define _DRM_BO_FLAG_EVICTED  0x00000002
402
403 struct drm_mem_type_manager {
404         int has_type;
405         int use_type;
406         struct drm_mm manager;
407         struct list_head lru;
408         struct list_head pinned;
409         uint32_t flags;
410         uint32_t drm_bus_maptype;
411         unsigned long gpu_offset;
412         unsigned long io_offset;
413         unsigned long io_size;
414         void *io_addr;
415 };
416
417 #define _DRM_FLAG_MEMTYPE_FIXED     0x00000001  /* Fixed (on-card) PCI memory */
418 #define _DRM_FLAG_MEMTYPE_MAPPABLE  0x00000002  /* Memory mappable */
419 #define _DRM_FLAG_MEMTYPE_CACHED    0x00000004  /* Cached binding */
420 #define _DRM_FLAG_NEEDS_IOREMAP     0x00000008  /* Fixed memory needs ioremap
421                                                    before kernel access. */
422 #define _DRM_FLAG_MEMTYPE_CMA       0x00000010  /* Can't map aperture */
423 #define _DRM_FLAG_MEMTYPE_CSELECT   0x00000020  /* Select caching */
424
425 struct drm_buffer_manager {
426         struct mutex init_mutex;
427         struct mutex evict_mutex;
428         int nice_mode;
429         int initialized;
430         struct drm_file *last_to_validate;
431         struct drm_mem_type_manager man[DRM_BO_MEM_TYPES];
432         struct list_head unfenced;
433         struct list_head ddestroy;
434 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
435         struct work_struct wq;
436 #else
437         struct delayed_work wq;
438 #endif
439         uint32_t fence_type;
440         unsigned long cur_pages;
441         atomic_t count;
442 };
443
444 struct drm_bo_driver {
445         const uint32_t *mem_type_prio;
446         const uint32_t *mem_busy_prio;
447         uint32_t num_mem_type_prio;
448         uint32_t num_mem_busy_prio;
449         struct drm_ttm_backend *(*create_ttm_backend_entry)
450          (struct drm_device * dev);
451         int (*fence_type) (struct drm_buffer_object *bo, uint32_t *fclass,
452                      uint32_t * type);
453         int (*invalidate_caches) (struct drm_device * dev, uint64_t flags);
454         int (*init_mem_type) (struct drm_device * dev, uint32_t type,
455                               struct drm_mem_type_manager * man);
456          uint32_t(*evict_mask) (struct drm_buffer_object *bo);
457         int (*move) (struct drm_buffer_object * bo,
458                      int evict, int no_wait, struct drm_bo_mem_reg * new_mem);
459 };
460
461 /*
462  * buffer objects (drm_bo.c)
463  */
464
465 extern int drm_bo_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
466 extern int drm_bo_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
467 extern int drm_bo_map_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
468 extern int drm_bo_unmap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
469 extern int drm_bo_reference_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
470 extern int drm_bo_unreference_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
471 extern int drm_bo_wait_idle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
472 extern int drm_bo_info_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
473 extern int drm_bo_op_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
474
475
476 extern int drm_mm_init_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
477 extern int drm_mm_takedown_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
478 extern int drm_mm_lock_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
479 extern int drm_mm_unlock_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
480 extern int drm_bo_driver_finish(struct drm_device *dev);
481 extern int drm_bo_driver_init(struct drm_device *dev);
482 extern int drm_bo_pci_offset(struct drm_device *dev,
483                              struct drm_bo_mem_reg * mem,
484                              unsigned long *bus_base,
485                              unsigned long *bus_offset,
486                              unsigned long *bus_size);
487 extern int drm_mem_reg_is_pci(struct drm_device *dev, struct drm_bo_mem_reg * mem);
488
489 extern void drm_bo_usage_deref_locked(struct drm_buffer_object ** bo);
490 extern void drm_bo_usage_deref_unlocked(struct drm_buffer_object ** bo);
491 extern void drm_putback_buffer_objects(struct drm_device *dev);
492 extern int drm_fence_buffer_objects(struct drm_device * dev,
493                                     struct list_head *list,
494                                     uint32_t fence_flags,
495                                     struct drm_fence_object * fence,
496                                     struct drm_fence_object ** used_fence);
497 extern void drm_bo_add_to_lru(struct drm_buffer_object * bo);
498 extern int drm_buffer_object_create(struct drm_device *dev, unsigned long size,
499                                     enum drm_bo_type type, uint64_t mask,
500                                     uint32_t hint, uint32_t page_alignment,
501                                     unsigned long buffer_start,
502                                     struct drm_buffer_object **bo);
503 extern int drm_bo_wait(struct drm_buffer_object * bo, int lazy, int ignore_signals,
504                        int no_wait);
505 extern int drm_bo_mem_space(struct drm_buffer_object * bo,
506                             struct drm_bo_mem_reg * mem, int no_wait);
507 extern int drm_bo_move_buffer(struct drm_buffer_object * bo, uint32_t new_mem_flags,
508                               int no_wait, int move_unfenced);
509 extern int drm_bo_clean_mm(struct drm_device * dev, unsigned mem_type);
510 extern int drm_bo_init_mm(struct drm_device * dev, unsigned type,
511                           unsigned long p_offset, unsigned long p_size);
512 extern int drm_bo_handle_validate(struct drm_file * file_priv, uint32_t handle,
513                                   uint32_t fence_class, uint64_t flags,
514                                   uint64_t mask, uint32_t hint,
515                                   struct drm_bo_info_rep * rep,
516                                   struct drm_buffer_object **bo_rep);
517 extern struct drm_buffer_object *drm_lookup_buffer_object(struct drm_file * file_priv,
518                                                           uint32_t handle,
519                                                           int check_owner);
520 extern int drm_bo_do_validate(struct drm_buffer_object *bo,
521                               uint64_t flags, uint64_t mask, uint32_t hint,
522                               uint32_t fence_class,
523                               int no_wait,
524                               struct drm_bo_info_rep *rep);
525
526 /*
527  * Buffer object memory move- and map helpers.
528  * drm_bo_move.c
529  */
530
531 extern int drm_bo_move_ttm(struct drm_buffer_object * bo,
532                            int evict, int no_wait, struct drm_bo_mem_reg * new_mem);
533 extern int drm_bo_move_memcpy(struct drm_buffer_object * bo,
534                               int evict,
535                               int no_wait, struct drm_bo_mem_reg * new_mem);
536 extern int drm_bo_move_accel_cleanup(struct drm_buffer_object * bo,
537                                      int evict,
538                                      int no_wait,
539                                      uint32_t fence_class,
540                                      uint32_t fence_type,
541                                      uint32_t fence_flags,
542                                      struct drm_bo_mem_reg * new_mem);
543 extern int drm_bo_same_page(unsigned long offset, unsigned long offset2);
544 extern unsigned long drm_bo_offset_end(unsigned long offset,
545                                        unsigned long end);
546
547 struct drm_bo_kmap_obj {
548         void *virtual;
549         struct page *page;
550         enum {
551                 bo_map_iomap,
552                 bo_map_vmap,
553                 bo_map_kmap,
554                 bo_map_premapped,
555         } bo_kmap_type;
556 };
557
558 static inline void *drm_bmo_virtual(struct drm_bo_kmap_obj *map, int *is_iomem)
559 {
560         *is_iomem = (map->bo_kmap_type == bo_map_iomap ||
561                      map->bo_kmap_type == bo_map_premapped);
562         return map->virtual;
563 }
564 extern void drm_bo_kunmap(struct drm_bo_kmap_obj *map);
565 extern int drm_bo_kmap(struct drm_buffer_object *bo, unsigned long start_page,
566                        unsigned long num_pages, struct drm_bo_kmap_obj *map);
567
568
569 /*
570  * drm_regman.c
571  */
572
573 struct drm_reg {
574         struct list_head head;
575         struct drm_fence_object *fence;
576         uint32_t fence_type;
577         uint32_t new_fence_type;
578 };
579
580 struct drm_reg_manager {
581         struct list_head free;
582         struct list_head lru;
583         struct list_head unfenced;
584
585         int (*reg_reusable)(const struct drm_reg *reg, const void *data);
586         void (*reg_destroy)(struct drm_reg *reg);
587 };
588
589 extern int drm_regs_alloc(struct drm_reg_manager *manager,
590                           const void *data,
591                           uint32_t fence_class,
592                           uint32_t fence_type,
593                           int interruptible,
594                           int no_wait,
595                           struct drm_reg **reg);
596
597 extern void drm_regs_fence(struct drm_reg_manager *regs,
598                            struct drm_fence_object *fence);
599
600 extern void drm_regs_free(struct drm_reg_manager *manager);
601 extern void drm_regs_add(struct drm_reg_manager *manager, struct drm_reg *reg);
602 extern void drm_regs_init(struct drm_reg_manager *manager,
603                           int (*reg_reusable)(const struct drm_reg *,
604                                               const void *),
605                           void (*reg_destroy)(struct drm_reg *));
606
607 #ifdef CONFIG_DEBUG_MUTEXES
608 #define DRM_ASSERT_LOCKED(_mutex)                                       \
609         BUG_ON(!mutex_is_locked(_mutex) ||                              \
610                ((_mutex)->owner != current_thread_info()))
611 #else
612 #define DRM_ASSERT_LOCKED(_mutex)
613 #endif
614 #endif