Merge tag 'gcc-plugins-v4.9-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / include / drm / ttm / ttm_bo_api.h
1 /**************************************************************************
2  *
3  * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., 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 Hellstrom <thellstrom-at-vmware-dot-com>
29  */
30
31 #ifndef _TTM_BO_API_H_
32 #define _TTM_BO_API_H_
33
34 #include <drm/drm_hashtab.h>
35 #include <drm/drm_vma_manager.h>
36 #include <linux/kref.h>
37 #include <linux/list.h>
38 #include <linux/wait.h>
39 #include <linux/mutex.h>
40 #include <linux/mm.h>
41 #include <linux/bitmap.h>
42 #include <linux/reservation.h>
43
44 struct ttm_bo_device;
45
46 struct drm_mm_node;
47
48 struct ttm_placement;
49
50 /**
51  * struct ttm_bus_placement
52  *
53  * @addr:               mapped virtual address
54  * @base:               bus base address
55  * @is_iomem:           is this io memory ?
56  * @size:               size in byte
57  * @offset:             offset from the base address
58  * @io_reserved_vm:     The VM system has a refcount in @io_reserved_count
59  * @io_reserved_count:  Refcounting the numbers of callers to ttm_mem_io_reserve
60  *
61  * Structure indicating the bus placement of an object.
62  */
63 struct ttm_bus_placement {
64         void            *addr;
65         phys_addr_t     base;
66         unsigned long   size;
67         unsigned long   offset;
68         bool            is_iomem;
69         bool            io_reserved_vm;
70         uint64_t        io_reserved_count;
71 };
72
73
74 /**
75  * struct ttm_mem_reg
76  *
77  * @mm_node: Memory manager node.
78  * @size: Requested size of memory region.
79  * @num_pages: Actual size of memory region in pages.
80  * @page_alignment: Page alignment.
81  * @placement: Placement flags.
82  * @bus: Placement on io bus accessible to the CPU
83  *
84  * Structure indicating the placement and space resources used by a
85  * buffer object.
86  */
87
88 struct ttm_mem_reg {
89         void *mm_node;
90         unsigned long start;
91         unsigned long size;
92         unsigned long num_pages;
93         uint32_t page_alignment;
94         uint32_t mem_type;
95         uint32_t placement;
96         struct ttm_bus_placement bus;
97 };
98
99 /**
100  * enum ttm_bo_type
101  *
102  * @ttm_bo_type_device: These are 'normal' buffers that can
103  * be mmapped by user space. Each of these bos occupy a slot in the
104  * device address space, that can be used for normal vm operations.
105  *
106  * @ttm_bo_type_kernel: These buffers are like ttm_bo_type_device buffers,
107  * but they cannot be accessed from user-space. For kernel-only use.
108  *
109  * @ttm_bo_type_sg: Buffer made from dmabuf sg table shared with another
110  * driver.
111  */
112
113 enum ttm_bo_type {
114         ttm_bo_type_device,
115         ttm_bo_type_kernel,
116         ttm_bo_type_sg
117 };
118
119 struct ttm_tt;
120
121 /**
122  * struct ttm_buffer_object
123  *
124  * @bdev: Pointer to the buffer object device structure.
125  * @type: The bo type.
126  * @destroy: Destruction function. If NULL, kfree is used.
127  * @num_pages: Actual number of pages.
128  * @acc_size: Accounted size for this object.
129  * @kref: Reference count of this buffer object. When this refcount reaches
130  * zero, the object is put on the delayed delete list.
131  * @list_kref: List reference count of this buffer object. This member is
132  * used to avoid destruction while the buffer object is still on a list.
133  * Lru lists may keep one refcount, the delayed delete list, and kref != 0
134  * keeps one refcount. When this refcount reaches zero,
135  * the object is destroyed.
136  * @mem: structure describing current placement.
137  * @persistent_swap_storage: Usually the swap storage is deleted for buffers
138  * pinned in physical memory. If this behaviour is not desired, this member
139  * holds a pointer to a persistent shmem object.
140  * @ttm: TTM structure holding system pages.
141  * @evicted: Whether the object was evicted without user-space knowing.
142  * @cpu_writes: For synchronization. Number of cpu writers.
143  * @lru: List head for the lru list.
144  * @ddestroy: List head for the delayed destroy list.
145  * @swap: List head for swap LRU list.
146  * @moving: Fence set when BO is moving
147  * @vma_node: Address space manager node.
148  * @offset: The current GPU offset, which can have different meanings
149  * depending on the memory type. For SYSTEM type memory, it should be 0.
150  * @cur_placement: Hint of current placement.
151  * @wu_mutex: Wait unreserved mutex.
152  *
153  * Base class for TTM buffer object, that deals with data placement and CPU
154  * mappings. GPU mappings are really up to the driver, but for simpler GPUs
155  * the driver can usually use the placement offset @offset directly as the
156  * GPU virtual address. For drivers implementing multiple
157  * GPU memory manager contexts, the driver should manage the address space
158  * in these contexts separately and use these objects to get the correct
159  * placement and caching for these GPU maps. This makes it possible to use
160  * these objects for even quite elaborate memory management schemes.
161  * The destroy member, the API visibility of this object makes it possible
162  * to derive driver specific types.
163  */
164
165 struct ttm_buffer_object {
166         /**
167          * Members constant at init.
168          */
169
170         struct ttm_bo_global *glob;
171         struct ttm_bo_device *bdev;
172         enum ttm_bo_type type;
173         void (*destroy) (struct ttm_buffer_object *);
174         unsigned long num_pages;
175         size_t acc_size;
176
177         /**
178         * Members not needing protection.
179         */
180
181         struct kref kref;
182         struct kref list_kref;
183
184         /**
185          * Members protected by the bo::resv::reserved lock.
186          */
187
188         struct ttm_mem_reg mem;
189         struct file *persistent_swap_storage;
190         struct ttm_tt *ttm;
191         bool evicted;
192
193         /**
194          * Members protected by the bo::reserved lock only when written to.
195          */
196
197         atomic_t cpu_writers;
198
199         /**
200          * Members protected by the bdev::lru_lock.
201          */
202
203         struct list_head lru;
204         struct list_head ddestroy;
205         struct list_head swap;
206         struct list_head io_reserve_lru;
207
208         /**
209          * Members protected by a bo reservation.
210          */
211
212         struct fence *moving;
213
214         struct drm_vma_offset_node vma_node;
215
216         /**
217          * Special members that are protected by the reserve lock
218          * and the bo::lock when written to. Can be read with
219          * either of these locks held.
220          */
221
222         uint64_t offset; /* GPU address space is independent of CPU word size */
223         uint32_t cur_placement;
224
225         struct sg_table *sg;
226
227         struct reservation_object *resv;
228         struct reservation_object ttm_resv;
229         struct mutex wu_mutex;
230 };
231
232 /**
233  * struct ttm_bo_kmap_obj
234  *
235  * @virtual: The current kernel virtual address.
236  * @page: The page when kmap'ing a single page.
237  * @bo_kmap_type: Type of bo_kmap.
238  *
239  * Object describing a kernel mapping. Since a TTM bo may be located
240  * in various memory types with various caching policies, the
241  * mapping can either be an ioremap, a vmap, a kmap or part of a
242  * premapped region.
243  */
244
245 #define TTM_BO_MAP_IOMEM_MASK 0x80
246 struct ttm_bo_kmap_obj {
247         void *virtual;
248         struct page *page;
249         enum {
250                 ttm_bo_map_iomap        = 1 | TTM_BO_MAP_IOMEM_MASK,
251                 ttm_bo_map_vmap         = 2,
252                 ttm_bo_map_kmap         = 3,
253                 ttm_bo_map_premapped    = 4 | TTM_BO_MAP_IOMEM_MASK,
254         } bo_kmap_type;
255         struct ttm_buffer_object *bo;
256 };
257
258 /**
259  * ttm_bo_reference - reference a struct ttm_buffer_object
260  *
261  * @bo: The buffer object.
262  *
263  * Returns a refcounted pointer to a buffer object.
264  */
265
266 static inline struct ttm_buffer_object *
267 ttm_bo_reference(struct ttm_buffer_object *bo)
268 {
269         kref_get(&bo->kref);
270         return bo;
271 }
272
273 /**
274  * ttm_bo_wait - wait for buffer idle.
275  *
276  * @bo:  The buffer object.
277  * @interruptible:  Use interruptible wait.
278  * @no_wait:  Return immediately if buffer is busy.
279  *
280  * This function must be called with the bo::mutex held, and makes
281  * sure any previous rendering to the buffer is completed.
282  * Note: It might be necessary to block validations before the
283  * wait by reserving the buffer.
284  * Returns -EBUSY if no_wait is true and the buffer is busy.
285  * Returns -ERESTARTSYS if interrupted by a signal.
286  */
287 extern int ttm_bo_wait(struct ttm_buffer_object *bo,
288                        bool interruptible, bool no_wait);
289
290 /**
291  * ttm_bo_mem_compat - Check if proposed placement is compatible with a bo
292  *
293  * @placement:  Return immediately if buffer is busy.
294  * @mem:  The struct ttm_mem_reg indicating the region where the bo resides
295  * @new_flags: Describes compatible placement found
296  *
297  * Returns true if the placement is compatible
298  */
299 extern bool ttm_bo_mem_compat(struct ttm_placement *placement,
300                               struct ttm_mem_reg *mem,
301                               uint32_t *new_flags);
302
303 /**
304  * ttm_bo_validate
305  *
306  * @bo: The buffer object.
307  * @placement: Proposed placement for the buffer object.
308  * @interruptible: Sleep interruptible if sleeping.
309  * @no_wait_gpu: Return immediately if the GPU is busy.
310  *
311  * Changes placement and caching policy of the buffer object
312  * according proposed placement.
313  * Returns
314  * -EINVAL on invalid proposed placement.
315  * -ENOMEM on out-of-memory condition.
316  * -EBUSY if no_wait is true and buffer busy.
317  * -ERESTARTSYS if interrupted by a signal.
318  */
319 extern int ttm_bo_validate(struct ttm_buffer_object *bo,
320                                 struct ttm_placement *placement,
321                                 bool interruptible,
322                                 bool no_wait_gpu);
323
324 /**
325  * ttm_bo_unref
326  *
327  * @bo: The buffer object.
328  *
329  * Unreference and clear a pointer to a buffer object.
330  */
331 extern void ttm_bo_unref(struct ttm_buffer_object **bo);
332
333
334 /**
335  * ttm_bo_list_ref_sub
336  *
337  * @bo: The buffer object.
338  * @count: The number of references with which to decrease @bo::list_kref;
339  * @never_free: The refcount should not reach zero with this operation.
340  *
341  * Release @count lru list references to this buffer object.
342  */
343 extern void ttm_bo_list_ref_sub(struct ttm_buffer_object *bo, int count,
344                                 bool never_free);
345
346 /**
347  * ttm_bo_add_to_lru
348  *
349  * @bo: The buffer object.
350  *
351  * Add this bo to the relevant mem type lru and, if it's backed by
352  * system pages (ttms) to the swap list.
353  * This function must be called with struct ttm_bo_global::lru_lock held, and
354  * is typically called immediately prior to unreserving a bo.
355  */
356 extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
357
358 /**
359  * ttm_bo_del_from_lru
360  *
361  * @bo: The buffer object.
362  *
363  * Remove this bo from all lru lists used to lookup and reserve an object.
364  * This function must be called with struct ttm_bo_global::lru_lock held,
365  * and is usually called just immediately after the bo has been reserved to
366  * avoid recursive reservation from lru lists.
367  */
368 extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo);
369
370 /**
371  * ttm_bo_move_to_lru_tail
372  *
373  * @bo: The buffer object.
374  *
375  * Move this BO to the tail of all lru lists used to lookup and reserve an
376  * object. This function must be called with struct ttm_bo_global::lru_lock
377  * held, and is used to make a BO less likely to be considered for eviction.
378  */
379 extern void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo);
380
381 /**
382  * ttm_bo_lock_delayed_workqueue
383  *
384  * Prevent the delayed workqueue from running.
385  * Returns
386  * True if the workqueue was queued at the time
387  */
388 extern int ttm_bo_lock_delayed_workqueue(struct ttm_bo_device *bdev);
389
390 /**
391  * ttm_bo_unlock_delayed_workqueue
392  *
393  * Allows the delayed workqueue to run.
394  */
395 extern void ttm_bo_unlock_delayed_workqueue(struct ttm_bo_device *bdev,
396                                             int resched);
397
398 /**
399  * ttm_bo_synccpu_write_grab
400  *
401  * @bo: The buffer object:
402  * @no_wait: Return immediately if buffer is busy.
403  *
404  * Synchronizes a buffer object for CPU RW access. This means
405  * command submission that affects the buffer will return -EBUSY
406  * until ttm_bo_synccpu_write_release is called.
407  *
408  * Returns
409  * -EBUSY if the buffer is busy and no_wait is true.
410  * -ERESTARTSYS if interrupted by a signal.
411  */
412 extern int
413 ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait);
414
415 /**
416  * ttm_bo_synccpu_write_release:
417  *
418  * @bo : The buffer object.
419  *
420  * Releases a synccpu lock.
421  */
422 extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo);
423
424 /**
425  * ttm_bo_acc_size
426  *
427  * @bdev: Pointer to a ttm_bo_device struct.
428  * @bo_size: size of the buffer object in byte.
429  * @struct_size: size of the structure holding buffer object datas
430  *
431  * Returns size to account for a buffer object
432  */
433 size_t ttm_bo_acc_size(struct ttm_bo_device *bdev,
434                        unsigned long bo_size,
435                        unsigned struct_size);
436 size_t ttm_bo_dma_acc_size(struct ttm_bo_device *bdev,
437                            unsigned long bo_size,
438                            unsigned struct_size);
439
440 /**
441  * ttm_bo_init
442  *
443  * @bdev: Pointer to a ttm_bo_device struct.
444  * @bo: Pointer to a ttm_buffer_object to be initialized.
445  * @size: Requested size of buffer object.
446  * @type: Requested type of buffer object.
447  * @flags: Initial placement flags.
448  * @page_alignment: Data alignment in pages.
449  * @interruptible: If needing to sleep to wait for GPU resources,
450  * sleep interruptible.
451  * @persistent_swap_storage: Usually the swap storage is deleted for buffers
452  * pinned in physical memory. If this behaviour is not desired, this member
453  * holds a pointer to a persistent shmem object. Typically, this would
454  * point to the shmem object backing a GEM object if TTM is used to back a
455  * GEM user interface.
456  * @acc_size: Accounted size for this object.
457  * @resv: Pointer to a reservation_object, or NULL to let ttm allocate one.
458  * @destroy: Destroy function. Use NULL for kfree().
459  *
460  * This function initializes a pre-allocated struct ttm_buffer_object.
461  * As this object may be part of a larger structure, this function,
462  * together with the @destroy function,
463  * enables driver-specific objects derived from a ttm_buffer_object.
464  * On successful return, the object kref and list_kref are set to 1.
465  * If a failure occurs, the function will call the @destroy function, or
466  * kfree() if @destroy is NULL. Thus, after a failure, dereferencing @bo is
467  * illegal and will likely cause memory corruption.
468  *
469  * Returns
470  * -ENOMEM: Out of memory.
471  * -EINVAL: Invalid placement flags.
472  * -ERESTARTSYS: Interrupted by signal while sleeping waiting for resources.
473  */
474
475 extern int ttm_bo_init(struct ttm_bo_device *bdev,
476                         struct ttm_buffer_object *bo,
477                         unsigned long size,
478                         enum ttm_bo_type type,
479                         struct ttm_placement *placement,
480                         uint32_t page_alignment,
481                         bool interrubtible,
482                         struct file *persistent_swap_storage,
483                         size_t acc_size,
484                         struct sg_table *sg,
485                         struct reservation_object *resv,
486                         void (*destroy) (struct ttm_buffer_object *));
487
488 /**
489  * ttm_bo_create
490  *
491  * @bdev: Pointer to a ttm_bo_device struct.
492  * @size: Requested size of buffer object.
493  * @type: Requested type of buffer object.
494  * @placement: Initial placement.
495  * @page_alignment: Data alignment in pages.
496  * @interruptible: If needing to sleep while waiting for GPU resources,
497  * sleep interruptible.
498  * @persistent_swap_storage: Usually the swap storage is deleted for buffers
499  * pinned in physical memory. If this behaviour is not desired, this member
500  * holds a pointer to a persistent shmem object. Typically, this would
501  * point to the shmem object backing a GEM object if TTM is used to back a
502  * GEM user interface.
503  * @p_bo: On successful completion *p_bo points to the created object.
504  *
505  * This function allocates a ttm_buffer_object, and then calls ttm_bo_init
506  * on that object. The destroy function is set to kfree().
507  * Returns
508  * -ENOMEM: Out of memory.
509  * -EINVAL: Invalid placement flags.
510  * -ERESTARTSYS: Interrupted by signal while waiting for resources.
511  */
512
513 extern int ttm_bo_create(struct ttm_bo_device *bdev,
514                                 unsigned long size,
515                                 enum ttm_bo_type type,
516                                 struct ttm_placement *placement,
517                                 uint32_t page_alignment,
518                                 bool interruptible,
519                                 struct file *persistent_swap_storage,
520                                 struct ttm_buffer_object **p_bo);
521
522 /**
523  * ttm_bo_init_mm
524  *
525  * @bdev: Pointer to a ttm_bo_device struct.
526  * @mem_type: The memory type.
527  * @p_size: size managed area in pages.
528  *
529  * Initialize a manager for a given memory type.
530  * Note: if part of driver firstopen, it must be protected from a
531  * potentially racing lastclose.
532  * Returns:
533  * -EINVAL: invalid size or memory type.
534  * -ENOMEM: Not enough memory.
535  * May also return driver-specified errors.
536  */
537
538 extern int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
539                                 unsigned long p_size);
540 /**
541  * ttm_bo_clean_mm
542  *
543  * @bdev: Pointer to a ttm_bo_device struct.
544  * @mem_type: The memory type.
545  *
546  * Take down a manager for a given memory type after first walking
547  * the LRU list to evict any buffers left alive.
548  *
549  * Normally, this function is part of lastclose() or unload(), and at that
550  * point there shouldn't be any buffers left created by user-space, since
551  * there should've been removed by the file descriptor release() method.
552  * However, before this function is run, make sure to signal all sync objects,
553  * and verify that the delayed delete queue is empty. The driver must also
554  * make sure that there are no NO_EVICT buffers present in this memory type
555  * when the call is made.
556  *
557  * If this function is part of a VT switch, the caller must make sure that
558  * there are no appications currently validating buffers before this
559  * function is called. The caller can do that by first taking the
560  * struct ttm_bo_device::ttm_lock in write mode.
561  *
562  * Returns:
563  * -EINVAL: invalid or uninitialized memory type.
564  * -EBUSY: There are still buffers left in this memory type.
565  */
566
567 extern int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type);
568
569 /**
570  * ttm_bo_evict_mm
571  *
572  * @bdev: Pointer to a ttm_bo_device struct.
573  * @mem_type: The memory type.
574  *
575  * Evicts all buffers on the lru list of the memory type.
576  * This is normally part of a VT switch or an
577  * out-of-memory-space-due-to-fragmentation handler.
578  * The caller must make sure that there are no other processes
579  * currently validating buffers, and can do that by taking the
580  * struct ttm_bo_device::ttm_lock in write mode.
581  *
582  * Returns:
583  * -EINVAL: Invalid or uninitialized memory type.
584  * -ERESTARTSYS: The call was interrupted by a signal while waiting to
585  * evict a buffer.
586  */
587
588 extern int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type);
589
590 /**
591  * ttm_kmap_obj_virtual
592  *
593  * @map: A struct ttm_bo_kmap_obj returned from ttm_bo_kmap.
594  * @is_iomem: Pointer to an integer that on return indicates 1 if the
595  * virtual map is io memory, 0 if normal memory.
596  *
597  * Returns the virtual address of a buffer object area mapped by ttm_bo_kmap.
598  * If *is_iomem is 1 on return, the virtual address points to an io memory area,
599  * that should strictly be accessed by the iowriteXX() and similar functions.
600  */
601
602 static inline void *ttm_kmap_obj_virtual(struct ttm_bo_kmap_obj *map,
603                                          bool *is_iomem)
604 {
605         *is_iomem = !!(map->bo_kmap_type & TTM_BO_MAP_IOMEM_MASK);
606         return map->virtual;
607 }
608
609 /**
610  * ttm_bo_kmap
611  *
612  * @bo: The buffer object.
613  * @start_page: The first page to map.
614  * @num_pages: Number of pages to map.
615  * @map: pointer to a struct ttm_bo_kmap_obj representing the map.
616  *
617  * Sets up a kernel virtual mapping, using ioremap, vmap or kmap to the
618  * data in the buffer object. The ttm_kmap_obj_virtual function can then be
619  * used to obtain a virtual address to the data.
620  *
621  * Returns
622  * -ENOMEM: Out of memory.
623  * -EINVAL: Invalid range.
624  */
625
626 extern int ttm_bo_kmap(struct ttm_buffer_object *bo, unsigned long start_page,
627                        unsigned long num_pages, struct ttm_bo_kmap_obj *map);
628
629 /**
630  * ttm_bo_kunmap
631  *
632  * @map: Object describing the map to unmap.
633  *
634  * Unmaps a kernel map set up by ttm_bo_kmap.
635  */
636
637 extern void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map);
638
639 /**
640  * ttm_fbdev_mmap - mmap fbdev memory backed by a ttm buffer object.
641  *
642  * @vma:       vma as input from the fbdev mmap method.
643  * @bo:        The bo backing the address space. The address space will
644  * have the same size as the bo, and start at offset 0.
645  *
646  * This function is intended to be called by the fbdev mmap method
647  * if the fbdev address space is to be backed by a bo.
648  */
649
650 extern int ttm_fbdev_mmap(struct vm_area_struct *vma,
651                           struct ttm_buffer_object *bo);
652
653 /**
654  * ttm_bo_mmap - mmap out of the ttm device address space.
655  *
656  * @filp:      filp as input from the mmap method.
657  * @vma:       vma as input from the mmap method.
658  * @bdev:      Pointer to the ttm_bo_device with the address space manager.
659  *
660  * This function is intended to be called by the device mmap method.
661  * if the device address space is to be backed by the bo manager.
662  */
663
664 extern int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
665                        struct ttm_bo_device *bdev);
666
667 /**
668  * ttm_bo_io
669  *
670  * @bdev:      Pointer to the struct ttm_bo_device.
671  * @filp:      Pointer to the struct file attempting to read / write.
672  * @wbuf:      User-space pointer to address of buffer to write. NULL on read.
673  * @rbuf:      User-space pointer to address of buffer to read into.
674  * Null on write.
675  * @count:     Number of bytes to read / write.
676  * @f_pos:     Pointer to current file position.
677  * @write:     1 for read, 0 for write.
678  *
679  * This function implements read / write into ttm buffer objects, and is
680  * intended to
681  * be called from the fops::read and fops::write method.
682  * Returns:
683  * See man (2) write, man(2) read. In particular,
684  * the function may return -ERESTARTSYS if
685  * interrupted by a signal.
686  */
687
688 extern ssize_t ttm_bo_io(struct ttm_bo_device *bdev, struct file *filp,
689                          const char __user *wbuf, char __user *rbuf,
690                          size_t count, loff_t *f_pos, bool write);
691
692 extern void ttm_bo_swapout_all(struct ttm_bo_device *bdev);
693 extern int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo);
694 #endif