aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/qxl/qxl_object.h
diff options
context:
space:
mode:
authorDave Airlie <airlied@gmail.com>2013-02-24 23:47:55 -0500
committerDave Airlie <airlied@redhat.com>2013-04-11 23:51:07 -0400
commitf64122c1f6ade301585569863b4b3b18f6e4e332 (patch)
tree1eb6629931604584f6fff28c0b9a1c9a3d9024f3 /drivers/gpu/drm/qxl/qxl_object.h
parentafe6804c045fbd69a1b75c681107b5d6df9190de (diff)
drm: add new QXL driver. (v1.4)
QXL is a paravirtual graphics device used by the Spice virtual desktop interface. The drivers uses GEM and TTM to manage memory, the qxl hw fencing however is quite different than normal TTM expects, we have to keep track of a number of non-linear fence ids per bo that we need to have released by the hardware. The releases are freed from a workqueue that wakes up and processes the release ring. releases are suballocated from a BO, there are 3 release categories, drawables, surfaces and cursor cmds. The hw also has 3 rings for commands, cursor and release handling. The hardware also have a surface id tracking mechnaism and the driver encapsulates it completely inside the kernel, userspace never sees the actual hw surface ids. This requires a newer version of the QXL userspace driver, so shouldn't be enabled until that has been placed into your distro of choice. Authors: Dave Airlie, Alon Levy v1.1: fixup some issues in the ioctl interface with padding v1.2: add module device table v1.3: fix nomodeset, fbcon leak, dumb bo create, release ring irq, don't try flush release ring (broken hw), fix -modesetting. v1.4: fbcon cpu usage reduction + suitable accel flags. Signed-off-by: Alon Levy <alevy@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/qxl/qxl_object.h')
-rw-r--r--drivers/gpu/drm/qxl/qxl_object.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/drivers/gpu/drm/qxl/qxl_object.h b/drivers/gpu/drm/qxl/qxl_object.h
new file mode 100644
index 000000000000..b4fd89fbd8b7
--- /dev/null
+++ b/drivers/gpu/drm/qxl/qxl_object.h
@@ -0,0 +1,112 @@
1/*
2 * Copyright 2013 Red Hat Inc.
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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.
21 *
22 * Authors: Dave Airlie
23 * Alon Levy
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, 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);
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 bool qxl_bo_is_reserved(struct qxl_bo *bo)
61{
62 return !!atomic_read(&bo->tbo.reserved);
63}
64
65static inline u64 qxl_bo_mmap_offset(struct qxl_bo *bo)
66{
67 return bo->tbo.addr_space_offset;
68}
69
70static inline int qxl_bo_wait(struct qxl_bo *bo, u32 *mem_type,
71 bool no_wait)
72{
73 int r;
74
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",
80 bo);
81 }
82 return r;
83 }
84 spin_lock(&bo->tbo.bdev->fence_lock);
85 if (mem_type)
86 *mem_type = bo->tbo.mem.mem_type;
87 if (bo->tbo.sync_obj)
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);
91 return r;
92}
93
94extern int qxl_bo_create(struct qxl_device *qdev,
95 unsigned long size,
96 bool kernel, u32 domain,
97 struct qxl_surface *surf,
98 struct qxl_bo **bo_ptr);
99extern int qxl_bo_kmap(struct qxl_bo *bo, void **ptr);
100extern void qxl_bo_kunmap(struct qxl_bo *bo);
101void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, int page_offset);
102void qxl_bo_kunmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, void *map);
103extern struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo);
104extern void qxl_bo_unref(struct qxl_bo **bo);
105extern int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr);
106extern int qxl_bo_unpin(struct qxl_bo *bo);
107extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain);
108extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo);
109
110extern int qxl_bo_list_add(struct qxl_reloc_list *reloc_list, struct qxl_bo *bo);
111extern void qxl_bo_list_unreserve(struct qxl_reloc_list *reloc_list, bool failed);
112#endif