aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-03-17 10:40:41 -0400
committerBen Skeggs <bskeggs@redhat.com>2012-03-22 03:17:46 -0400
commit48aca13f0167ae78c28c6b48d82a157a6692eecb (patch)
tree54937c4fc0e8f19fcf2d8abfb35a82798f85ce96 /drivers/gpu/drm
parentd5316e251230c4e54a157349a362229c3d4daa32 (diff)
drm/nouveau: remove m2mf creation on userspace channels
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_channel.c19
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_dma.c61
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c91
4 files changed, 93 insertions, 81 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index a018defb7621..337e228629ed 100644
--- a/drivers/gpu/drm/nouveau/nouveau_channel.c
+++ b/drivers/gpu/drm/nouveau/nouveau_channel.c
@@ -122,7 +122,7 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret,
122 struct nouveau_fpriv *fpriv = nouveau_fpriv(file_priv); 122 struct nouveau_fpriv *fpriv = nouveau_fpriv(file_priv);
123 struct nouveau_channel *chan; 123 struct nouveau_channel *chan;
124 unsigned long flags; 124 unsigned long flags;
125 int ret; 125 int ret, i;
126 126
127 /* allocate and lock channel structure */ 127 /* allocate and lock channel structure */
128 chan = kzalloc(sizeof(*chan), GFP_KERNEL); 128 chan = kzalloc(sizeof(*chan), GFP_KERNEL);
@@ -184,7 +184,7 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret,
184 return ret; 184 return ret;
185 } 185 }
186 186
187 nouveau_dma_pre_init(chan); 187 nouveau_dma_init(chan);
188 chan->user_put = 0x40; 188 chan->user_put = 0x40;
189 chan->user_get = 0x44; 189 chan->user_get = 0x44;
190 if (dev_priv->card_type >= NV_50) 190 if (dev_priv->card_type >= NV_50)
@@ -202,9 +202,18 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret,
202 202
203 pfifo->reassign(dev, true); 203 pfifo->reassign(dev, true);
204 204
205 ret = nouveau_dma_init(chan); 205 /* Insert NOPs for NOUVEAU_DMA_SKIPS */
206 if (!ret) 206 ret = RING_SPACE(chan, NOUVEAU_DMA_SKIPS);
207 ret = nouveau_fence_channel_init(chan); 207 if (ret) {
208 nouveau_channel_put(&chan);
209 return ret;
210 }
211
212 for (i = 0; i < NOUVEAU_DMA_SKIPS; i++)
213 OUT_RING (chan, 0x00000000);
214 FIRE_RING(chan);
215
216 ret = nouveau_fence_channel_init(chan);
208 if (ret) { 217 if (ret) {
209 nouveau_channel_put(&chan); 218 nouveau_channel_put(&chan);
210 return ret; 219 return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c
index 4c2e4e5925fe..295932e66ac5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.c
@@ -31,7 +31,7 @@
31#include "nouveau_ramht.h" 31#include "nouveau_ramht.h"
32 32
33void 33void
34nouveau_dma_pre_init(struct nouveau_channel *chan) 34nouveau_dma_init(struct nouveau_channel *chan)
35{ 35{
36 struct drm_nouveau_private *dev_priv = chan->dev->dev_private; 36 struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
37 struct nouveau_bo *pushbuf = chan->pushbuf_bo; 37 struct nouveau_bo *pushbuf = chan->pushbuf_bo;
@@ -54,65 +54,6 @@ nouveau_dma_pre_init(struct nouveau_channel *chan)
54 chan->dma.free = chan->dma.max - chan->dma.cur; 54 chan->dma.free = chan->dma.max - chan->dma.cur;
55} 55}
56 56
57int
58nouveau_dma_init(struct nouveau_channel *chan)
59{
60 struct drm_device *dev = chan->dev;
61 struct drm_nouveau_private *dev_priv = dev->dev_private;
62 int ret, i;
63
64 if (dev_priv->card_type >= NV_C0) {
65 ret = nouveau_gpuobj_gr_new(chan, 0x9039, 0x9039);
66 if (ret)
67 return ret;
68
69 ret = RING_SPACE(chan, 2);
70 if (ret)
71 return ret;
72
73 BEGIN_NVC0(chan, 2, NvSubM2MF, 0x0000, 1);
74 OUT_RING (chan, 0x00009039);
75 FIRE_RING (chan);
76 return 0;
77 }
78
79 /* Create NV_MEMORY_TO_MEMORY_FORMAT for buffer moves */
80 ret = nouveau_gpuobj_gr_new(chan, NvM2MF, dev_priv->card_type < NV_50 ?
81 0x0039 : 0x5039);
82 if (ret)
83 return ret;
84
85 /* NV_MEMORY_TO_MEMORY_FORMAT requires a notifier object */
86 ret = nouveau_notifier_alloc(chan, NvNotify0, 32, 0xfe0, 0x1000,
87 &chan->m2mf_ntfy);
88 if (ret)
89 return ret;
90
91 /* Insert NOPS for NOUVEAU_DMA_SKIPS */
92 ret = RING_SPACE(chan, NOUVEAU_DMA_SKIPS);
93 if (ret)
94 return ret;
95
96 for (i = 0; i < NOUVEAU_DMA_SKIPS; i++)
97 OUT_RING(chan, 0);
98
99 /* Initialise NV_MEMORY_TO_MEMORY_FORMAT */
100 ret = RING_SPACE(chan, 6);
101 if (ret)
102 return ret;
103 BEGIN_RING(chan, NvSubM2MF, NV_MEMORY_TO_MEMORY_FORMAT_NAME, 1);
104 OUT_RING (chan, NvM2MF);
105 BEGIN_RING(chan, NvSubM2MF, NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3);
106 OUT_RING (chan, NvNotify0);
107 OUT_RING (chan, chan->vram_handle);
108 OUT_RING (chan, chan->gart_handle);
109
110 /* Sit back and pray the channel works.. */
111 FIRE_RING(chan);
112
113 return 0;
114}
115
116void 57void
117OUT_RINGp(struct nouveau_channel *chan, const void *data, unsigned nr_dwords) 58OUT_RINGp(struct nouveau_channel *chan, const void *data, unsigned nr_dwords)
118{ 59{
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 3dd620fc7837..2d6032e2063f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -1089,8 +1089,7 @@ nouveau_debugfs_channel_fini(struct nouveau_channel *chan)
1089#endif 1089#endif
1090 1090
1091/* nouveau_dma.c */ 1091/* nouveau_dma.c */
1092extern void nouveau_dma_pre_init(struct nouveau_channel *); 1092extern void nouveau_dma_init(struct nouveau_channel *);
1093extern int nouveau_dma_init(struct nouveau_channel *);
1094extern int nouveau_dma_wait(struct nouveau_channel *, int slots, int size); 1093extern int nouveau_dma_wait(struct nouveau_channel *, int slots, int size);
1095 1094
1096/* nouveau_acpi.c */ 1095/* nouveau_acpi.c */
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index 9c144fb8bbba..6476cf604cc4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -552,6 +552,75 @@ static bool nouveau_switcheroo_can_switch(struct pci_dev *pdev)
552 return can_switch; 552 return can_switch;
553} 553}
554 554
555static void
556nouveau_card_channel_fini(struct drm_device *dev)
557{
558 struct drm_nouveau_private *dev_priv = dev->dev_private;
559
560 if (dev_priv->channel)
561 nouveau_channel_put_unlocked(&dev_priv->channel);
562}
563
564static int
565nouveau_card_channel_init(struct drm_device *dev)
566{
567 struct drm_nouveau_private *dev_priv = dev->dev_private;
568 struct nouveau_channel *chan;
569 int ret, oclass;
570
571 ret = nouveau_channel_alloc(dev, &chan, NULL, NvDmaFB, NvDmaTT);
572 dev_priv->channel = chan;
573 if (ret)
574 return ret;
575
576 mutex_unlock(&dev_priv->channel->mutex);
577
578 if (dev_priv->card_type <= NV_50) {
579 if (dev_priv->card_type < NV_50)
580 oclass = 0x0039;
581 else
582 oclass = 0x5039;
583
584 ret = nouveau_gpuobj_gr_new(chan, NvM2MF, oclass);
585 if (ret)
586 goto error;
587
588 ret = nouveau_notifier_alloc(chan, NvNotify0, 32, 0xfe0, 0x1000,
589 &chan->m2mf_ntfy);
590 if (ret)
591 goto error;
592
593 ret = RING_SPACE(chan, 6);
594 if (ret)
595 goto error;
596
597 BEGIN_RING(chan, NvSubM2MF, NV_MEMORY_TO_MEMORY_FORMAT_NAME, 1);
598 OUT_RING (chan, NvM2MF);
599 BEGIN_RING(chan, NvSubM2MF, NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3);
600 OUT_RING (chan, NvNotify0);
601 OUT_RING (chan, chan->vram_handle);
602 OUT_RING (chan, chan->gart_handle);
603 } else
604 if (dev_priv->card_type <= NV_C0) {
605 ret = nouveau_gpuobj_gr_new(chan, 0x9039, 0x9039);
606 if (ret)
607 goto error;
608
609 ret = RING_SPACE(chan, 2);
610 if (ret)
611 goto error;
612
613 BEGIN_NVC0(chan, 2, NvSubM2MF, 0x0000, 1);
614 OUT_RING (chan, 0x00009039);
615 }
616
617 FIRE_RING (chan);
618error:
619 if (ret)
620 nouveau_card_channel_fini(dev);
621 return ret;
622}
623
555int 624int
556nouveau_card_init(struct drm_device *dev) 625nouveau_card_init(struct drm_device *dev)
557{ 626{
@@ -738,17 +807,14 @@ nouveau_card_init(struct drm_device *dev)
738 nouveau_backlight_init(dev); 807 nouveau_backlight_init(dev);
739 nouveau_pm_init(dev); 808 nouveau_pm_init(dev);
740 809
741 if (dev_priv->eng[NVOBJ_ENGINE_GR]) { 810 ret = nouveau_fence_init(dev);
742 ret = nouveau_fence_init(dev); 811 if (ret)
743 if (ret) 812 goto out_pm;
744 goto out_pm;
745 813
746 ret = nouveau_channel_alloc(dev, &dev_priv->channel, NULL, 814 if (!dev_priv->noaccel) {
747 NvDmaFB, NvDmaTT); 815 ret = nouveau_card_channel_init(dev);
748 if (ret) 816 if (ret)
749 goto out_fence; 817 goto out_fence;
750
751 mutex_unlock(&dev_priv->channel->mutex);
752 } 818 }
753 819
754 if (dev->mode_config.num_crtc) { 820 if (dev->mode_config.num_crtc) {
@@ -762,7 +828,7 @@ nouveau_card_init(struct drm_device *dev)
762 return 0; 828 return 0;
763 829
764out_chan: 830out_chan:
765 nouveau_channel_put_unlocked(&dev_priv->channel); 831 nouveau_card_channel_fini(dev);
766out_fence: 832out_fence:
767 nouveau_fence_fini(dev); 833 nouveau_fence_fini(dev);
768out_pm: 834out_pm:
@@ -820,11 +886,8 @@ static void nouveau_card_takedown(struct drm_device *dev)
820 nouveau_display_fini(dev); 886 nouveau_display_fini(dev);
821 } 887 }
822 888
823 if (dev_priv->channel) { 889 nouveau_card_channel_fini(dev);
824 nouveau_channel_put_unlocked(&dev_priv->channel); 890 nouveau_fence_fini(dev);
825 nouveau_fence_fini(dev);
826 }
827
828 nouveau_pm_fini(dev); 891 nouveau_pm_fini(dev);
829 nouveau_backlight_exit(dev); 892 nouveau_backlight_exit(dev);
830 nouveau_display_destroy(dev); 893 nouveau_display_destroy(dev);