1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#ifndef QXL_OBJECT_H
#define QXL_OBJECT_H
#include "qxl_drv.h"
static inline int qxl_bo_reserve(struct qxl_bo *bo, bool no_wait)
{
int r;
r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0);
if (unlikely(r != 0)) {
if (r != -ERESTARTSYS)
dev_err(bo->qdev->dev, "%p reserve failed\n", bo);
return r;
}
return 0;
}
static inline void qxl_bo_unreserve(struct qxl_bo *bo)
{
ttm_bo_unreserve(&bo->tbo);
}
static inline u64 qxl_bo_gpu_offset(struct qxl_bo *bo)
{
return bo->tbo.offset;
}
static inline unsigned long qxl_bo_size(struct qxl_bo *bo)
{
return bo->tbo.num_pages << PAGE_SHIFT;
}
static inline bool qxl_bo_is_reserved(struct qxl_bo *bo)
{
return !!atomic_read(&bo->tbo.reserved);
}
static inline u64 qxl_bo_mmap_offset(struct qxl_bo *bo)
{
return bo->tbo.addr_space_offset;
}
static inline int qxl_bo_wait(struct qxl_bo *bo, u32 *mem_type,
bool no_wait)
{
int r;
r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0);
if (unlikely(r != 0)) {
if (r != -ERESTARTSYS)
dev_err(bo->qdev->dev, "%p reserve failed for wait\n", bo);
return r;
}
spin_lock(&bo->tbo.bdev->fence_lock);
if (mem_type)
*mem_type = bo->tbo.mem.mem_type;
if (bo->tbo.sync_obj)
r = ttm_bo_wait(&bo->tbo, true, true, no_wait);
spin_unlock(&bo->tbo.bdev->fence_lock);
ttm_bo_unreserve(&bo->tbo);
return r;
}
extern int qxl_bo_create(struct qxl_device *qdev,
unsigned long size,
bool kernel, u32 domain,
struct qxl_bo **bo_ptr);
extern void qxl_bo_free(struct qxl_bo *bo);
extern int qxl_bo_kmap(struct qxl_bo *bo, void **ptr);
extern void qxl_bo_kunmap(struct qxl_bo *bo);
extern void qxl_bo_unref(struct qxl_bo **bo);
extern int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr);
extern int qxl_bo_unpin(struct qxl_bo *bo);
extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain);
extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo);
#endif // QXL_OBJECT_H
|