Add fence error member.
[profile/ivi/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.
107  * If "item" has been obtained by a call to drm_lookup_user_object. You may not
108  * release the struct_mutex before calling drm_remove_ref_object.
109  * This function may temporarily release the struct_mutex.
110  */
111
112 extern int drm_remove_user_object(struct drm_file * priv, struct drm_user_object * item);
113
114 /*
115  * Must be called with the struct_mutex held. May temporarily release it.
116  */
117
118 extern int drm_add_ref_object(struct drm_file * priv,
119                               struct drm_user_object * referenced_object,
120                               enum drm_ref_type ref_action);
121
122 /*
123  * Must be called with the struct_mutex held.
124  */
125
126 struct drm_ref_object *drm_lookup_ref_object(struct drm_file * priv,
127                                         struct drm_user_object * referenced_object,
128                                         enum drm_ref_type ref_action);
129 /*
130  * Must be called with the struct_mutex held.
131  * If "item" has been obtained by a call to drm_lookup_ref_object. You may not
132  * release the struct_mutex before calling drm_remove_ref_object.
133  * This function may temporarily release the struct_mutex.
134  */
135
136 extern void drm_remove_ref_object(struct drm_file * priv, struct drm_ref_object * item);
137 extern int drm_user_object_ref(struct drm_file * priv, uint32_t user_token,
138                                enum drm_object_type type,
139                                struct drm_user_object ** object);
140 extern int drm_user_object_unref(struct drm_file * priv, uint32_t user_token,
141                                  enum drm_object_type type);
142
143 /***************************************************
144  * Fence objects. (drm_fence.c)
145  */
146
147 struct drm_fence_object {
148         struct drm_user_object base;
149         struct drm_device *dev;
150         atomic_t usage;
151
152         /*
153          * The below three fields are protected by the fence manager spinlock.
154          */
155
156         struct list_head ring;
157         int class;
158         uint32_t native_type;
159         uint32_t type;
160         uint32_t signaled;
161         uint32_t sequence;
162         uint32_t flush_mask;
163         uint32_t submitted_flush;
164         uint32_t error;
165 };
166
167 #define _DRM_FENCE_CLASSES 8
168 #define _DRM_FENCE_TYPE_EXE 0x00
169
170 struct drm_fence_class_manager {
171         struct list_head ring;
172         uint32_t pending_flush;
173         wait_queue_head_t fence_queue;
174         int pending_exe_flush;
175         uint32_t last_exe_flush;
176         uint32_t exe_flush_sequence;
177 };
178
179 struct drm_fence_manager {
180         int initialized;
181         rwlock_t lock;
182         struct drm_fence_class_manager class[_DRM_FENCE_CLASSES];
183         uint32_t num_classes;
184         atomic_t count;
185 };
186
187 struct drm_fence_driver {
188         uint32_t num_classes;
189         uint32_t wrap_diff;
190         uint32_t flush_diff;
191         uint32_t sequence_mask;
192         int lazy_capable;
193         int (*has_irq) (struct drm_device * dev, uint32_t class,
194                         uint32_t flags);
195         int (*emit) (struct drm_device * dev, uint32_t class, uint32_t flags,
196                      uint32_t * breadcrumb, uint32_t * native_type);
197         void (*poke_flush) (struct drm_device * dev, uint32_t class);
198 };
199
200 extern void drm_fence_handler(struct drm_device *dev, uint32_t class,
201                               uint32_t sequence, uint32_t type, uint32_t error);
202 extern void drm_fence_manager_init(struct drm_device *dev);
203 extern void drm_fence_manager_takedown(struct drm_device *dev);
204 extern void drm_fence_flush_old(struct drm_device *dev, uint32_t class,
205                                 uint32_t sequence);
206 extern int drm_fence_object_flush(struct drm_fence_object * fence, uint32_t type);
207 extern int drm_fence_object_signaled(struct drm_fence_object * fence,
208                                      uint32_t type, int flush);
209 extern void drm_fence_usage_deref_locked(struct drm_fence_object ** fence);
210 extern void drm_fence_usage_deref_unlocked(struct drm_fence_object ** fence);
211 extern struct drm_fence_object *drm_fence_reference_locked(struct drm_fence_object *src);
212 extern void drm_fence_reference_unlocked(struct drm_fence_object **dst,
213                                          struct drm_fence_object *src);
214 extern int drm_fence_object_wait(struct drm_fence_object * fence,
215                                  int lazy, int ignore_signals, uint32_t mask);
216 extern int drm_fence_object_create(struct drm_device *dev, uint32_t type,
217                                    uint32_t fence_flags, uint32_t class,
218                                    struct drm_fence_object ** c_fence);
219 extern int drm_fence_object_emit(struct drm_fence_object * fence,
220                                  uint32_t fence_flags, uint32_t class,
221                                  uint32_t type);
222 extern void drm_fence_fill_arg(struct drm_fence_object *fence,
223                                struct drm_fence_arg *arg);
224
225 extern int drm_fence_add_user_object(struct drm_file * priv,
226                                      struct drm_fence_object * fence, int shareable);
227
228 extern int drm_fence_create_ioctl(struct drm_device *dev, void *data,
229                                   struct drm_file *file_priv);
230 extern int drm_fence_destroy_ioctl(struct drm_device *dev, void *data,
231                                    struct drm_file *file_priv);
232 extern int drm_fence_reference_ioctl(struct drm_device *dev, void *data,
233                                      struct drm_file *file_priv);
234 extern int drm_fence_unreference_ioctl(struct drm_device *dev, void *data,
235                                        struct drm_file *file_priv);
236 extern int drm_fence_signaled_ioctl(struct drm_device *dev, void *data,
237                                     struct drm_file *file_priv);
238 extern int drm_fence_flush_ioctl(struct drm_device *dev, void *data,
239                                  struct drm_file *file_priv);
240 extern int drm_fence_wait_ioctl(struct drm_device *dev, void *data,
241                                 struct drm_file *file_priv);
242 extern int drm_fence_emit_ioctl(struct drm_device *dev, void *data,
243                                 struct drm_file *file_priv);
244 extern int drm_fence_buffers_ioctl(struct drm_device *dev, void *data,
245                                    struct drm_file *file_priv);
246 /**************************************************
247  *TTMs
248  */
249
250 /*
251  * The ttm backend GTT interface. (In our case AGP).
252  * Any similar type of device (PCIE?)
253  * needs only to implement these functions to be usable with the "TTM" interface.
254  * The AGP backend implementation lives in drm_agpsupport.c
255  * basically maps these calls to available functions in agpgart.
256  * Each drm device driver gets an
257  * additional function pointer that creates these types,
258  * so that the device can choose the correct aperture.
259  * (Multiple AGP apertures, etc.)
260  * Most device drivers will let this point to the standard AGP implementation.
261  */
262
263 #define DRM_BE_FLAG_NEEDS_FREE     0x00000001
264 #define DRM_BE_FLAG_BOUND_CACHED   0x00000002
265
266 struct drm_ttm_backend;
267 struct drm_ttm_backend_func {
268         int (*needs_ub_cache_adjust) (struct drm_ttm_backend * backend);
269         int (*populate) (struct drm_ttm_backend * backend,
270                          unsigned long num_pages, struct page ** pages);
271         void (*clear) (struct drm_ttm_backend * backend);
272         int (*bind) (struct drm_ttm_backend * backend,
273                      struct drm_bo_mem_reg * bo_mem);
274         int (*unbind) (struct drm_ttm_backend * backend);
275         void (*destroy) (struct drm_ttm_backend * backend);
276 };
277
278
279 typedef struct drm_ttm_backend {
280         struct drm_device *dev;
281         uint32_t flags;
282         struct drm_ttm_backend_func *func;
283 } drm_ttm_backend_t;
284
285 struct drm_ttm {
286         struct page **pages;
287         uint32_t page_flags;
288         unsigned long num_pages;
289         atomic_t vma_count;
290         struct drm_device *dev;
291         int destroy;
292         uint32_t mapping_offset;
293         struct drm_ttm_backend *be;
294         enum {
295                 ttm_bound,
296                 ttm_evicted,
297                 ttm_unbound,
298                 ttm_unpopulated,
299         } state;
300
301 };
302
303 extern struct drm_ttm *drm_ttm_init(struct drm_device *dev, unsigned long size);
304 extern int drm_bind_ttm(struct drm_ttm * ttm, struct drm_bo_mem_reg *bo_mem);
305 extern void drm_ttm_unbind(struct drm_ttm * ttm);
306 extern void drm_ttm_evict(struct drm_ttm * ttm);
307 extern void drm_ttm_fixup_caching(struct drm_ttm * ttm);
308 extern struct page *drm_ttm_get_page(struct drm_ttm * ttm, int index);
309 extern void drm_ttm_cache_flush(void);
310 extern int drm_ttm_populate(struct drm_ttm * ttm);
311
312 /*
313  * Destroy a ttm. The user normally calls drmRmMap or a similar IOCTL to do this,
314  * which calls this function iff there are no vmas referencing it anymore. Otherwise it is called
315  * when the last vma exits.
316  */
317
318 extern int drm_destroy_ttm(struct drm_ttm * ttm);
319
320 #define DRM_FLAG_MASKED(_old, _new, _mask) {\
321 (_old) ^= (((_old) ^ (_new)) & (_mask)); \
322 }
323
324 #define DRM_TTM_MASK_FLAGS ((1 << PAGE_SHIFT) - 1)
325 #define DRM_TTM_MASK_PFN (0xFFFFFFFFU - DRM_TTM_MASK_FLAGS)
326
327 /*
328  * Page flags.
329  */
330
331 #define DRM_TTM_PAGE_UNCACHED 0x01
332 #define DRM_TTM_PAGE_USED     0x02
333 #define DRM_TTM_PAGE_BOUND    0x04
334 #define DRM_TTM_PAGE_PRESENT  0x08
335 #define DRM_TTM_PAGE_VMALLOC  0x10
336
337 /***************************************************
338  * Buffer objects. (drm_bo.c, drm_bo_move.c)
339  */
340
341 struct drm_bo_mem_reg {
342         struct drm_mm_node *mm_node;
343         unsigned long size;
344         unsigned long num_pages;
345         uint32_t page_alignment;
346         uint32_t mem_type;
347         uint64_t flags;
348         uint64_t mask;
349         uint32_t desired_tile_stride;
350         uint32_t hw_tile_stride;
351 };
352
353 struct drm_buffer_object {
354         struct drm_device *dev;
355         struct drm_user_object base;
356
357         /*
358          * If there is a possibility that the usage variable is zero,
359          * then dev->struct_mutext should be locked before incrementing it.
360          */
361
362         atomic_t usage;
363         unsigned long buffer_start;
364         enum drm_bo_type type;
365         unsigned long offset;
366         atomic_t mapped;
367         struct drm_bo_mem_reg mem;
368
369         struct list_head lru;
370         struct list_head ddestroy;
371
372         uint32_t fence_type;
373         uint32_t fence_class;
374         uint32_t new_fence_type;
375         uint32_t new_fence_class;
376         struct drm_fence_object *fence;
377         uint32_t priv_flags;
378         wait_queue_head_t event_queue;
379         struct mutex mutex;
380         unsigned long num_pages;
381
382         /* For pinned buffers */
383         int pinned;
384         struct drm_mm_node *pinned_node;
385         uint32_t pinned_mem_type;
386         struct list_head pinned_lru;
387
388         /* For vm */
389         struct drm_ttm *ttm;
390         struct drm_map_list map_list;
391         uint32_t memory_type;
392         unsigned long bus_offset;
393         uint32_t vm_flags;
394         void *iomap;
395
396 #ifdef DRM_ODD_MM_COMPAT
397         /* dev->struct_mutex only protected. */
398         struct list_head vma_list;
399         struct list_head p_mm_list;
400 #endif
401
402 };
403
404 #define _DRM_BO_FLAG_UNFENCED 0x00000001
405 #define _DRM_BO_FLAG_EVICTED  0x00000002
406
407 struct drm_mem_type_manager {
408         int has_type;
409         int use_type;
410         struct drm_mm manager;
411         struct list_head lru;
412         struct list_head pinned;
413         uint32_t flags;
414         uint32_t drm_bus_maptype;
415         unsigned long gpu_offset;
416         unsigned long io_offset;
417         unsigned long io_size;
418         void *io_addr;
419 };
420
421 #define _DRM_FLAG_MEMTYPE_FIXED     0x00000001  /* Fixed (on-card) PCI memory */
422 #define _DRM_FLAG_MEMTYPE_MAPPABLE  0x00000002  /* Memory mappable */
423 #define _DRM_FLAG_MEMTYPE_CACHED    0x00000004  /* Cached binding */
424 #define _DRM_FLAG_NEEDS_IOREMAP     0x00000008  /* Fixed memory needs ioremap
425                                                    before kernel access. */
426 #define _DRM_FLAG_MEMTYPE_CMA       0x00000010  /* Can't map aperture */
427 #define _DRM_FLAG_MEMTYPE_CSELECT   0x00000020  /* Select caching */
428
429 struct drm_buffer_manager {
430         struct mutex init_mutex;
431         struct mutex evict_mutex;
432         int nice_mode;
433         int initialized;
434         struct drm_file *last_to_validate;
435         struct drm_mem_type_manager man[DRM_BO_MEM_TYPES];
436         struct list_head unfenced;
437         struct list_head ddestroy;
438 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
439         struct work_struct wq;
440 #else
441         struct delayed_work wq;
442 #endif
443         uint32_t fence_type;
444         unsigned long cur_pages;
445         atomic_t count;
446 };
447
448 struct drm_bo_driver {
449         const uint32_t *mem_type_prio;
450         const uint32_t *mem_busy_prio;
451         uint32_t num_mem_type_prio;
452         uint32_t num_mem_busy_prio;
453         struct drm_ttm_backend *(*create_ttm_backend_entry)
454          (struct drm_device * dev);
455         int (*fence_type) (struct drm_buffer_object *bo, uint32_t *fclass,
456                      uint32_t * type);
457         int (*invalidate_caches) (struct drm_device * dev, uint64_t flags);
458         int (*init_mem_type) (struct drm_device * dev, uint32_t type,
459                               struct drm_mem_type_manager * man);
460          uint32_t(*evict_mask) (struct drm_buffer_object *bo);
461         int (*move) (struct drm_buffer_object * bo,
462                      int evict, int no_wait, struct drm_bo_mem_reg * new_mem);
463 };
464
465 /*
466  * buffer objects (drm_bo.c)
467  */
468
469 extern int drm_bo_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
470 extern int drm_bo_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
471 extern int drm_bo_map_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
472 extern int drm_bo_unmap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
473 extern int drm_bo_reference_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
474 extern int drm_bo_unreference_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
475 extern int drm_bo_wait_idle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
476 extern int drm_bo_info_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
477 extern int drm_bo_op_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
478 int drm_bo_set_pin_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
479
480 extern int drm_mm_init_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
481 extern int drm_mm_takedown_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
482 extern int drm_mm_lock_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
483 extern int drm_mm_unlock_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);
484 extern int drm_bo_driver_finish(struct drm_device *dev);
485 extern int drm_bo_driver_init(struct drm_device *dev);
486 extern int drm_bo_pci_offset(struct drm_device *dev,
487                              struct drm_bo_mem_reg * mem,
488                              unsigned long *bus_base,
489                              unsigned long *bus_offset,
490                              unsigned long *bus_size);
491 extern int drm_mem_reg_is_pci(struct drm_device *dev, struct drm_bo_mem_reg * mem);
492
493 extern void drm_bo_usage_deref_locked(struct drm_buffer_object ** bo);
494 extern void drm_bo_usage_deref_unlocked(struct drm_buffer_object ** bo);
495 extern void drm_putback_buffer_objects(struct drm_device *dev);
496 extern int drm_fence_buffer_objects(struct drm_device * dev,
497                                     struct list_head *list,
498                                     uint32_t fence_flags,
499                                     struct drm_fence_object * fence,
500                                     struct drm_fence_object ** used_fence);
501 extern void drm_bo_add_to_lru(struct drm_buffer_object * bo);
502 extern int drm_buffer_object_create(struct drm_device *dev, unsigned long size,
503                                     enum drm_bo_type type, uint64_t mask,
504                                     uint32_t hint, uint32_t page_alignment,
505                                     unsigned long buffer_start,
506                                     struct drm_buffer_object **bo);
507 extern int drm_bo_wait(struct drm_buffer_object * bo, int lazy, int ignore_signals,
508                        int no_wait);
509 extern int drm_bo_mem_space(struct drm_buffer_object * bo,
510                             struct drm_bo_mem_reg * mem, int no_wait);
511 extern int drm_bo_move_buffer(struct drm_buffer_object * bo, uint32_t new_mem_flags,
512                               int no_wait, int move_unfenced);
513 extern int drm_bo_clean_mm(struct drm_device * dev, unsigned mem_type);
514 extern int drm_bo_init_mm(struct drm_device * dev, unsigned type,
515                           unsigned long p_offset, unsigned long p_size);
516 extern int drm_bo_handle_validate(struct drm_file * file_priv, uint32_t handle,
517                                   uint32_t fence_class, uint64_t flags,
518                                   uint64_t mask, uint32_t hint,
519                                   struct drm_bo_info_rep * rep,
520                                   struct drm_buffer_object **bo_rep);
521 extern struct drm_buffer_object *drm_lookup_buffer_object(struct drm_file * file_priv,
522                                                           uint32_t handle,
523                                                           int check_owner);
524 extern int drm_bo_do_validate(struct drm_buffer_object *bo,
525                               uint64_t flags, uint64_t mask, uint32_t hint,
526                               uint32_t fence_class,
527                               int no_wait,
528                               struct drm_bo_info_rep *rep);
529
530 /*
531  * Buffer object memory move- and map helpers.
532  * drm_bo_move.c
533  */
534
535 extern int drm_bo_move_ttm(struct drm_buffer_object * bo,
536                            int evict, int no_wait, struct drm_bo_mem_reg * new_mem);
537 extern int drm_bo_move_memcpy(struct drm_buffer_object * bo,
538                               int evict,
539                               int no_wait, struct drm_bo_mem_reg * new_mem);
540 extern int drm_bo_move_accel_cleanup(struct drm_buffer_object * bo,
541                                      int evict,
542                                      int no_wait,
543                                      uint32_t fence_class,
544                                      uint32_t fence_type,
545                                      uint32_t fence_flags,
546                                      struct drm_bo_mem_reg * new_mem);
547 extern int drm_bo_same_page(unsigned long offset, unsigned long offset2);
548 extern unsigned long drm_bo_offset_end(unsigned long offset,
549                                        unsigned long end);
550
551 struct drm_bo_kmap_obj {
552         void *virtual;
553         struct page *page;
554         enum {
555                 bo_map_iomap,
556                 bo_map_vmap,
557                 bo_map_kmap,
558                 bo_map_premapped,
559         } bo_kmap_type;
560 };
561
562 static inline void *drm_bmo_virtual(struct drm_bo_kmap_obj *map, int *is_iomem)
563 {
564         *is_iomem = (map->bo_kmap_type == bo_map_iomap ||
565                      map->bo_kmap_type == bo_map_premapped);
566         return map->virtual;
567 }
568 extern void drm_bo_kunmap(struct drm_bo_kmap_obj *map);
569 extern int drm_bo_kmap(struct drm_buffer_object *bo, unsigned long start_page,
570                        unsigned long num_pages, struct drm_bo_kmap_obj *map);
571
572
573 /*
574  * drm_regman.c
575  */
576
577 struct drm_reg {
578         struct list_head head;
579         struct drm_fence_object *fence;
580         uint32_t fence_type;
581         uint32_t new_fence_type;
582 };
583
584 struct drm_reg_manager {
585         struct list_head free;
586         struct list_head lru;
587         struct list_head unfenced;
588
589         int (*reg_reusable)(const struct drm_reg *reg, const void *data);
590         void (*reg_destroy)(struct drm_reg *reg);
591 };
592
593 extern int drm_regs_alloc(struct drm_reg_manager *manager,
594                           const void *data,
595                           uint32_t fence_class,
596                           uint32_t fence_type,
597                           int interruptible,
598                           int no_wait,
599                           struct drm_reg **reg);
600
601 extern void drm_regs_fence(struct drm_reg_manager *regs,
602                            struct drm_fence_object *fence);
603
604 extern void drm_regs_free(struct drm_reg_manager *manager);
605 extern void drm_regs_add(struct drm_reg_manager *manager, struct drm_reg *reg);
606 extern void drm_regs_init(struct drm_reg_manager *manager,
607                           int (*reg_reusable)(const struct drm_reg *,
608                                               const void *),
609                           void (*reg_destroy)(struct drm_reg *));
610
611 #ifdef CONFIG_DEBUG_MUTEXES
612 #define DRM_ASSERT_LOCKED(_mutex)                                       \
613         BUG_ON(!mutex_is_locked(_mutex) ||                              \
614                ((_mutex)->owner != current_thread_info()))
615 #else
616 #define DRM_ASSERT_LOCKED(_mutex)
617 #endif
618 #endif