aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_abi16.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2014-08-09 14:10:22 -0400
committerBen Skeggs <bskeggs@redhat.com>2014-08-09 15:13:14 -0400
commit0ad72863ea426d46b2786cba9430e122a40aad0b (patch)
treebbb9346e53a5e0c16674f4e43807cad013c6cc25 /drivers/gpu/drm/nouveau/nouveau_abi16.c
parent967e7bde8739fe3b215f7537e8f1f39c044902af (diff)
drm/nouveau: port to nvif client/device/objects
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_abi16.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c63
1 files changed, 27 insertions, 36 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 6a6f20f41ae9..ae794625a5b8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -27,47 +27,34 @@
27#include <core/class.h> 27#include <core/class.h>
28#include <core/mm.h> 28#include <core/mm.h>
29 29
30#include <subdev/fb.h>
31#include <subdev/timer.h>
32#include <subdev/instmem.h>
33#include <engine/graph.h>
34
35#include "nouveau_drm.h" 30#include "nouveau_drm.h"
36#include "nouveau_dma.h" 31#include "nouveau_dma.h"
37#include "nouveau_gem.h" 32#include "nouveau_gem.h"
38#include "nouveau_chan.h" 33#include "nouveau_chan.h"
39#include "nouveau_abi16.h" 34#include "nouveau_abi16.h"
40 35
41void nouveau_drm_hack_device(struct nouveau_drm *, struct nvif_device *);
42
43struct nouveau_abi16 * 36struct nouveau_abi16 *
44nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev) 37nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev)
45{ 38{
46 struct nouveau_cli *cli = nouveau_cli(file_priv); 39 struct nouveau_cli *cli = nouveau_cli(file_priv);
47 struct nouveau_drm *drm = nouveau_drm(dev);
48 mutex_lock(&cli->mutex); 40 mutex_lock(&cli->mutex);
49 if (!cli->abi16) { 41 if (!cli->abi16) {
50 struct nouveau_abi16 *abi16; 42 struct nouveau_abi16 *abi16;
51 cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL); 43 cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL);
52 if (cli->abi16) { 44 if (cli->abi16) {
53 INIT_LIST_HEAD(&abi16->channels); 45 INIT_LIST_HEAD(&abi16->channels);
54 abi16->client = nv_object(cli);
55 46
56 /* allocate device object targeting client's default 47 /* allocate device object targeting client's default
57 * device (ie. the one that belongs to the fd it 48 * device (ie. the one that belongs to the fd it
58 * opened) 49 * opened)
59 */ 50 */
60 if (nouveau_object_new(abi16->client, NVDRM_CLIENT, 51 if (nvif_device_init(&cli->base.base, NULL,
61 NVDRM_DEVICE, 0x0080, 52 NVDRM_DEVICE, NV_DEVICE_CLASS,
62 &(struct nv_device_class) { 53 &(struct nv_device_class) {
63 .device = ~0ULL, 54 .device = ~0ULL,
64 }, 55 }, sizeof(struct nv_device_class),
65 sizeof(struct nv_device_class), 56 &abi16->device) == 0)
66 (struct nouveau_object **)
67 &abi16->device.object) == 0) {
68 nouveau_drm_hack_device(drm, &abi16->device);
69 return cli->abi16; 57 return cli->abi16;
70 }
71 58
72 kfree(cli->abi16); 59 kfree(cli->abi16);
73 cli->abi16 = NULL; 60 cli->abi16 = NULL;
@@ -81,7 +68,7 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev)
81int 68int
82nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret) 69nouveau_abi16_put(struct nouveau_abi16 *abi16, int ret)
83{ 70{
84 struct nouveau_cli *cli = (void *)abi16->client; 71 struct nouveau_cli *cli = (void *)nvif_client(&abi16->device.base);
85 mutex_unlock(&cli->mutex); 72 mutex_unlock(&cli->mutex);
86 return ret; 73 return ret;
87} 74}
@@ -144,7 +131,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
144 131
145 /* destroy channel object, all children will be killed too */ 132 /* destroy channel object, all children will be killed too */
146 if (chan->chan) { 133 if (chan->chan) {
147 abi16->handles &= ~(1ULL << (chan->chan->handle & 0xffff)); 134 abi16->handles &= ~(1ULL << (chan->chan->object->handle & 0xffff));
148 nouveau_channel_del(&chan->chan); 135 nouveau_channel_del(&chan->chan);
149 } 136 }
150 137
@@ -155,7 +142,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
155void 142void
156nouveau_abi16_fini(struct nouveau_abi16 *abi16) 143nouveau_abi16_fini(struct nouveau_abi16 *abi16)
157{ 144{
158 struct nouveau_cli *cli = (void *)abi16->client; 145 struct nouveau_cli *cli = (void *)nvif_client(&abi16->device.base);
159 struct nouveau_abi16_chan *chan, *temp; 146 struct nouveau_abi16_chan *chan, *temp;
160 147
161 /* cleanup channels */ 148 /* cleanup channels */
@@ -164,7 +151,7 @@ nouveau_abi16_fini(struct nouveau_abi16 *abi16)
164 } 151 }
165 152
166 /* destroy the device object */ 153 /* destroy the device object */
167 nouveau_object_del(abi16->client, NVDRM_CLIENT, NVDRM_DEVICE); 154 nvif_device_fini(&abi16->device);
168 155
169 kfree(cli->abi16); 156 kfree(cli->abi16);
170 cli->abi16 = NULL; 157 cli->abi16 = NULL;
@@ -251,7 +238,6 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
251 struct nouveau_drm *drm = nouveau_drm(dev); 238 struct nouveau_drm *drm = nouveau_drm(dev);
252 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); 239 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
253 struct nouveau_abi16_chan *chan; 240 struct nouveau_abi16_chan *chan;
254 struct nouveau_client *client;
255 struct nvif_device *device; 241 struct nvif_device *device;
256 struct nouveau_instmem *imem; 242 struct nouveau_instmem *imem;
257 struct nouveau_fb *pfb; 243 struct nouveau_fb *pfb;
@@ -263,7 +249,6 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
263 if (!drm->channel) 249 if (!drm->channel)
264 return nouveau_abi16_put(abi16, -ENODEV); 250 return nouveau_abi16_put(abi16, -ENODEV);
265 251
266 client = nv_client(abi16->client);
267 device = &abi16->device; 252 device = &abi16->device;
268 imem = nvkm_instmem(device); 253 imem = nvkm_instmem(device);
269 pfb = nvkm_fb(device); 254 pfb = nvkm_fb(device);
@@ -298,8 +283,8 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
298 abi16->handles |= (1ULL << init->channel); 283 abi16->handles |= (1ULL << init->channel);
299 284
300 /* create channel object and initialise dma and fence management */ 285 /* create channel object and initialise dma and fence management */
301 ret = nouveau_channel_new(drm, cli, NVDRM_DEVICE, NVDRM_CHAN | 286 ret = nouveau_channel_new(drm, device, NVDRM_CHAN | init->channel,
302 init->channel, init->fb_ctxdma_handle, 287 init->fb_ctxdma_handle,
303 init->tt_ctxdma_handle, &chan->chan); 288 init->tt_ctxdma_handle, &chan->chan);
304 if (ret) 289 if (ret)
305 goto done; 290 goto done;
@@ -330,7 +315,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
330 goto done; 315 goto done;
331 316
332 if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) { 317 if (device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
333 ret = nouveau_bo_vma_add(chan->ntfy, client->vm, 318 ret = nouveau_bo_vma_add(chan->ntfy, cli->vm,
334 &chan->ntfy_vma); 319 &chan->ntfy_vma);
335 if (ret) 320 if (ret)
336 goto done; 321 goto done;
@@ -361,7 +346,7 @@ nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS)
361 return -ENOMEM; 346 return -ENOMEM;
362 347
363 list_for_each_entry(chan, &abi16->channels, head) { 348 list_for_each_entry(chan, &abi16->channels, head) {
364 if (chan->chan->handle == (NVDRM_CHAN | req->channel)) { 349 if (chan->chan->object->handle == (NVDRM_CHAN | req->channel)) {
365 nouveau_abi16_chan_fini(abi16, chan); 350 nouveau_abi16_chan_fini(abi16, chan);
366 return nouveau_abi16_put(abi16, 0); 351 return nouveau_abi16_put(abi16, 0);
367 } 352 }
@@ -392,8 +377,10 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
392 return nouveau_abi16_put(abi16, 0); 377 return nouveau_abi16_put(abi16, 0);
393 } 378 }
394 379
395 ret = nouveau_object_new(abi16->client, NVDRM_CHAN | init->channel, 380 /*XXX*/
396 init->handle, init->class, NULL, 0, &object); 381 ret = nouveau_object_new(nv_object(nvkm_client(&abi16->device.base)),
382 NVDRM_CHAN | init->channel, init->handle,
383 init->class, NULL, 0, &object);
397 return nouveau_abi16_put(abi16, ret); 384 return nouveau_abi16_put(abi16, ret);
398} 385}
399 386
@@ -418,7 +405,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
418 return nouveau_abi16_put(abi16, -EINVAL); 405 return nouveau_abi16_put(abi16, -EINVAL);
419 406
420 list_for_each_entry(temp, &abi16->channels, head) { 407 list_for_each_entry(temp, &abi16->channels, head) {
421 if (temp->chan->handle == (NVDRM_CHAN | info->channel)) { 408 if (temp->chan->object->handle == (NVDRM_CHAN | info->channel)) {
422 chan = temp; 409 chan = temp;
423 break; 410 break;
424 } 411 }
@@ -456,9 +443,11 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
456 args.limit += chan->ntfy->bo.offset; 443 args.limit += chan->ntfy->bo.offset;
457 } 444 }
458 445
459 ret = nouveau_object_new(abi16->client, chan->chan->handle, 446 /*XXX*/
460 ntfy->handle, 0x003d, &args, 447 ret = nouveau_object_new(nv_object(nvkm_client(&abi16->device.base)),
461 sizeof(args), &object); 448 NVDRM_CHAN | info->channel, ntfy->handle,
449 NV_DMA_IN_MEMORY_CLASS, &args, sizeof(args),
450 &object);
462 if (ret) 451 if (ret)
463 goto done; 452 goto done;
464 453
@@ -483,7 +472,7 @@ nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS)
483 return -ENOMEM; 472 return -ENOMEM;
484 473
485 list_for_each_entry(temp, &abi16->channels, head) { 474 list_for_each_entry(temp, &abi16->channels, head) {
486 if (temp->chan->handle == (NVDRM_CHAN | fini->channel)) { 475 if (temp->chan->object->handle == (NVDRM_CHAN | fini->channel)) {
487 chan = temp; 476 chan = temp;
488 break; 477 break;
489 } 478 }
@@ -495,7 +484,9 @@ nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS)
495 /* synchronize with the user channel and destroy the gpu object */ 484 /* synchronize with the user channel and destroy the gpu object */
496 nouveau_channel_idle(chan->chan); 485 nouveau_channel_idle(chan->chan);
497 486
498 ret = nouveau_object_del(abi16->client, chan->chan->handle, fini->handle); 487 /*XXX*/
488 ret = nouveau_object_del(nv_object(nvkm_client(&abi16->device.base)),
489 chan->chan->object->handle, fini->handle);
499 if (ret) 490 if (ret)
500 return nouveau_abi16_put(abi16, ret); 491 return nouveau_abi16_put(abi16, ret);
501 492