ttm_bo_api.h 20 KB

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