diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-04-30 12:33:43 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-05-24 02:55:41 -0400 |
commit | 20abd1634a6e2eedb84ca977adea56b8aa06cc3e (patch) | |
tree | 32eca9cf843cf2aa5163b15e76f833691eb306a2 /drivers/gpu/drm/nouveau/nv50_software.c | |
parent | 2cda7f4c5e83925fe687f63625893e033358de4e (diff) |
drm/nouveau: create real execution engine for software object class
Just a cleanup more or less, and to remove the need for special handling of
software objects.
This removes a heap of documentation on dma/graph object formats. The info
is very out of date with our current understanding, and is far better
documented in rnndb in envytools git.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nv50_software.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nv50_software.c | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nv50_software.c b/drivers/gpu/drm/nouveau/nv50_software.c new file mode 100644 index 000000000000..0e64d80d5363 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nv50_software.c | |||
@@ -0,0 +1,190 @@ | |||
1 | /* | ||
2 | * Copyright 2012 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: Ben Skeggs | ||
23 | */ | ||
24 | |||
25 | #include "drmP.h" | ||
26 | #include "nouveau_drv.h" | ||
27 | #include "nouveau_ramht.h" | ||
28 | #include "nouveau_software.h" | ||
29 | |||
30 | struct nv50_software_priv { | ||
31 | struct nouveau_software_priv base; | ||
32 | }; | ||
33 | |||
34 | struct nv50_software_chan { | ||
35 | struct nouveau_software_chan base; | ||
36 | struct { | ||
37 | struct nouveau_gpuobj *object; | ||
38 | } vblank; | ||
39 | }; | ||
40 | |||
41 | static int | ||
42 | mthd_dma_vblsem(struct nouveau_channel *chan, u32 class, u32 mthd, u32 data) | ||
43 | { | ||
44 | struct nv50_software_chan *pch = chan->engctx[NVOBJ_ENGINE_SW]; | ||
45 | struct nouveau_gpuobj *gpuobj; | ||
46 | |||
47 | gpuobj = nouveau_ramht_find(chan, data); | ||
48 | if (!gpuobj) | ||
49 | return -ENOENT; | ||
50 | |||
51 | if (nouveau_notifier_offset(gpuobj, NULL)) | ||
52 | return -EINVAL; | ||
53 | |||
54 | pch->vblank.object = gpuobj; | ||
55 | pch->base.vblank.offset = ~0; | ||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int | ||
60 | mthd_vblsem_offset(struct nouveau_channel *chan, u32 class, u32 mthd, u32 data) | ||
61 | { | ||
62 | struct nv50_software_chan *pch = chan->engctx[NVOBJ_ENGINE_SW]; | ||
63 | |||
64 | if (nouveau_notifier_offset(pch->vblank.object, &data)) | ||
65 | return -ERANGE; | ||
66 | |||
67 | pch->base.vblank.offset = data >> 2; | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static int | ||
72 | mthd_vblsem_value(struct nouveau_channel *chan, u32 class, u32 mthd, u32 data) | ||
73 | { | ||
74 | struct nv50_software_chan *pch = chan->engctx[NVOBJ_ENGINE_SW]; | ||
75 | pch->base.vblank.value = data; | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static int | ||
80 | mthd_vblsem_release(struct nouveau_channel *chan, u32 class, u32 mthd, u32 data) | ||
81 | { | ||
82 | struct nv50_software_priv *psw = nv_engine(chan->dev, NVOBJ_ENGINE_SW); | ||
83 | struct nv50_software_chan *pch = chan->engctx[NVOBJ_ENGINE_SW]; | ||
84 | struct drm_device *dev = chan->dev; | ||
85 | |||
86 | if (!pch->vblank.object || pch->base.vblank.offset == ~0 || data > 1) | ||
87 | return -EINVAL; | ||
88 | |||
89 | drm_vblank_get(dev, data); | ||
90 | |||
91 | pch->base.vblank.head = data; | ||
92 | list_add(&pch->base.vblank.list, &psw->base.vblank); | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static int | ||
97 | mthd_flip(struct nouveau_channel *chan, u32 class, u32 mthd, u32 data) | ||
98 | { | ||
99 | nouveau_finish_page_flip(chan, NULL); | ||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | static int | ||
104 | nv50_software_context_new(struct nouveau_channel *chan, int engine) | ||
105 | { | ||
106 | struct nv50_software_chan *pch; | ||
107 | |||
108 | pch = kzalloc(sizeof(*pch), GFP_KERNEL); | ||
109 | if (!pch) | ||
110 | return -ENOMEM; | ||
111 | |||
112 | nouveau_software_context_new(&pch->base); | ||
113 | pch->base.vblank.bo = chan->notifier_bo; | ||
114 | |||
115 | chan->engctx[engine] = pch; | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | static void | ||
120 | nv50_software_context_del(struct nouveau_channel *chan, int engine) | ||
121 | { | ||
122 | struct nv50_software_chan *pch = chan->engctx[engine]; | ||
123 | chan->engctx[engine] = NULL; | ||
124 | kfree(pch); | ||
125 | } | ||
126 | |||
127 | static int | ||
128 | nv50_software_object_new(struct nouveau_channel *chan, int engine, | ||
129 | u32 handle, u16 class) | ||
130 | { | ||
131 | struct drm_device *dev = chan->dev; | ||
132 | struct nouveau_gpuobj *obj = NULL; | ||
133 | int ret; | ||
134 | |||
135 | ret = nouveau_gpuobj_new(dev, chan, 16, 16, 0, &obj); | ||
136 | if (ret) | ||
137 | return ret; | ||
138 | obj->engine = 0; | ||
139 | obj->class = class; | ||
140 | |||
141 | ret = nouveau_ramht_insert(chan, handle, obj); | ||
142 | nouveau_gpuobj_ref(NULL, &obj); | ||
143 | return ret; | ||
144 | } | ||
145 | |||
146 | static int | ||
147 | nv50_software_init(struct drm_device *dev, int engine) | ||
148 | { | ||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static int | ||
153 | nv50_software_fini(struct drm_device *dev, int engine, bool suspend) | ||
154 | { | ||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | static void | ||
159 | nv50_software_destroy(struct drm_device *dev, int engine) | ||
160 | { | ||
161 | struct nv50_software_priv *psw = nv_engine(dev, engine); | ||
162 | |||
163 | NVOBJ_ENGINE_DEL(dev, SW); | ||
164 | kfree(psw); | ||
165 | } | ||
166 | |||
167 | int | ||
168 | nv50_software_create(struct drm_device *dev) | ||
169 | { | ||
170 | struct nv50_software_priv *psw = kzalloc(sizeof(*psw), GFP_KERNEL); | ||
171 | if (!psw) | ||
172 | return -ENOMEM; | ||
173 | |||
174 | psw->base.base.destroy = nv50_software_destroy; | ||
175 | psw->base.base.init = nv50_software_init; | ||
176 | psw->base.base.fini = nv50_software_fini; | ||
177 | psw->base.base.context_new = nv50_software_context_new; | ||
178 | psw->base.base.context_del = nv50_software_context_del; | ||
179 | psw->base.base.object_new = nv50_software_object_new; | ||
180 | nouveau_software_create(&psw->base); | ||
181 | |||
182 | NVOBJ_ENGINE_ADD(dev, SW, &psw->base.base); | ||
183 | NVOBJ_CLASS(dev, 0x506e, SW); | ||
184 | NVOBJ_MTHD (dev, 0x506e, 0x018c, mthd_dma_vblsem); | ||
185 | NVOBJ_MTHD (dev, 0x506e, 0x0400, mthd_vblsem_offset); | ||
186 | NVOBJ_MTHD (dev, 0x506e, 0x0404, mthd_vblsem_value); | ||
187 | NVOBJ_MTHD (dev, 0x506e, 0x0408, mthd_vblsem_release); | ||
188 | NVOBJ_MTHD (dev, 0x506e, 0x0500, mthd_flip); | ||
189 | return 0; | ||
190 | } | ||