nouveau_abi16.c 16 KB

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