2 * Copyright 2013 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 * Authors: Dave Airlie
30 static inline int qxl_bo_reserve(struct qxl_bo
*bo
, bool no_wait
)
34 r
= ttm_bo_reserve(&bo
->tbo
, true, no_wait
, false, 0);
35 if (unlikely(r
!= 0)) {
36 if (r
!= -ERESTARTSYS
) {
37 struct qxl_device
*qdev
= (struct qxl_device
*)bo
->gem_base
.dev
->dev_private
;
38 dev_err(qdev
->dev
, "%p reserve failed\n", bo
);
45 static inline void qxl_bo_unreserve(struct qxl_bo
*bo
)
47 ttm_bo_unreserve(&bo
->tbo
);
50 static inline u64
qxl_bo_gpu_offset(struct qxl_bo
*bo
)
52 return bo
->tbo
.offset
;
55 static inline unsigned long qxl_bo_size(struct qxl_bo
*bo
)
57 return bo
->tbo
.num_pages
<< PAGE_SHIFT
;
60 static inline bool qxl_bo_is_reserved(struct qxl_bo
*bo
)
62 return !!atomic_read(&bo
->tbo
.reserved
);
65 static inline u64
qxl_bo_mmap_offset(struct qxl_bo
*bo
)
67 return bo
->tbo
.addr_space_offset
;
70 static inline int qxl_bo_wait(struct qxl_bo
*bo
, u32
*mem_type
,
75 r
= ttm_bo_reserve(&bo
->tbo
, true, no_wait
, false, 0);
76 if (unlikely(r
!= 0)) {
77 if (r
!= -ERESTARTSYS
) {
78 struct qxl_device
*qdev
= (struct qxl_device
*)bo
->gem_base
.dev
->dev_private
;
79 dev_err(qdev
->dev
, "%p reserve failed for wait\n",
84 spin_lock(&bo
->tbo
.bdev
->fence_lock
);
86 *mem_type
= bo
->tbo
.mem
.mem_type
;
88 r
= ttm_bo_wait(&bo
->tbo
, true, true, no_wait
);
89 spin_unlock(&bo
->tbo
.bdev
->fence_lock
);
90 ttm_bo_unreserve(&bo
->tbo
);
94 extern int qxl_bo_create(struct qxl_device
*qdev
,
96 bool kernel
, u32 domain
,
97 struct qxl_surface
*surf
,
98 struct qxl_bo
**bo_ptr
);
99 extern int qxl_bo_kmap(struct qxl_bo
*bo
, void **ptr
);
100 extern void qxl_bo_kunmap(struct qxl_bo
*bo
);
101 void *qxl_bo_kmap_atomic_page(struct qxl_device
*qdev
, struct qxl_bo
*bo
, int page_offset
);
102 void qxl_bo_kunmap_atomic_page(struct qxl_device
*qdev
, struct qxl_bo
*bo
, void *map
);
103 extern struct qxl_bo
*qxl_bo_ref(struct qxl_bo
*bo
);
104 extern void qxl_bo_unref(struct qxl_bo
**bo
);
105 extern int qxl_bo_pin(struct qxl_bo
*bo
, u32 domain
, u64
*gpu_addr
);
106 extern int qxl_bo_unpin(struct qxl_bo
*bo
);
107 extern void qxl_ttm_placement_from_domain(struct qxl_bo
*qbo
, u32 domain
);
108 extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object
*bo
);
110 extern int qxl_bo_list_add(struct qxl_reloc_list
*reloc_list
, struct qxl_bo
*bo
);
111 extern void qxl_bo_list_unreserve(struct qxl_reloc_list
*reloc_list
, bool failed
);
This page took 0.033491 seconds and 6 git commands to generate.