aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2014-08-09 14:10:23 -0400
committerBen Skeggs <bskeggs@redhat.com>2014-08-09 15:13:17 -0400
commita4e610b5e655186f81f18f027d2b7a15e010cbef (patch)
treeb805e8cbfb32f7360039ae62f262a42ea1585f9c /drivers
parentfdb751ef2bbc78314d1e01d3425cfacfb19b9f86 (diff)
drm/nouveau: use ioctl interface for abi16 grobj alloc
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c77
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.h3
2 files changed, 46 insertions, 34 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 22c1eff58b40..ec15c97ec841 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -21,7 +21,9 @@
21 * 21 *
22 */ 22 */
23 23
24#include <nvif/os.h> 24#include <nvif/client.h>
25#include <nvif/driver.h>
26#include <nvif/ioctl.h>
25#include <nvif/class.h> 27#include <nvif/class.h>
26 28
27#include "nouveau_drm.h" 29#include "nouveau_drm.h"
@@ -46,7 +48,7 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev)
46 * opened) 48 * opened)
47 */ 49 */
48 if (nvif_device_init(&cli->base.base, NULL, 50 if (nvif_device_init(&cli->base.base, NULL,
49 NVDRM_DEVICE, NV_DEVICE_CLASS, 51 NOUVEAU_ABI16_DEVICE, NV_DEVICE,
50 &(struct nv_device_class) { 52 &(struct nv_device_class) {
51 .device = ~0ULL, 53 .device = ~0ULL,
52 }, sizeof(struct nv_device_class), 54 }, sizeof(struct nv_device_class),
@@ -280,7 +282,8 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
280 abi16->handles |= (1ULL << init->channel); 282 abi16->handles |= (1ULL << init->channel);
281 283
282 /* create channel object and initialise dma and fence management */ 284 /* create channel object and initialise dma and fence management */
283 ret = nouveau_channel_new(drm, device, NVDRM_CHAN | init->channel, 285 ret = nouveau_channel_new(drm, device,
286 NOUVEAU_ABI16_CHAN(init->channel),
284 init->fb_ctxdma_handle, 287 init->fb_ctxdma_handle,
285 init->tt_ctxdma_handle, &chan->chan); 288 init->tt_ctxdma_handle, &chan->chan);
286 if (ret) 289 if (ret)
@@ -330,6 +333,18 @@ done:
330 return nouveau_abi16_put(abi16, ret); 333 return nouveau_abi16_put(abi16, ret);
331} 334}
332 335
336static struct nouveau_abi16_chan *
337nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel)
338{
339 struct nouveau_abi16_chan *chan;
340
341 list_for_each_entry(chan, &abi16->channels, head) {
342 if (chan->chan->object->handle == NOUVEAU_ABI16_CHAN(channel))
343 return chan;
344 }
345
346 return NULL;
347}
333 348
334int 349int
335nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS) 350nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS)
@@ -337,28 +352,38 @@ nouveau_abi16_ioctl_channel_free(ABI16_IOCTL_ARGS)
337 struct drm_nouveau_channel_free *req = data; 352 struct drm_nouveau_channel_free *req = data;
338 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); 353 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
339 struct nouveau_abi16_chan *chan; 354 struct nouveau_abi16_chan *chan;
340 int ret = -ENOENT;
341 355
342 if (unlikely(!abi16)) 356 if (unlikely(!abi16))
343 return -ENOMEM; 357 return -ENOMEM;
344 358
345 list_for_each_entry(chan, &abi16->channels, head) { 359 chan = nouveau_abi16_chan(abi16, req->channel);
346 if (chan->chan->object->handle == (NVDRM_CHAN | req->channel)) { 360 if (!chan)
347 nouveau_abi16_chan_fini(abi16, chan); 361 return nouveau_abi16_put(abi16, -ENOENT);
348 return nouveau_abi16_put(abi16, 0); 362 nouveau_abi16_chan_fini(abi16, chan);
349 } 363 return nouveau_abi16_put(abi16, 0);
350 }
351
352 return nouveau_abi16_put(abi16, ret);
353} 364}
354 365
355int 366int
356nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS) 367nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
357{ 368{
358 struct drm_nouveau_grobj_alloc *init = data; 369 struct drm_nouveau_grobj_alloc *init = data;
370 struct {
371 struct nvif_ioctl_v0 ioctl;
372 struct nvif_ioctl_new_v0 new;
373 } args = {
374 .ioctl.owner = NVIF_IOCTL_V0_OWNER_ANY,
375 .ioctl.type = NVIF_IOCTL_V0_NEW,
376 .ioctl.path_nr = 3,
377 .ioctl.path[2] = NOUVEAU_ABI16_CLIENT,
378 .ioctl.path[1] = NOUVEAU_ABI16_DEVICE,
379 .ioctl.path[0] = NOUVEAU_ABI16_CHAN(init->channel),
380 .new.route = NVDRM_OBJECT_ABI16,
381 .new.handle = init->handle,
382 .new.oclass = init->class,
383 };
359 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); 384 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
360 struct nouveau_drm *drm = nouveau_drm(dev); 385 struct nouveau_drm *drm = nouveau_drm(dev);
361 struct nouveau_object *object; 386 struct nvif_client *client;
362 int ret; 387 int ret;
363 388
364 if (unlikely(!abi16)) 389 if (unlikely(!abi16))
@@ -366,6 +391,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
366 391
367 if (init->handle == ~0) 392 if (init->handle == ~0)
368 return nouveau_abi16_put(abi16, -EINVAL); 393 return nouveau_abi16_put(abi16, -EINVAL);
394 client = nvif_client(nvif_object(&abi16->device));
369 395
370 /* compatibility with userspace that assumes 506e for all chipsets */ 396 /* compatibility with userspace that assumes 506e for all chipsets */
371 if (init->class == 0x506e) { 397 if (init->class == 0x506e) {
@@ -374,10 +400,7 @@ nouveau_abi16_ioctl_grobj_alloc(ABI16_IOCTL_ARGS)
374 return nouveau_abi16_put(abi16, 0); 400 return nouveau_abi16_put(abi16, 0);
375 } 401 }
376 402
377 /*XXX*/ 403 ret = nvif_client_ioctl(client, &args, sizeof(args));
378 ret = nouveau_object_new(nv_object(nvkm_client(&abi16->device.base)),
379 NVDRM_CHAN | init->channel, init->handle,
380 init->class, NULL, 0, &object);
381 return nouveau_abi16_put(abi16, ret); 404 return nouveau_abi16_put(abi16, ret);
382} 405}
383 406
@@ -387,7 +410,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
387 struct drm_nouveau_notifierobj_alloc *info = data; 410 struct drm_nouveau_notifierobj_alloc *info = data;
388 struct nouveau_drm *drm = nouveau_drm(dev); 411 struct nouveau_drm *drm = nouveau_drm(dev);
389 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); 412 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
390 struct nouveau_abi16_chan *chan = NULL, *temp; 413 struct nouveau_abi16_chan *chan;
391 struct nouveau_abi16_ntfy *ntfy; 414 struct nouveau_abi16_ntfy *ntfy;
392 struct nvif_device *device = &abi16->device; 415 struct nvif_device *device = &abi16->device;
393 struct nouveau_object *object; 416 struct nouveau_object *object;
@@ -401,13 +424,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
401 if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI)) 424 if (unlikely(device->info.family >= NV_DEVICE_INFO_V0_FERMI))
402 return nouveau_abi16_put(abi16, -EINVAL); 425 return nouveau_abi16_put(abi16, -EINVAL);
403 426
404 list_for_each_entry(temp, &abi16->channels, head) { 427 chan = nouveau_abi16_chan(abi16, info->channel);
405 if (temp->chan->object->handle == (NVDRM_CHAN | info->channel)) {
406 chan = temp;
407 break;
408 }
409 }
410
411 if (!chan) 428 if (!chan)
412 return nouveau_abi16_put(abi16, -ENOENT); 429 return nouveau_abi16_put(abi16, -ENOENT);
413 430
@@ -461,20 +478,14 @@ nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS)
461{ 478{
462 struct drm_nouveau_gpuobj_free *fini = data; 479 struct drm_nouveau_gpuobj_free *fini = data;
463 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev); 480 struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
464 struct nouveau_abi16_chan *chan = NULL, *temp; 481 struct nouveau_abi16_chan *chan;
465 struct nouveau_abi16_ntfy *ntfy; 482 struct nouveau_abi16_ntfy *ntfy;
466 int ret; 483 int ret;
467 484
468 if (unlikely(!abi16)) 485 if (unlikely(!abi16))
469 return -ENOMEM; 486 return -ENOMEM;
470 487
471 list_for_each_entry(temp, &abi16->channels, head) { 488 chan = nouveau_abi16_chan(abi16, fini->channel);
472 if (temp->chan->object->handle == (NVDRM_CHAN | fini->channel)) {
473 chan = temp;
474 break;
475 }
476 }
477
478 if (!chan) 489 if (!chan)
479 return nouveau_abi16_put(abi16, -ENOENT); 490 return nouveau_abi16_put(abi16, -ENOENT);
480 491
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
index 1fe401a898da..5479013e13f4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
@@ -31,7 +31,6 @@
31#include <core/class.h> 31#include <core/class.h>
32 32
33#include <drmP.h> 33#include <drmP.h>
34#include <drm/nouveau_drm.h>
35 34
36#include <drm/ttm/ttm_bo_api.h> 35#include <drm/ttm/ttm_bo_api.h>
37#include <drm/ttm/ttm_bo_driver.h> 36#include <drm/ttm/ttm_bo_driver.h>
@@ -40,6 +39,8 @@
40#include <drm/ttm/ttm_module.h> 39#include <drm/ttm/ttm_module.h>
41#include <drm/ttm/ttm_page_alloc.h> 40#include <drm/ttm/ttm_page_alloc.h>
42 41
42#include "uapi/drm/nouveau_drm.h"
43
43struct nouveau_channel; 44struct nouveau_channel;
44struct platform_device; 45struct platform_device;
45 46