nouveau_abi16.c 15 KB

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