Subversion Repositories Kolibri OS

Rev

Rev 2003 | Rev 4065 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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