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