ttm_bo_api.h 20 KB

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