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#ifndef QXL_OBJECT_H
26#define QXL_OBJECT_H
27
28#include "qxl_drv.h"
29
30static inline int qxl_bo_reserve(struct qxl_bo *bo, bool no_wait)
31{
32 int r;
33
34 r = ttm_bo_reserve(&bo->tbo, true, no_wait, NULL);
35 if (unlikely(r != 0)) {
36 if (r != -ERESTARTSYS) {
37 struct drm_device *ddev = bo->gem_base.dev;
38 dev_err(ddev->dev, "%p reserve failed\n", bo);
39 }
40 return r;
41 }
42 return 0;
43}
44
45static inline void qxl_bo_unreserve(struct qxl_bo *bo)
46{
47 ttm_bo_unreserve(&bo->tbo);
48}
49
50static inline u64 qxl_bo_gpu_offset(struct qxl_bo *bo)
51{
52 return bo->tbo.offset;
53}
54
55static inline unsigned long qxl_bo_size(struct qxl_bo *bo)
56{
57 return bo->tbo.num_pages << PAGE_SHIFT;
58}
59
60static inline u64 qxl_bo_mmap_offset(struct qxl_bo *bo)
61{
62 return drm_vma_node_offset_addr(&bo->tbo.vma_node);
63}
64
65static inline int qxl_bo_wait(struct qxl_bo *bo, u32 *mem_type,
66 bool no_wait)
67{
68 int r;
69
70 r = ttm_bo_reserve(&bo->tbo, true, no_wait, NULL);
71 if (unlikely(r != 0)) {
72 if (r != -ERESTARTSYS) {
73 struct drm_device *ddev = bo->gem_base.dev;
74 dev_err(ddev->dev, "%p reserve failed for wait\n",
75 bo);
76 }
77 return r;
78 }
79 if (mem_type)
80 *mem_type = bo->tbo.mem.mem_type;
81
82 r = ttm_bo_wait(&bo->tbo, true, no_wait);
83 ttm_bo_unreserve(&bo->tbo);
84 return r;
85}
86
87extern int qxl_bo_create(struct qxl_device *qdev,
88 unsigned long size,
89 bool kernel, bool pinned, u32 domain,
90 struct qxl_surface *surf,
91 struct qxl_bo **bo_ptr);
92extern int qxl_bo_kmap(struct qxl_bo *bo, void **ptr);
93extern void qxl_bo_kunmap(struct qxl_bo *bo);
94void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, int page_offset);
95void qxl_bo_kunmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, void *map);
96extern struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo);
97extern void qxl_bo_unref(struct qxl_bo **bo);
98extern int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr);
99extern int qxl_bo_unpin(struct qxl_bo *bo);
100extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned);
101extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo);
102
103#endif
104