aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-03-30 23:44:16 -0400
committerBen Skeggs <bskeggs@redhat.com>2011-05-15 20:47:52 -0400
commit4ea52f8974392b39ffb192fd31de80dc65b52657 (patch)
tree594e2a1cc6649768ee23bcb9958b091f8c0ea0c3
parent475feffabe7d42d3333bf9a17167f38f3c467d11 (diff)
drm/nouveau: move engine object creation into per-engine hooks
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h7
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_object.c95
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c8
-rw-r--r--drivers/gpu/drm/nouveau/nv04_graph.c28
-rw-r--r--drivers/gpu/drm/nouveau/nv40_graph.c27
-rw-r--r--drivers/gpu/drm/nouveau/nv50_graph.c26
-rw-r--r--drivers/gpu/drm/nouveau/nv84_crypt.c23
-rw-r--r--drivers/gpu/drm/nouveau/nvc0_graph.c6
8 files changed, 138 insertions, 82 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 0f5f797e500c..723e424d7033 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -383,6 +383,7 @@ struct nouveau_pgraph_engine {
383 void (*destroy_context)(struct nouveau_channel *); 383 void (*destroy_context)(struct nouveau_channel *);
384 int (*load_context)(struct nouveau_channel *); 384 int (*load_context)(struct nouveau_channel *);
385 int (*unload_context)(struct drm_device *); 385 int (*unload_context)(struct drm_device *);
386 int (*object_new)(struct nouveau_channel *chan, u32 handle, u16 class);
386 void (*tlb_flush)(struct drm_device *dev); 387 void (*tlb_flush)(struct drm_device *dev);
387 388
388 void (*set_tile_region)(struct drm_device *dev, int i); 389 void (*set_tile_region)(struct drm_device *dev, int i);
@@ -507,6 +508,7 @@ struct nouveau_crypt_engine {
507 void (*takedown)(struct drm_device *); 508 void (*takedown)(struct drm_device *);
508 int (*create_context)(struct nouveau_channel *); 509 int (*create_context)(struct nouveau_channel *);
509 void (*destroy_context)(struct nouveau_channel *); 510 void (*destroy_context)(struct nouveau_channel *);
511 int (*object_new)(struct nouveau_channel *, u32 handle, u16 class);
510 void (*tlb_flush)(struct drm_device *dev); 512 void (*tlb_flush)(struct drm_device *dev);
511}; 513};
512 514
@@ -1147,6 +1149,7 @@ extern int nv04_graph_create_context(struct nouveau_channel *);
1147extern void nv04_graph_destroy_context(struct nouveau_channel *); 1149extern void nv04_graph_destroy_context(struct nouveau_channel *);
1148extern int nv04_graph_load_context(struct nouveau_channel *); 1150extern int nv04_graph_load_context(struct nouveau_channel *);
1149extern int nv04_graph_unload_context(struct drm_device *); 1151extern int nv04_graph_unload_context(struct drm_device *);
1152extern int nv04_graph_object_new(struct nouveau_channel *, u32, u16);
1150extern int nv04_graph_mthd_page_flip(struct nouveau_channel *chan, 1153extern int nv04_graph_mthd_page_flip(struct nouveau_channel *chan,
1151 u32 class, u32 mthd, u32 data); 1154 u32 class, u32 mthd, u32 data);
1152extern struct nouveau_bitfield nv04_graph_nsource[]; 1155extern struct nouveau_bitfield nv04_graph_nsource[];
@@ -1181,6 +1184,7 @@ extern int nv40_graph_create_context(struct nouveau_channel *);
1181extern void nv40_graph_destroy_context(struct nouveau_channel *); 1184extern void nv40_graph_destroy_context(struct nouveau_channel *);
1182extern int nv40_graph_load_context(struct nouveau_channel *); 1185extern int nv40_graph_load_context(struct nouveau_channel *);
1183extern int nv40_graph_unload_context(struct drm_device *); 1186extern int nv40_graph_unload_context(struct drm_device *);
1187extern int nv40_graph_object_new(struct nouveau_channel *, u32, u16);
1184extern void nv40_grctx_init(struct nouveau_grctx *); 1188extern void nv40_grctx_init(struct nouveau_grctx *);
1185extern void nv40_graph_set_tile_region(struct drm_device *dev, int i); 1189extern void nv40_graph_set_tile_region(struct drm_device *dev, int i);
1186 1190
@@ -1193,6 +1197,7 @@ extern int nv50_graph_create_context(struct nouveau_channel *);
1193extern void nv50_graph_destroy_context(struct nouveau_channel *); 1197extern void nv50_graph_destroy_context(struct nouveau_channel *);
1194extern int nv50_graph_load_context(struct nouveau_channel *); 1198extern int nv50_graph_load_context(struct nouveau_channel *);
1195extern int nv50_graph_unload_context(struct drm_device *); 1199extern int nv50_graph_unload_context(struct drm_device *);
1200extern int nv50_graph_object_new(struct nouveau_channel *, u32, u16);
1196extern int nv50_grctx_init(struct nouveau_grctx *); 1201extern int nv50_grctx_init(struct nouveau_grctx *);
1197extern void nv50_graph_tlb_flush(struct drm_device *dev); 1202extern void nv50_graph_tlb_flush(struct drm_device *dev);
1198extern void nv84_graph_tlb_flush(struct drm_device *dev); 1203extern void nv84_graph_tlb_flush(struct drm_device *dev);
@@ -1207,6 +1212,7 @@ extern int nvc0_graph_create_context(struct nouveau_channel *);
1207extern void nvc0_graph_destroy_context(struct nouveau_channel *); 1212extern void nvc0_graph_destroy_context(struct nouveau_channel *);
1208extern int nvc0_graph_load_context(struct nouveau_channel *); 1213extern int nvc0_graph_load_context(struct nouveau_channel *);
1209extern int nvc0_graph_unload_context(struct drm_device *); 1214extern int nvc0_graph_unload_context(struct drm_device *);
1215extern int nvc0_graph_object_new(struct nouveau_channel *, u32, u16);
1210 1216
1211/* nv84_crypt.c */ 1217/* nv84_crypt.c */
1212extern int nv84_crypt_init(struct drm_device *dev); 1218extern int nv84_crypt_init(struct drm_device *dev);
@@ -1214,6 +1220,7 @@ extern void nv84_crypt_fini(struct drm_device *dev);
1214extern int nv84_crypt_create_context(struct nouveau_channel *); 1220extern int nv84_crypt_create_context(struct nouveau_channel *);
1215extern void nv84_crypt_destroy_context(struct nouveau_channel *); 1221extern void nv84_crypt_destroy_context(struct nouveau_channel *);
1216extern void nv84_crypt_tlb_flush(struct drm_device *dev); 1222extern void nv84_crypt_tlb_flush(struct drm_device *dev);
1223extern int nv84_crypt_object_new(struct nouveau_channel *, u32, u16);
1217 1224
1218/* nv04_instmem.c */ 1225/* nv04_instmem.c */
1219extern int nv04_instmem_init(struct drm_device *); 1226extern int nv04_instmem_init(struct drm_device *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c
index 67a16e01ffa6..f7b806f26f2f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_object.c
+++ b/drivers/gpu/drm/nouveau/nouveau_object.c
@@ -361,20 +361,6 @@ nouveau_gpuobj_new_fake(struct drm_device *dev, u32 pinst, u64 vinst,
361 return 0; 361 return 0;
362} 362}
363 363
364
365static uint32_t
366nouveau_gpuobj_class_instmem_size(struct drm_device *dev, int class)
367{
368 struct drm_nouveau_private *dev_priv = dev->dev_private;
369
370 /*XXX: dodgy hack for now */
371 if (dev_priv->card_type >= NV_50)
372 return 24;
373 if (dev_priv->card_type >= NV_40)
374 return 32;
375 return 16;
376}
377
378/* 364/*
379 DMA objects are used to reference a piece of memory in the 365 DMA objects are used to reference a piece of memory in the
380 framebuffer, PCI or AGP address space. Each object is 16 bytes big 366 framebuffer, PCI or AGP address space. Each object is 16 bytes big
@@ -606,11 +592,11 @@ nouveau_gpuobj_dma_new(struct nouveau_channel *chan, int class, u64 base,
606 set to 0? 592 set to 0?
607*/ 593*/
608static int 594static int
609nouveau_gpuobj_sw_new(struct nouveau_channel *chan, int class, 595nouveau_gpuobj_sw_new(struct nouveau_channel *chan, u32 handle, u16 class)
610 struct nouveau_gpuobj **gpuobj_ret)
611{ 596{
612 struct drm_nouveau_private *dev_priv = chan->dev->dev_private; 597 struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
613 struct nouveau_gpuobj *gpuobj; 598 struct nouveau_gpuobj *gpuobj;
599 int ret;
614 600
615 gpuobj = kzalloc(sizeof(*gpuobj), GFP_KERNEL); 601 gpuobj = kzalloc(sizeof(*gpuobj), GFP_KERNEL);
616 if (!gpuobj) 602 if (!gpuobj)
@@ -624,17 +610,20 @@ nouveau_gpuobj_sw_new(struct nouveau_channel *chan, int class,
624 spin_lock(&dev_priv->ramin_lock); 610 spin_lock(&dev_priv->ramin_lock);
625 list_add_tail(&gpuobj->list, &dev_priv->gpuobj_list); 611 list_add_tail(&gpuobj->list, &dev_priv->gpuobj_list);
626 spin_unlock(&dev_priv->ramin_lock); 612 spin_unlock(&dev_priv->ramin_lock);
627 *gpuobj_ret = gpuobj; 613
628 return 0; 614 ret = nouveau_ramht_insert(chan, handle, gpuobj);
615 nouveau_gpuobj_ref(NULL, &gpuobj);
616 return ret;
629} 617}
630 618
631int 619int
632nouveau_gpuobj_gr_new(struct nouveau_channel *chan, u32 handle, int class) 620nouveau_gpuobj_gr_new(struct nouveau_channel *chan, u32 handle, int class)
633{ 621{
634 struct drm_nouveau_private *dev_priv = chan->dev->dev_private; 622 struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
623 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
624 struct nouveau_crypt_engine *pcrypt = &dev_priv->engine.crypt;
635 struct drm_device *dev = chan->dev; 625 struct drm_device *dev = chan->dev;
636 struct nouveau_gpuobj_class *oc; 626 struct nouveau_gpuobj_class *oc;
637 struct nouveau_gpuobj *gpuobj;
638 int ret; 627 int ret;
639 628
640 NV_DEBUG(dev, "ch%d class=0x%04x\n", chan->id, class); 629 NV_DEBUG(dev, "ch%d class=0x%04x\n", chan->id, class);
@@ -650,85 +639,27 @@ nouveau_gpuobj_gr_new(struct nouveau_channel *chan, u32 handle, int class)
650found: 639found:
651 switch (oc->engine) { 640 switch (oc->engine) {
652 case NVOBJ_ENGINE_SW: 641 case NVOBJ_ENGINE_SW:
653 if (dev_priv->card_type < NV_C0) { 642 return nouveau_gpuobj_sw_new(chan, handle, class);
654 ret = nouveau_gpuobj_sw_new(chan, class, &gpuobj);
655 if (ret)
656 return ret;
657 goto insert;
658 }
659 break;
660 case NVOBJ_ENGINE_GR: 643 case NVOBJ_ENGINE_GR:
661 if ((dev_priv->card_type >= NV_20 && !chan->ramin_grctx) || 644 if ((dev_priv->card_type >= NV_20 && !chan->ramin_grctx) ||
662 (dev_priv->card_type < NV_20 && !chan->pgraph_ctx)) { 645 (dev_priv->card_type < NV_20 && !chan->pgraph_ctx)) {
663 struct nouveau_pgraph_engine *pgraph =
664 &dev_priv->engine.graph;
665
666 ret = pgraph->create_context(chan); 646 ret = pgraph->create_context(chan);
667 if (ret) 647 if (ret)
668 return ret; 648 return ret;
669 } 649 }
670 break; 650
651 return pgraph->object_new(chan, handle, class);
671 case NVOBJ_ENGINE_CRYPT: 652 case NVOBJ_ENGINE_CRYPT:
672 if (!chan->crypt_ctx) { 653 if (!chan->crypt_ctx) {
673 struct nouveau_crypt_engine *pcrypt =
674 &dev_priv->engine.crypt;
675
676 ret = pcrypt->create_context(chan); 654 ret = pcrypt->create_context(chan);
677 if (ret) 655 if (ret)
678 return ret; 656 return ret;
679 } 657 }
680 break;
681 }
682
683 /* we're done if this is fermi */
684 if (dev_priv->card_type >= NV_C0)
685 return 0;
686
687 ret = nouveau_gpuobj_new(dev, chan,
688 nouveau_gpuobj_class_instmem_size(dev, class),
689 16,
690 NVOBJ_FLAG_ZERO_ALLOC | NVOBJ_FLAG_ZERO_FREE,
691 &gpuobj);
692 if (ret) {
693 NV_ERROR(dev, "error creating gpuobj: %d\n", ret);
694 return ret;
695 }
696 658
697 if (dev_priv->card_type >= NV_50) { 659 return pcrypt->object_new(chan, handle, class);
698 nv_wo32(gpuobj, 0, class);
699 nv_wo32(gpuobj, 20, 0x00010000);
700 } else {
701 switch (class) {
702 case NV_CLASS_NULL:
703 nv_wo32(gpuobj, 0, 0x00001030);
704 nv_wo32(gpuobj, 4, 0xFFFFFFFF);
705 break;
706 default:
707 if (dev_priv->card_type >= NV_40) {
708 nv_wo32(gpuobj, 0, class);
709#ifdef __BIG_ENDIAN
710 nv_wo32(gpuobj, 8, 0x01000000);
711#endif
712 } else {
713#ifdef __BIG_ENDIAN
714 nv_wo32(gpuobj, 0, class | 0x00080000);
715#else
716 nv_wo32(gpuobj, 0, class);
717#endif
718 }
719 }
720 } 660 }
721 dev_priv->engine.instmem.flush(dev);
722 661
723 gpuobj->engine = oc->engine; 662 BUG_ON(1);
724 gpuobj->class = oc->id;
725
726insert:
727 ret = nouveau_ramht_insert(chan, handle, gpuobj);
728 if (ret)
729 NV_ERROR(dev, "error adding gpuobj to RAMHT: %d\n", ret);
730 nouveau_gpuobj_ref(NULL, &gpuobj);
731 return ret;
732} 663}
733 664
734static int 665static int
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index 4b4992824bbf..fa81b9017b35 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -73,6 +73,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
73 engine->graph.destroy_context = nv04_graph_destroy_context; 73 engine->graph.destroy_context = nv04_graph_destroy_context;
74 engine->graph.load_context = nv04_graph_load_context; 74 engine->graph.load_context = nv04_graph_load_context;
75 engine->graph.unload_context = nv04_graph_unload_context; 75 engine->graph.unload_context = nv04_graph_unload_context;
76 engine->graph.object_new = nv04_graph_object_new;
76 engine->fifo.channels = 16; 77 engine->fifo.channels = 16;
77 engine->fifo.init = nv04_fifo_init; 78 engine->fifo.init = nv04_fifo_init;
78 engine->fifo.takedown = nv04_fifo_fini; 79 engine->fifo.takedown = nv04_fifo_fini;
@@ -131,6 +132,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
131 engine->graph.fifo_access = nv04_graph_fifo_access; 132 engine->graph.fifo_access = nv04_graph_fifo_access;
132 engine->graph.load_context = nv10_graph_load_context; 133 engine->graph.load_context = nv10_graph_load_context;
133 engine->graph.unload_context = nv10_graph_unload_context; 134 engine->graph.unload_context = nv10_graph_unload_context;
135 engine->graph.object_new = nv04_graph_object_new;
134 engine->graph.set_tile_region = nv10_graph_set_tile_region; 136 engine->graph.set_tile_region = nv10_graph_set_tile_region;
135 engine->fifo.channels = 32; 137 engine->fifo.channels = 32;
136 engine->fifo.init = nv10_fifo_init; 138 engine->fifo.init = nv10_fifo_init;
@@ -190,6 +192,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
190 engine->graph.fifo_access = nv04_graph_fifo_access; 192 engine->graph.fifo_access = nv04_graph_fifo_access;
191 engine->graph.load_context = nv20_graph_load_context; 193 engine->graph.load_context = nv20_graph_load_context;
192 engine->graph.unload_context = nv20_graph_unload_context; 194 engine->graph.unload_context = nv20_graph_unload_context;
195 engine->graph.object_new = nv04_graph_object_new;
193 engine->graph.set_tile_region = nv20_graph_set_tile_region; 196 engine->graph.set_tile_region = nv20_graph_set_tile_region;
194 engine->fifo.channels = 32; 197 engine->fifo.channels = 32;
195 engine->fifo.init = nv10_fifo_init; 198 engine->fifo.init = nv10_fifo_init;
@@ -249,6 +252,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
249 engine->graph.destroy_context = nv20_graph_destroy_context; 252 engine->graph.destroy_context = nv20_graph_destroy_context;
250 engine->graph.load_context = nv20_graph_load_context; 253 engine->graph.load_context = nv20_graph_load_context;
251 engine->graph.unload_context = nv20_graph_unload_context; 254 engine->graph.unload_context = nv20_graph_unload_context;
255 engine->graph.object_new = nv04_graph_object_new;
252 engine->graph.set_tile_region = nv20_graph_set_tile_region; 256 engine->graph.set_tile_region = nv20_graph_set_tile_region;
253 engine->fifo.channels = 32; 257 engine->fifo.channels = 32;
254 engine->fifo.init = nv10_fifo_init; 258 engine->fifo.init = nv10_fifo_init;
@@ -311,6 +315,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
311 engine->graph.destroy_context = nv40_graph_destroy_context; 315 engine->graph.destroy_context = nv40_graph_destroy_context;
312 engine->graph.load_context = nv40_graph_load_context; 316 engine->graph.load_context = nv40_graph_load_context;
313 engine->graph.unload_context = nv40_graph_unload_context; 317 engine->graph.unload_context = nv40_graph_unload_context;
318 engine->graph.object_new = nv40_graph_object_new;
314 engine->graph.set_tile_region = nv40_graph_set_tile_region; 319 engine->graph.set_tile_region = nv40_graph_set_tile_region;
315 engine->fifo.channels = 32; 320 engine->fifo.channels = 32;
316 engine->fifo.init = nv40_fifo_init; 321 engine->fifo.init = nv40_fifo_init;
@@ -376,6 +381,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
376 engine->graph.destroy_context = nv50_graph_destroy_context; 381 engine->graph.destroy_context = nv50_graph_destroy_context;
377 engine->graph.load_context = nv50_graph_load_context; 382 engine->graph.load_context = nv50_graph_load_context;
378 engine->graph.unload_context = nv50_graph_unload_context; 383 engine->graph.unload_context = nv50_graph_unload_context;
384 engine->graph.object_new = nv50_graph_object_new;
379 if (dev_priv->chipset == 0x50 || 385 if (dev_priv->chipset == 0x50 ||
380 dev_priv->chipset == 0xac) 386 dev_priv->chipset == 0xac)
381 engine->graph.tlb_flush = nv50_graph_tlb_flush; 387 engine->graph.tlb_flush = nv50_graph_tlb_flush;
@@ -443,6 +449,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
443 engine->crypt.takedown = nv84_crypt_fini; 449 engine->crypt.takedown = nv84_crypt_fini;
444 engine->crypt.create_context = nv84_crypt_create_context; 450 engine->crypt.create_context = nv84_crypt_create_context;
445 engine->crypt.destroy_context = nv84_crypt_destroy_context; 451 engine->crypt.destroy_context = nv84_crypt_destroy_context;
452 engine->crypt.object_new = nv84_crypt_object_new;
446 engine->crypt.tlb_flush = nv84_crypt_tlb_flush; 453 engine->crypt.tlb_flush = nv84_crypt_tlb_flush;
447 break; 454 break;
448 default: 455 default:
@@ -480,6 +487,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
480 engine->graph.destroy_context = nvc0_graph_destroy_context; 487 engine->graph.destroy_context = nvc0_graph_destroy_context;
481 engine->graph.load_context = nvc0_graph_load_context; 488 engine->graph.load_context = nvc0_graph_load_context;
482 engine->graph.unload_context = nvc0_graph_unload_context; 489 engine->graph.unload_context = nvc0_graph_unload_context;
490 engine->graph.object_new = nvc0_graph_object_new;
483 engine->fifo.channels = 128; 491 engine->fifo.channels = 128;
484 engine->fifo.init = nvc0_fifo_init; 492 engine->fifo.init = nvc0_fifo_init;
485 engine->fifo.takedown = nvc0_fifo_takedown; 493 engine->fifo.takedown = nvc0_fifo_takedown;
diff --git a/drivers/gpu/drm/nouveau/nv04_graph.c b/drivers/gpu/drm/nouveau/nv04_graph.c
index 055677a2eea2..eb45f3aac885 100644
--- a/drivers/gpu/drm/nouveau/nv04_graph.c
+++ b/drivers/gpu/drm/nouveau/nv04_graph.c
@@ -28,6 +28,7 @@
28#include "nouveau_drv.h" 28#include "nouveau_drv.h"
29#include "nouveau_hw.h" 29#include "nouveau_hw.h"
30#include "nouveau_util.h" 30#include "nouveau_util.h"
31#include "nouveau_ramht.h"
31 32
32static int nv04_graph_register(struct drm_device *dev); 33static int nv04_graph_register(struct drm_device *dev);
33static void nv04_graph_isr(struct drm_device *dev); 34static void nv04_graph_isr(struct drm_device *dev);
@@ -481,6 +482,33 @@ nv04_graph_unload_context(struct drm_device *dev)
481 return 0; 482 return 0;
482} 483}
483 484
485int
486nv04_graph_object_new(struct nouveau_channel *chan, u32 handle, u16 class)
487{
488 struct drm_device *dev = chan->dev;
489 struct nouveau_gpuobj *obj = NULL;
490 int ret;
491
492 ret = nouveau_gpuobj_new(dev, chan, 16, 16, NVOBJ_FLAG_ZERO_FREE, &obj);
493 if (ret)
494 return ret;
495 obj->engine = 1;
496 obj->class = class;
497
498#ifdef __BIG_ENDIAN
499 nv_wo32(obj, 0x00, 0x00080000 | class);
500#else
501 nv_wo32(obj, 0x00, class);
502#endif
503 nv_wo32(obj, 0x04, 0x00000000);
504 nv_wo32(obj, 0x08, 0x00000000);
505 nv_wo32(obj, 0x0c, 0x00000000);
506
507 ret = nouveau_ramht_insert(chan, handle, obj);
508 nouveau_gpuobj_ref(NULL, &obj);
509 return ret;
510}
511
484int nv04_graph_init(struct drm_device *dev) 512int nv04_graph_init(struct drm_device *dev)
485{ 513{
486 struct drm_nouveau_private *dev_priv = dev->dev_private; 514 struct drm_nouveau_private *dev_priv = dev->dev_private;
diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
index fceb44c0ec74..2952daf43a3d 100644
--- a/drivers/gpu/drm/nouveau/nv40_graph.c
+++ b/drivers/gpu/drm/nouveau/nv40_graph.c
@@ -28,6 +28,7 @@
28#include "drm.h" 28#include "drm.h"
29#include "nouveau_drv.h" 29#include "nouveau_drv.h"
30#include "nouveau_grctx.h" 30#include "nouveau_grctx.h"
31#include "nouveau_ramht.h"
31 32
32static int nv40_graph_register(struct drm_device *); 33static int nv40_graph_register(struct drm_device *);
33static void nv40_graph_isr(struct drm_device *); 34static void nv40_graph_isr(struct drm_device *);
@@ -204,6 +205,32 @@ nv40_graph_unload_context(struct drm_device *dev)
204 return ret; 205 return ret;
205} 206}
206 207
208int
209nv40_graph_object_new(struct nouveau_channel *chan, u32 handle, u16 class)
210{
211 struct drm_device *dev = chan->dev;
212 struct nouveau_gpuobj *obj = NULL;
213 int ret;
214
215 ret = nouveau_gpuobj_new(dev, chan, 20, 16, NVOBJ_FLAG_ZERO_FREE, &obj);
216 if (ret)
217 return ret;
218 obj->engine = 1;
219 obj->class = class;
220
221 nv_wo32(obj, 0x00, class);
222 nv_wo32(obj, 0x04, 0x00000000);
223#ifdef __BIG_ENDIAN
224 nv_wo32(obj, 0x08, 0x01000000);
225#endif
226 nv_wo32(obj, 0x0c, 0x00000000);
227 nv_wo32(obj, 0x10, 0x00000000);
228
229 ret = nouveau_ramht_insert(chan, handle, obj);
230 nouveau_gpuobj_ref(NULL, &obj);
231 return ret;
232}
233
207void 234void
208nv40_graph_set_tile_region(struct drm_device *dev, int i) 235nv40_graph_set_tile_region(struct drm_device *dev, int i)
209{ 236{
diff --git a/drivers/gpu/drm/nouveau/nv50_graph.c b/drivers/gpu/drm/nouveau/nv50_graph.c
index 7950bac8123a..eb83179ed74f 100644
--- a/drivers/gpu/drm/nouveau/nv50_graph.c
+++ b/drivers/gpu/drm/nouveau/nv50_graph.c
@@ -31,6 +31,7 @@
31#include "nouveau_grctx.h" 31#include "nouveau_grctx.h"
32#include "nouveau_dma.h" 32#include "nouveau_dma.h"
33#include "nouveau_vm.h" 33#include "nouveau_vm.h"
34#include "nouveau_ramht.h"
34#include "nv50_evo.h" 35#include "nv50_evo.h"
35 36
36static int nv50_graph_register(struct drm_device *); 37static int nv50_graph_register(struct drm_device *);
@@ -364,6 +365,31 @@ nv50_graph_unload_context(struct drm_device *dev)
364 return 0; 365 return 0;
365} 366}
366 367
368int
369nv50_graph_object_new(struct nouveau_channel *chan, u32 handle, u16 class)
370{
371 struct drm_device *dev = chan->dev;
372 struct drm_nouveau_private *dev_priv = dev->dev_private;
373 struct nouveau_gpuobj *obj = NULL;
374 int ret;
375
376 ret = nouveau_gpuobj_new(dev, chan, 16, 16, NVOBJ_FLAG_ZERO_FREE, &obj);
377 if (ret)
378 return ret;
379 obj->engine = 1;
380 obj->class = class;
381
382 nv_wo32(obj, 0x00, class);
383 nv_wo32(obj, 0x04, 0x00000000);
384 nv_wo32(obj, 0x08, 0x00000000);
385 nv_wo32(obj, 0x0c, 0x00000000);
386 dev_priv->engine.instmem.flush(dev);
387
388 ret = nouveau_ramht_insert(chan, handle, obj);
389 nouveau_gpuobj_ref(NULL, &obj);
390 return ret;
391}
392
367static void 393static void
368nv50_graph_context_switch(struct drm_device *dev) 394nv50_graph_context_switch(struct drm_device *dev)
369{ 395{
diff --git a/drivers/gpu/drm/nouveau/nv84_crypt.c b/drivers/gpu/drm/nouveau/nv84_crypt.c
index fabc7fd30b1d..4918f4e60bab 100644
--- a/drivers/gpu/drm/nouveau/nv84_crypt.c
+++ b/drivers/gpu/drm/nouveau/nv84_crypt.c
@@ -26,6 +26,7 @@
26#include "nouveau_drv.h" 26#include "nouveau_drv.h"
27#include "nouveau_util.h" 27#include "nouveau_util.h"
28#include "nouveau_vm.h" 28#include "nouveau_vm.h"
29#include "nouveau_ramht.h"
29 30
30static void nv84_crypt_isr(struct drm_device *); 31static void nv84_crypt_isr(struct drm_device *);
31 32
@@ -84,6 +85,28 @@ nv84_crypt_destroy_context(struct nouveau_channel *chan)
84 atomic_dec(&chan->vm->pcrypt_refs); 85 atomic_dec(&chan->vm->pcrypt_refs);
85} 86}
86 87
88int
89nv84_crypt_object_new(struct nouveau_channel *chan, u32 handle, u16 class)
90{
91 struct drm_device *dev = chan->dev;
92 struct drm_nouveau_private *dev_priv = dev->dev_private;
93 struct nouveau_gpuobj *obj = NULL;
94 int ret;
95
96 ret = nouveau_gpuobj_new(dev, chan, 16, 16, NVOBJ_FLAG_ZERO_FREE, &obj);
97 if (ret)
98 return ret;
99 obj->engine = 5;
100 obj->class = class;
101
102 nv_wo32(obj, 0x00, class);
103 dev_priv->engine.instmem.flush(dev);
104
105 ret = nouveau_ramht_insert(chan, handle, obj);
106 nouveau_gpuobj_ref(NULL, &obj);
107 return ret;
108}
109
87void 110void
88nv84_crypt_tlb_flush(struct drm_device *dev) 111nv84_crypt_tlb_flush(struct drm_device *dev)
89{ 112{
diff --git a/drivers/gpu/drm/nouveau/nvc0_graph.c b/drivers/gpu/drm/nouveau/nvc0_graph.c
index 68f5c3f70f54..d1f2d56b1279 100644
--- a/drivers/gpu/drm/nouveau/nvc0_graph.c
+++ b/drivers/gpu/drm/nouveau/nvc0_graph.c
@@ -270,6 +270,12 @@ nvc0_graph_unload_context(struct drm_device *dev)
270 return nvc0_graph_unload_context_to(dev, inst); 270 return nvc0_graph_unload_context_to(dev, inst);
271} 271}
272 272
273int
274nvc0_graph_object_new(struct nouveau_channel *chan, u32 handle, u16 class)
275{
276 return 0;
277}
278
273static void 279static void
274nvc0_graph_destroy(struct drm_device *dev) 280nvc0_graph_destroy(struct drm_device *dev)
275{ 281{