nouveau_abi16.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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. break;
  194. case NOUVEAU_GETPARAM_FB_SIZE:
  195. getparam->value = drm->gem.vram_available;
  196. break;
  197. case NOUVEAU_GETPARAM_AGP_SIZE:
  198. getparam->value = drm->gem.gart_available;
  199. break;
  200. case NOUVEAU_GETPARAM_VM_VRAM_BASE:
  201. getparam->value = 0; /* deprecated */
  202. break;
  203. case NOUVEAU_GETPARAM_PTIMER_TIME:
  204. getparam->value = nvif_device_time(device);
  205. break;
  206. case NOUVEAU_GETPARAM_HAS_BO_USAGE:
  207. getparam->value = 1;
  208. break;
  209. case NOUVEAU_GETPARAM_HAS_PAGEFLIP:
  210. getparam->value = 1;
  211. break;
  212. case NOUVEAU_GETPARAM_GRAPH_UNITS:
  213. getparam->value = nvkm_gr_units(gr);
  214. break;
  215. default:
  216. NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param);
  217. return -EINVAL;
  218. }
  219. return 0;
  220. }
  221. int
  222. nouveau_abi16_ioctl_setparam(ABI16_IOCTL_ARGS)
  223. {
  224. return -EINVAL;
  225. }
  226. int
  227. nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
  228. {
  229. struct drm_nouveau_channel_alloc *init = data;
  230. struct nouveau_cli *cli = nouveau_cli(file_priv);
  231. struct nouveau_drm *drm = nouveau_drm(dev);
  232. struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv);
  233. struct nouveau_abi16_chan *chan;
  234. struct nvif_device *device;
  235. u64 engine;
  236. int ret;
  237. if (unlikely(!abi16))
  238. return -ENOMEM;
  239. if (!drm->channel)
  240. return nouveau_abi16_put(abi16, -ENODEV);
  241. device = &abi16->device;
  242. /* hack to allow channel engine type specification on kepler */
  243. if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
  244. if (init->fb_ctxdma_handle == ~0) {
  245. switch (init->tt_ctxdma_handle) {
  246. case 0x01: engine = NV_DEVICE_INFO_ENGINE_GR ; break;
  247. case 0x02: engine = NV_DEVICE_INFO_ENGINE_MSPDEC; break;
  248. case 0x04: engine = NV_DEVICE_INFO_ENGINE_MSPPP ; break;
  249. case 0x08: engine = NV_DEVICE_INFO_ENGINE_MSVLD ; break;
  250. case 0x30: engine = NV_DEVICE_INFO_ENGINE_CE ; break;
  251. default:
  252. return nouveau_abi16_put(abi16, -ENOSYS);
  253. }
  254. } else {
  255. engine = NV_DEVICE_INFO_ENGINE_GR;
  256. }
  257. if (engine != NV_DEVICE_INFO_ENGINE_CE)
  258. engine = nvif_fifo_runlist(device, engine);
  259. else
  260. engine = nvif_fifo_runlist_ce(device);
  261. init->fb_ctxdma_handle = engine;
  262. init->tt_ctxdma_handle = 0;
  263. }
  264. if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0)
  265. return nouveau_abi16_put(abi16, -EINVAL);
  266. /* allocate "abi16 channel" data and make up a handle for it */
  267. chan = kzalloc(sizeof(*chan), GFP_KERNEL);
  268. if (!chan)
  269. return nouveau_abi16_put(abi16, -ENOMEM);
  270. INIT_LIST_HEAD(&chan->notifiers);
  271. list_add(&chan->head, &abi16->channels);
  272. /* create channel object and initialise dma and fence management */
  273. ret = nouveau_channel_new(drm, device, init->fb_ctxdma_handle,
  274. init->tt_ctxdma_handle, &chan->chan);
  275. if (ret)
  276. goto done;
  277. init->channel = chan->chan->chid;
  278. if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)
  279. init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |
  280. NOUVEAU_GEM_DOMAIN_GART;
  281. else
  282. if (chan->chan->push.buffer->bo.mem.mem_type == TTM_PL_VRAM)
  283. init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM;
  284. else
  285. init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_GART;
  286. if (device->info.family < NV_DEVICE_INFO_V0_CELSIUS) {
  287. init->subchan[0].handle = 0x00000000;
  288. init->subchan[0].grclass = 0x0000;
  289. init->subchan[1].handle = chan->chan->nvsw.handle;
  290. init->subchan[1].grclass = 0x506e;
  291. init->nr_subchan = 2;
  292. }
  293. /* Named memory object area */
  294. ret = nouveau_gem_new(cli, PAGE_SIZE, 0, NOUVEAU_GEM_DOMAIN_GART,
  295. 0, 0, &chan->ntfy);
  296. if (ret == 0)
  297. ret = nouveau_bo_pin(chan->ntfy, TTM_PL_FLAG_TT, false);
  298. if (ret)
  299. goto done;
  300. if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
  301. ret = nouveau_vma_new(chan->ntfy, &cli->vmm, &chan->ntfy_vma);
  302. if (ret)
  303. goto done;
  304. }
  305. ret = drm_gem_handle_create(file_priv, &chan->ntfy->gem,
  306. &init->notifier_handle);
  307. if (ret)
  308. goto done;
  309. ret = nvkm_mm_init(&chan->heap, 0, 0, PAGE_SIZE, 1);
  310. done:
  311. if (ret)
  312. nouveau_abi16_chan_fini(abi16, chan);
  313. return nouveau_abi16_put(abi16, ret);
  314. }
  315. static struct nouveau_abi16_chan *
  316. nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel)
  317. {
  318. struct nouveau_abi16_chan *chan;
  319. list_for_each_entry(chan, &abi16->channels, head) {
  320. if (chan->chan->chid == channel)
  321. return chan;
  322. }
  323. return NULL;
  324. }
  325. int
  326. nouveau_abi16_usif(struct drm_file *file_priv, void *data, u32 size)
  327. {
  328. union {
  329. struct nvif_ioctl_v0 v0;
  330. } *args = data;
  331. struct nouveau_abi16_chan *chan;
  332. struct nouveau_abi16 *abi16;
  333. int ret = -ENOSYS;
  334. if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
  335. switch (args->v0.type) {
  336. case NVIF_IOCTL_V0_NEW:
  337. case NVIF_IOCTL_V0_MTHD:
  338. case NVIF_IOCTL_V0_SCLASS:
  339. break;
  340. default:
  341. return -EACCES;
  342. }
  343. } else
  344. return ret;
  345. if (!(abi16 = nouveau_abi16(file_priv)))
  346. return -ENOMEM;
  347. if (args->v0.token != ~0ULL) {
  348. if (!(chan = nouveau_abi16_chan(abi16, args->v0.token)))
  349. return -EINVAL;
  350. args->v0.object = nvif_handle(&chan->chan->user);
  351. args->v0.owner = NVIF_IOCTL_V0_OWNER_ANY;
  352. return 0;
  353. }
  354. args->v0.object = nvif_handle(&abi16->device.object);
  355. args->v0.owner = NVIF_IOCTL_V0_OWNER_ANY;
  356. return 0;
  357. }
  358. int
  359. nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS)
  360. {
  361. struct drm_nouveau_channel_free *req = data;
  362. struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv);
  363. struct nouveau_abi16_chan *chan;
  364. if (unlikely(!abi16))
  365. return -ENOMEM;
  366. chan = nouveau_abi16_chan(abi16, req->channel);
  367. if (!chan)
  368. return nouveau_abi16_put(abi16, -ENOENT);
  369. nouveau_abi16_chan_fini(abi16, chan);
  370. return nouveau_abi16_put(abi16, 0);
  371. }
  372. int
  373. nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
  374. {
  375. struct drm_nouveau_grobj_alloc *init = data;
  376. struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv);
  377. struct nouveau_abi16_chan *chan;
  378. struct nouveau_abi16_ntfy *ntfy;
  379. struct nvif_client *client;
  380. struct nvif_sclass *sclass;
  381. s32 oclass = 0;
  382. int ret, i;
  383. if (unlikely(!abi16))
  384. return -ENOMEM;
  385. if (init->handle == ~0)
  386. return nouveau_abi16_put(abi16, -EINVAL);
  387. client = abi16->device.object.client;
  388. chan = nouveau_abi16_chan(abi16, init->channel);
  389. if (!chan)
  390. return nouveau_abi16_put(abi16, -ENOENT);
  391. ret = nvif_object_sclass_get(&chan->chan->user, &sclass);
  392. if (ret < 0)
  393. return nouveau_abi16_put(abi16, ret);
  394. if ((init->class & 0x00ff) == 0x006e) {
  395. /* nvsw: compatibility with older 0x*6e class identifier */
  396. for (i = 0; !oclass && i < ret; i++) {
  397. switch (sclass[i].oclass) {
  398. case NVIF_CLASS_SW_NV04:
  399. case NVIF_CLASS_SW_NV10:
  400. case NVIF_CLASS_SW_NV50:
  401. case NVIF_CLASS_SW_GF100:
  402. oclass = sclass[i].oclass;
  403. break;
  404. default:
  405. break;
  406. }
  407. }
  408. } else
  409. if ((init->class & 0x00ff) == 0x00b1) {
  410. /* msvld: compatibility with incorrect version exposure */
  411. for (i = 0; i < ret; i++) {
  412. if ((sclass[i].oclass & 0x00ff) == 0x00b1) {
  413. oclass = sclass[i].oclass;
  414. break;
  415. }
  416. }
  417. } else
  418. if ((init->class & 0x00ff) == 0x00b2) { /* mspdec */
  419. /* mspdec: compatibility with incorrect version exposure */
  420. for (i = 0; i < ret; i++) {
  421. if ((sclass[i].oclass & 0x00ff) == 0x00b2) {
  422. oclass = sclass[i].oclass;
  423. break;
  424. }
  425. }
  426. } else
  427. if ((init->class & 0x00ff) == 0x00b3) { /* msppp */
  428. /* msppp: compatibility with incorrect version exposure */
  429. for (i = 0; i < ret; i++) {
  430. if ((sclass[i].oclass & 0x00ff) == 0x00b3) {
  431. oclass = sclass[i].oclass;
  432. break;
  433. }
  434. }
  435. } else {
  436. oclass = init->class;
  437. }
  438. nvif_object_sclass_put(&sclass);
  439. if (!oclass)
  440. return nouveau_abi16_put(abi16, -EINVAL);
  441. ntfy = kzalloc(sizeof(*ntfy), GFP_KERNEL);
  442. if (!ntfy)
  443. return nouveau_abi16_put(abi16, -ENOMEM);
  444. list_add(&ntfy->head, &chan->notifiers);
  445. client->route = NVDRM_OBJECT_ABI16;
  446. ret = nvif_object_init(&chan->chan->user, init->handle, oclass,
  447. NULL, 0, &ntfy->object);
  448. client->route = NVDRM_OBJECT_NVIF;
  449. if (ret)
  450. nouveau_abi16_ntfy_fini(chan, ntfy);
  451. return nouveau_abi16_put(abi16, ret);
  452. }
  453. int
  454. nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
  455. {
  456. struct drm_nouveau_notifierobj_alloc *info = data;
  457. struct nouveau_drm *drm = nouveau_drm(dev);
  458. struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv);
  459. struct nouveau_abi16_chan *chan;
  460. struct nouveau_abi16_ntfy *ntfy;
  461. struct nvif_device *device = &abi16->device;
  462. struct nvif_client *client;
  463. struct nv_dma_v0 args = {};
  464. int ret;
  465. if (unlikely(!abi16))
  466. return -ENOMEM;
  467. /* completely unnecessary for these chipsets... */
  468. if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI))
  469. return nouveau_abi16_put(abi16, -EINVAL);
  470. client = abi16->device.object.client;
  471. chan = nouveau_abi16_chan(abi16, info->channel);
  472. if (!chan)
  473. return nouveau_abi16_put(abi16, -ENOENT);
  474. ntfy = kzalloc(sizeof(*ntfy), GFP_KERNEL);
  475. if (!ntfy)
  476. return nouveau_abi16_put(abi16, -ENOMEM);
  477. list_add(&ntfy->head, &chan->notifiers);
  478. ret = nvkm_mm_head(&chan->heap, 0, 1, info->size, info->size, 1,
  479. &ntfy->node);
  480. if (ret)
  481. goto done;
  482. args.start = ntfy->node->offset;
  483. args.limit = ntfy->node->offset + ntfy->node->length - 1;
  484. if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
  485. args.target = NV_DMA_V0_TARGET_VM;
  486. args.access = NV_DMA_V0_ACCESS_VM;
  487. args.start += chan->ntfy_vma->addr;
  488. args.limit += chan->ntfy_vma->addr;
  489. } else
  490. if (drm->agp.bridge) {
  491. args.target = NV_DMA_V0_TARGET_AGP;
  492. args.access = NV_DMA_V0_ACCESS_RDWR;
  493. args.start += drm->agp.base + chan->ntfy->bo.offset;
  494. args.limit += drm->agp.base + chan->ntfy->bo.offset;
  495. } else {
  496. args.target = NV_DMA_V0_TARGET_VM;
  497. args.access = NV_DMA_V0_ACCESS_RDWR;
  498. args.start += chan->ntfy->bo.offset;
  499. args.limit += chan->ntfy->bo.offset;
  500. }
  501. client->route = NVDRM_OBJECT_ABI16;
  502. client->super = true;
  503. ret = nvif_object_init(&chan->chan->user, info->handle,
  504. NV_DMA_IN_MEMORY, &args, sizeof(args),
  505. &ntfy->object);
  506. client->super = false;
  507. client->route = NVDRM_OBJECT_NVIF;
  508. if (ret)
  509. goto done;
  510. info->offset = ntfy->node->offset;
  511. done:
  512. if (ret)
  513. nouveau_abi16_ntfy_fini(chan, ntfy);
  514. return nouveau_abi16_put(abi16, ret);
  515. }
  516. int
  517. nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS)
  518. {
  519. struct drm_nouveau_gpuobj_free *fini = data;
  520. struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv);
  521. struct nouveau_abi16_chan *chan;
  522. struct nouveau_abi16_ntfy *ntfy;
  523. int ret = -ENOENT;
  524. if (unlikely(!abi16))
  525. return -ENOMEM;
  526. chan = nouveau_abi16_chan(abi16, fini->channel);
  527. if (!chan)
  528. return nouveau_abi16_put(abi16, -EINVAL);
  529. /* synchronize with the user channel and destroy the gpu object */
  530. nouveau_channel_idle(chan->chan);
  531. list_for_each_entry(ntfy, &chan->notifiers, head) {
  532. if (ntfy->object.handle == fini->handle) {
  533. nouveau_abi16_ntfy_fini(chan, ntfy);
  534. ret = 0;
  535. break;
  536. }
  537. }
  538. return nouveau_abi16_put(abi16, ret);
  539. }