ttm_bo_api.h 21 KB

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