drm/nouveau/fifo: audit and version fifo channel classes
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nouveau_abi16.c
CommitLineData
2a259a3d
BS
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 */
23
a4e610b5
BS
24#include <nvif/client.h>
25#include <nvif/driver.h>
26#include <nvif/ioctl.h>
fdb751ef 27#include <nvif/class.h>
2a259a3d 28
ebb945a9 29#include "nouveau_drm.h"
2a259a3d 30#include "nouveau_dma.h"
ebb945a9
BS
31#include "nouveau_gem.h"
32#include "nouveau_chan.h"
2a259a3d 33#include "nouveau_abi16.h"
ebb945a9
BS
34
35struct nouveau_abi16 *
36nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev)
37{
38 struct nouveau_cli *cli = nouveau_cli(file_priv);
39 mutex_lock(&cli->mutex);
40 if (!cli->abi16) {
41 struct nouveau_abi16 *abi16;
42 cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL);
43 if (cli->abi16) {
586491e6
BS
44 struct nv_device_v0 args = {
45 .device = ~0ULL,
46 };
47
ebb945a9 48 INIT_LIST_HEAD(&abi16->channels);
ebb945a9
BS
49
50 /* allocate device object targeting client's default
51 * device (ie. the one that belongs to the fd it
52 * opened)
53 */
0ad72863 54 if (nvif_device_init(&cli->base.base, NULL,
a4e610b5 55 NOUVEAU_ABI16_DEVICE, NV_DEVICE,
586491e6 56 &args, sizeof(args),
0ad72863 57 &abi16->device) == 0)
ebb945a9
BS
58 return cli->abi16;
59
60 kfree(cli->abi16);
61 cli->abi16 = NULL;
62 }
63
64 mutex_unlock(&cli->mutex);
65 }
66 return cli->abi16;
67}
68
69int
70nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret)
71{
0ad72863 72 struct nouveau_cli *cli = (void *)nvif_client(&abi16->device.base);
ebb945a9
BS
73 mutex_unlock(&cli->mutex);
74 return ret;
75}
76
77u16
78nouveau_abi16_swclass(struct nouveau_drm *drm)
79{
967e7bde
BS
80 switch (drm->device.info.family) {
81 case NV_DEVICE_INFO_V0_TNT:
ebb945a9 82 return 0x006e;
967e7bde
BS
83 case NV_DEVICE_INFO_V0_CELSIUS:
84 case NV_DEVICE_INFO_V0_KELVIN:
85 case NV_DEVICE_INFO_V0_RANKINE:
86 case NV_DEVICE_INFO_V0_CURIE:
ebb945a9 87 return 0x016e;
967e7bde 88 case NV_DEVICE_INFO_V0_TESLA:
ebb945a9 89 return 0x506e;
967e7bde
BS
90 case NV_DEVICE_INFO_V0_FERMI:
91 case NV_DEVICE_INFO_V0_KEPLER:
92 case NV_DEVICE_INFO_V0_MAXWELL:
ebb945a9
BS
93 return 0x906e;
94 }
95
96 return 0x0000;
97}
98
99static void
100nouveau_abi16_ntfy_fini(struct nouveau_abi16_chan *chan,
101 struct nouveau_abi16_ntfy *ntfy)
102{
103 nouveau_mm_free(&chan->heap, &ntfy->node);
104 list_del(&ntfy->head);
105 kfree(ntfy);
106}
107
108static void
109nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
110 struct nouveau_abi16_chan *chan)
111{
112 struct nouveau_abi16_ntfy *ntfy, *temp;
113
2b77c1c0
MS
114 /* wait for all activity to stop before releasing notify object, which
115 * may be still in use */
116 if (chan->chan && chan->ntfy)
117 nouveau_channel_idle(chan->chan);
118
ebb945a9
BS
119 /* cleanup notifier state */
120 list_for_each_entry_safe(ntfy, temp, &chan->notifiers, head) {
121 nouveau_abi16_ntfy_fini(chan, ntfy);
122 }
123
124 if (chan->ntfy) {
125 nouveau_bo_vma_del(chan->ntfy, &chan->ntfy_vma);
198c14a0 126 nouveau_bo_unpin(chan->ntfy);
55fb74ad 127 drm_gem_object_unreference_unlocked(&chan->ntfy->gem);
ebb945a9
BS
128 }
129
130 if (chan->heap.block_size)
131 nouveau_mm_fini(&chan->heap);
132
133 /* destroy channel object, all children will be killed too */
134 if (chan->chan) {
0ad72863 135 abi16->handles &= ~(1ULL << (chan->chan->object->handle & 0xffff));
ebb945a9
BS
136 nouveau_channel_del(&chan->chan);
137 }
138
139 list_del(&chan->head);
140 kfree(chan);
141}
142
143void
144nouveau_abi16_fini(struct nouveau_abi16 *abi16)
145{
0ad72863 146 struct nouveau_cli *cli = (void *)nvif_client(&abi16->device.base);
ebb945a9
BS
147 struct nouveau_abi16_chan *chan, *temp;
148
149 /* cleanup channels */
150 list_for_each_entry_safe(chan, temp, &abi16->channels, head) {
151 nouveau_abi16_chan_fini(abi16, chan);
152 }
153
154 /* destroy the device object */
0ad72863 155 nvif_device_fini(&abi16->device);
ebb945a9
BS
156
157 kfree(cli->abi16);
158 cli->abi16 = NULL;
159}
2a259a3d
BS
160
161int
162nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
163{
fa2bade9 164 struct nouveau_cli *cli = nouveau_cli(file_priv);
ebb945a9 165 struct nouveau_drm *drm = nouveau_drm(dev);
967e7bde
BS
166 struct nvif_device *device = &drm->device;
167 struct nouveau_timer *ptimer = nvkm_timer(device);
168 struct nouveau_graph *graph = nvkm_gr(device);
2a259a3d
BS
169 struct drm_nouveau_getparam *getparam = data;
170
171 switch (getparam->param) {
172 case NOUVEAU_GETPARAM_CHIPSET_ID:
967e7bde 173 getparam->value = device->info.chipset;
2a259a3d
BS
174 break;
175 case NOUVEAU_GETPARAM_PCI_VENDOR:
967e7bde 176 if (nv_device_is_pci(nvkm_device(device)))
420b9469
AC
177 getparam->value = dev->pdev->vendor;
178 else
179 getparam->value = 0;
2a259a3d
BS
180 break;
181 case NOUVEAU_GETPARAM_PCI_DEVICE:
967e7bde 182 if (nv_device_is_pci(nvkm_device(device)))
420b9469
AC
183 getparam->value = dev->pdev->device;
184 else
185 getparam->value = 0;
2a259a3d
BS
186 break;
187 case NOUVEAU_GETPARAM_BUS_TYPE:
967e7bde 188 if (!nv_device_is_pci(nvkm_device(device)))
420b9469
AC
189 getparam->value = 3;
190 else
2a259a3d
BS
191 if (drm_pci_device_is_agp(dev))
192 getparam->value = 0;
193 else
194 if (!pci_is_pcie(dev->pdev))
195 getparam->value = 1;
196 else
197 getparam->value = 2;
198 break;
199 case NOUVEAU_GETPARAM_FB_SIZE:
ebb945a9 200 getparam->value = drm->gem.vram_available;
2a259a3d
BS
201 break;
202 case NOUVEAU_GETPARAM_AGP_SIZE:
ebb945a9 203 getparam->value = drm->gem.gart_available;
2a259a3d
BS
204 break;
205 case NOUVEAU_GETPARAM_VM_VRAM_BASE:
206 getparam->value = 0; /* deprecated */
207 break;
208 case NOUVEAU_GETPARAM_PTIMER_TIME:
ebb945a9 209 getparam->value = ptimer->read(ptimer);
2a259a3d
BS
210 break;
211 case NOUVEAU_GETPARAM_HAS_BO_USAGE:
212 getparam->value = 1;
213 break;
214 case NOUVEAU_GETPARAM_HAS_PAGEFLIP:
215 getparam->value = 1;
216 break;
217 case NOUVEAU_GETPARAM_GRAPH_UNITS:
7e22e71e
CB
218 getparam->value = graph->units ? graph->units(graph) : 0;
219 break;
2a259a3d 220 default:
fa2bade9 221 NV_PRINTK(debug, cli, "unknown parameter %lld\n", getparam->param);
2a259a3d
BS
222 return -EINVAL;
223 }
224
225 return 0;
226}
227
228int
229nouveau_abi16_ioctl_setparam(ABI16_IOCTL_ARGS)
230{
231 return -EINVAL;
232}
233
234int
235nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
236{
2a259a3d 237 struct drm_nouveau_channel_alloc *init = data;
ebb945a9
BS
238 struct nouveau_cli *cli = nouveau_cli(file_priv);
239 struct nouveau_drm *drm = nouveau_drm(dev);
240 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
241 struct nouveau_abi16_chan *chan;
967e7bde 242 struct nvif_device *device;
ebb945a9
BS
243 struct nouveau_instmem *imem;
244 struct nouveau_fb *pfb;
2a259a3d
BS
245 int ret;
246
ebb945a9
BS
247 if (unlikely(!abi16))
248 return -ENOMEM;
bf7e438b
MS
249
250 if (!drm->channel)
251 return nouveau_abi16_put(abi16, -ENODEV);
252
967e7bde
BS
253 device = &abi16->device;
254 imem = nvkm_instmem(device);
255 pfb = nvkm_fb(device);
ebb945a9 256
49469800 257 /* hack to allow channel engine type specification on kepler */
967e7bde 258 if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
49469800 259 if (init->fb_ctxdma_handle != ~0)
bbf8906b 260 init->fb_ctxdma_handle = KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR;
49469800
BS
261 else
262 init->fb_ctxdma_handle = init->tt_ctxdma_handle;
263
264 /* allow flips to be executed if this is a graphics channel */
265 init->tt_ctxdma_handle = 0;
bbf8906b 266 if (init->fb_ctxdma_handle == KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR)
49469800
BS
267 init->tt_ctxdma_handle = 1;
268 }
269
270 if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0)
271 return nouveau_abi16_put(abi16, -EINVAL);
272
ebb945a9 273 /* allocate "abi16 channel" data and make up a handle for it */
73970c47
IM
274 init->channel = __ffs64(~abi16->handles);
275 if (~abi16->handles == 0)
ebb945a9
BS
276 return nouveau_abi16_put(abi16, -ENOSPC);
277
278 chan = kzalloc(sizeof(*chan), GFP_KERNEL);
279 if (!chan)
280 return nouveau_abi16_put(abi16, -ENOMEM);
281
282 INIT_LIST_HEAD(&chan->notifiers);
283 list_add(&chan->head, &abi16->channels);
ef98c1f7 284 abi16->handles |= (1ULL << init->channel);
2a259a3d 285
ebb945a9 286 /* create channel object and initialise dma and fence management */
a4e610b5
BS
287 ret = nouveau_channel_new(drm, device,
288 NOUVEAU_ABI16_CHAN(init->channel),
0ad72863 289 init->fb_ctxdma_handle,
ebb945a9 290 init->tt_ctxdma_handle, &chan->chan);
2a259a3d 291 if (ret)
ebb945a9
BS
292 goto done;
293
967e7bde 294 if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)
ebb945a9
BS
295 init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |
296 NOUVEAU_GEM_DOMAIN_GART;
297 else
298 if (chan->chan->push.buffer->bo.mem.mem_type == TTM_PL_VRAM)
2a259a3d 299 init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM;
ebb945a9
BS
300 else
301 init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_GART;
2a259a3d 302
967e7bde 303 if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
2a259a3d
BS
304 init->subchan[0].handle = 0x00000000;
305 init->subchan[0].grclass = 0x0000;
f45f55c4 306 init->subchan[1].handle = chan->chan->nvsw.handle;
ebb945a9 307 init->subchan[1].grclass = 0x506e;
2a259a3d
BS
308 init->nr_subchan = 2;
309 }
310
311 /* Named memory object area */
ebb945a9
BS
312 ret = nouveau_gem_new(dev, PAGE_SIZE, 0, NOUVEAU_GEM_DOMAIN_GART,
313 0, 0, &chan->ntfy);
314 if (ret == 0)
315 ret = nouveau_bo_pin(chan->ntfy, TTM_PL_FLAG_TT);
316 if (ret)
317 goto done;
318
967e7bde 319 if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
0ad72863 320 ret = nouveau_bo_vma_add(chan->ntfy, cli->vm,
ebb945a9
BS
321 &chan->ntfy_vma);
322 if (ret)
323 goto done;
324 }
325
55fb74ad 326 ret = drm_gem_handle_create(file_priv, &chan->ntfy->gem,
2a259a3d 327 &init->notifier_handle);
ebb945a9
BS
328 if (ret)
329 goto done;
2a259a3d 330
ebb945a9
BS
331 ret = nouveau_mm_init(&chan->heap, 0, PAGE_SIZE, 1);
332done:
333 if (ret)
334 nouveau_abi16_chan_fini(abi16, chan);
335 return nouveau_abi16_put(abi16, ret);
2a259a3d
BS
336}
337
a4e610b5
BS
338static struct nouveau_abi16_chan *
339nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel)
340{
341 struct nouveau_abi16_chan *chan;
342
343 list_for_each_entry(chan, &abi16->channels, head) {
344 if (chan->chan->object->handle == NOUVEAU_ABI16_CHAN(channel))
345 return chan;
346 }
347
348 return NULL;
349}
ebb945a9 350
2a259a3d
BS
351int
352nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS)
353{
354 struct drm_nouveau_channel_free *req = data;
ebb945a9
BS
355 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
356 struct nouveau_abi16_chan *chan;
2a259a3d 357
ebb945a9
BS
358 if (unlikely(!abi16))
359 return -ENOMEM;
2a259a3d 360
a4e610b5
BS
361 chan = nouveau_abi16_chan(abi16, req->channel);
362 if (!chan)
363 return nouveau_abi16_put(abi16, -ENOENT);
364 nouveau_abi16_chan_fini(abi16, chan);
365 return nouveau_abi16_put(abi16, 0);
2a259a3d
BS
366}
367
368int
369nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
370{
371 struct drm_nouveau_grobj_alloc *init = data;
a4e610b5
BS
372 struct {
373 struct nvif_ioctl_v0 ioctl;
374 struct nvif_ioctl_new_v0 new;
375 } args = {
376 .ioctl.owner = NVIF_IOCTL_V0_OWNER_ANY,
377 .ioctl.type = NVIF_IOCTL_V0_NEW,
378 .ioctl.path_nr = 3,
379 .ioctl.path[2] = NOUVEAU_ABI16_CLIENT,
380 .ioctl.path[1] = NOUVEAU_ABI16_DEVICE,
381 .ioctl.path[0] = NOUVEAU_ABI16_CHAN(init->channel),
382 .new.route = NVDRM_OBJECT_ABI16,
383 .new.handle = init->handle,
384 .new.oclass = init->class,
385 };
ebb945a9
BS
386 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
387 struct nouveau_drm *drm = nouveau_drm(dev);
a4e610b5 388 struct nvif_client *client;
2a259a3d
BS
389 int ret;
390
ebb945a9
BS
391 if (unlikely(!abi16))
392 return -ENOMEM;
393
2a259a3d 394 if (init->handle == ~0)
ebb945a9 395 return nouveau_abi16_put(abi16, -EINVAL);
a4e610b5 396 client = nvif_client(nvif_object(&abi16->device));
2a259a3d
BS
397
398 /* compatibility with userspace that assumes 506e for all chipsets */
399 if (init->class == 0x506e) {
ebb945a9 400 init->class = nouveau_abi16_swclass(drm);
2a259a3d 401 if (init->class == 0x906e)
ebb945a9 402 return nouveau_abi16_put(abi16, 0);
2a259a3d
BS
403 }
404
a4e610b5 405 ret = nvif_client_ioctl(client, &args, sizeof(args));
ebb945a9 406 return nouveau_abi16_put(abi16, ret);
2a259a3d
BS
407}
408
409int
410nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
411{
ebb945a9 412 struct drm_nouveau_notifierobj_alloc *info = data;
3bdda04f
BS
413 struct {
414 struct nvif_ioctl_v0 ioctl;
415 struct nvif_ioctl_new_v0 new;
4acfd707 416 struct nv_dma_v0 ctxdma;
3bdda04f
BS
417 } args = {
418 .ioctl.owner = NVIF_IOCTL_V0_OWNER_ANY,
419 .ioctl.type = NVIF_IOCTL_V0_NEW,
420 .ioctl.path_nr = 3,
421 .ioctl.path[2] = NOUVEAU_ABI16_CLIENT,
422 .ioctl.path[1] = NOUVEAU_ABI16_DEVICE,
423 .ioctl.path[0] = NOUVEAU_ABI16_CHAN(info->channel),
424 .new.route = NVDRM_OBJECT_ABI16,
425 .new.handle = info->handle,
4acfd707 426 .new.oclass = NV_DMA_IN_MEMORY,
3bdda04f 427 };
ebb945a9 428 struct nouveau_drm *drm = nouveau_drm(dev);
ebb945a9 429 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
a4e610b5 430 struct nouveau_abi16_chan *chan;
ebb945a9 431 struct nouveau_abi16_ntfy *ntfy;
967e7bde 432 struct nvif_device *device = &abi16->device;
3bdda04f 433 struct nvif_client *client;
2a259a3d
BS
434 int ret;
435
ebb945a9
BS
436 if (unlikely(!abi16))
437 return -ENOMEM;
438
2a259a3d 439 /* completely unnecessary for these chipsets... */
967e7bde 440 if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI))
ebb945a9 441 return nouveau_abi16_put(abi16, -EINVAL);
3bdda04f 442 client = nvif_client(nvif_object(&abi16->device));
2a259a3d 443
a4e610b5 444 chan = nouveau_abi16_chan(abi16, info->channel);
ebb945a9
BS
445 if (!chan)
446 return nouveau_abi16_put(abi16, -ENOENT);
447
448 ntfy = kzalloc(sizeof(*ntfy), GFP_KERNEL);
449 if (!ntfy)
450 return nouveau_abi16_put(abi16, -ENOMEM);
451
452 list_add(&ntfy->head, &chan->notifiers);
453 ntfy->handle = info->handle;
454
455 ret = nouveau_mm_head(&chan->heap, 1, info->size, info->size, 1,
456 &ntfy->node);
457 if (ret)
458 goto done;
459
3bdda04f
BS
460 args.ctxdma.start = ntfy->node->offset;
461 args.ctxdma.limit = ntfy->node->offset + ntfy->node->length - 1;
967e7bde 462 if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
4acfd707
BS
463 args.ctxdma.target = NV_DMA_V0_TARGET_VM;
464 args.ctxdma.access = NV_DMA_V0_ACCESS_VM;
3bdda04f
BS
465 args.ctxdma.start += chan->ntfy_vma.offset;
466 args.ctxdma.limit += chan->ntfy_vma.offset;
ebb945a9
BS
467 } else
468 if (drm->agp.stat == ENABLED) {
4acfd707
BS
469 args.ctxdma.target = NV_DMA_V0_TARGET_AGP;
470 args.ctxdma.access = NV_DMA_V0_ACCESS_RDWR;
3bdda04f
BS
471 args.ctxdma.start += drm->agp.base + chan->ntfy->bo.offset;
472 args.ctxdma.limit += drm->agp.base + chan->ntfy->bo.offset;
473 client->super = true;
ebb945a9 474 } else {
4acfd707
BS
475 args.ctxdma.target = NV_DMA_V0_TARGET_VM;
476 args.ctxdma.access = NV_DMA_V0_ACCESS_RDWR;
3bdda04f
BS
477 args.ctxdma.start += chan->ntfy->bo.offset;
478 args.ctxdma.limit += chan->ntfy->bo.offset;
ebb945a9
BS
479 }
480
3bdda04f
BS
481 ret = nvif_client_ioctl(client, &args, sizeof(args));
482 client->super = false;
ebb945a9
BS
483 if (ret)
484 goto done;
485
c1ccaa64
BG
486 info->offset = ntfy->node->offset;
487
ebb945a9
BS
488done:
489 if (ret)
490 nouveau_abi16_ntfy_fini(chan, ntfy);
491 return nouveau_abi16_put(abi16, ret);
2a259a3d
BS
492}
493
494int
495nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS)
496{
ebb945a9 497 struct drm_nouveau_gpuobj_free *fini = data;
aedf43d5
BS
498 struct {
499 struct nvif_ioctl_v0 ioctl;
500 struct nvif_ioctl_del del;
501 } args = {
502 .ioctl.owner = NVDRM_OBJECT_ABI16,
503 .ioctl.type = NVIF_IOCTL_V0_DEL,
504 .ioctl.path_nr = 4,
505 .ioctl.path[3] = NOUVEAU_ABI16_CLIENT,
506 .ioctl.path[2] = NOUVEAU_ABI16_DEVICE,
507 .ioctl.path[1] = NOUVEAU_ABI16_CHAN(fini->channel),
508 .ioctl.path[0] = fini->handle,
509 };
ebb945a9 510 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
a4e610b5 511 struct nouveau_abi16_chan *chan;
ebb945a9 512 struct nouveau_abi16_ntfy *ntfy;
aedf43d5 513 struct nvif_client *client;
2a259a3d
BS
514 int ret;
515
ebb945a9
BS
516 if (unlikely(!abi16))
517 return -ENOMEM;
518
a4e610b5 519 chan = nouveau_abi16_chan(abi16, fini->channel);
ebb945a9
BS
520 if (!chan)
521 return nouveau_abi16_put(abi16, -ENOENT);
aedf43d5 522 client = nvif_client(nvif_object(&abi16->device));
2a259a3d 523
ebb945a9
BS
524 /* synchronize with the user channel and destroy the gpu object */
525 nouveau_channel_idle(chan->chan);
2a259a3d 526
aedf43d5 527 ret = nvif_client_ioctl(client, &args, sizeof(args));
ebb945a9
BS
528 if (ret)
529 return nouveau_abi16_put(abi16, ret);
530
531 /* cleanup extra state if this object was a notifier */
532 list_for_each_entry(ntfy, &chan->notifiers, head) {
533 if (ntfy->handle == fini->handle) {
534 nouveau_mm_free(&chan->heap, &ntfy->node);
535 list_del(&ntfy->head);
536 break;
537 }
538 }
539
540 return nouveau_abi16_put(abi16, 0);
2a259a3d 541}
This page took 0.160315 seconds and 5 git commands to generate.