]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
drm/nouveau: remove m2mf creation on userspace channels
authorBen Skeggs <bskeggs@redhat.com>
Sat, 17 Mar 2012 14:40:41 +0000 (00:40 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 22 Mar 2012 07:17:46 +0000 (17:17 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_channel.c
drivers/gpu/drm/nouveau/nouveau_dma.c
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_state.c

index a018defb7621fd2e1c91e45f271485bebd9b17c5..337e228629ed66860c1d919fa26992c18580c28a 100644 (file)
@@ -122,7 +122,7 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret,
        struct nouveau_fpriv *fpriv = nouveau_fpriv(file_priv);
        struct nouveau_channel *chan;
        unsigned long flags;
-       int ret;
+       int ret, i;
 
        /* allocate and lock channel structure */
        chan = kzalloc(sizeof(*chan), GFP_KERNEL);
@@ -184,7 +184,7 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret,
                return ret;
        }
 
-       nouveau_dma_pre_init(chan);
+       nouveau_dma_init(chan);
        chan->user_put = 0x40;
        chan->user_get = 0x44;
        if (dev_priv->card_type >= NV_50)
@@ -202,9 +202,18 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret,
 
        pfifo->reassign(dev, true);
 
-       ret = nouveau_dma_init(chan);
-       if (!ret)
-               ret = nouveau_fence_channel_init(chan);
+       /* Insert NOPs for NOUVEAU_DMA_SKIPS */
+       ret = RING_SPACE(chan, NOUVEAU_DMA_SKIPS);
+       if (ret) {
+               nouveau_channel_put(&chan);
+               return ret;
+       }
+
+       for (i = 0; i < NOUVEAU_DMA_SKIPS; i++)
+               OUT_RING  (chan, 0x00000000);
+       FIRE_RING(chan);
+
+       ret = nouveau_fence_channel_init(chan);
        if (ret) {
                nouveau_channel_put(&chan);
                return ret;
index 4c2e4e5925feb549a71826c81a11342d53167118..295932e66ac5b0a6a9918148fdcd3f69fe0db54e 100644 (file)
@@ -31,7 +31,7 @@
 #include "nouveau_ramht.h"
 
 void
-nouveau_dma_pre_init(struct nouveau_channel *chan)
+nouveau_dma_init(struct nouveau_channel *chan)
 {
        struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
        struct nouveau_bo *pushbuf = chan->pushbuf_bo;
@@ -54,65 +54,6 @@ nouveau_dma_pre_init(struct nouveau_channel *chan)
        chan->dma.free = chan->dma.max - chan->dma.cur;
 }
 
-int
-nouveau_dma_init(struct nouveau_channel *chan)
-{
-       struct drm_device *dev = chan->dev;
-       struct drm_nouveau_private *dev_priv = dev->dev_private;
-       int ret, i;
-
-       if (dev_priv->card_type >= NV_C0) {
-               ret = nouveau_gpuobj_gr_new(chan, 0x9039, 0x9039);
-               if (ret)
-                       return ret;
-
-               ret = RING_SPACE(chan, 2);
-               if (ret)
-                       return ret;
-
-               BEGIN_NVC0(chan, 2, NvSubM2MF, 0x0000, 1);
-               OUT_RING  (chan, 0x00009039);
-               FIRE_RING (chan);
-               return 0;
-       }
-
-       /* Create NV_MEMORY_TO_MEMORY_FORMAT for buffer moves */
-       ret = nouveau_gpuobj_gr_new(chan, NvM2MF, dev_priv->card_type < NV_50 ?
-                                   0x0039 : 0x5039);
-       if (ret)
-               return ret;
-
-       /* NV_MEMORY_TO_MEMORY_FORMAT requires a notifier object */
-       ret = nouveau_notifier_alloc(chan, NvNotify0, 32, 0xfe0, 0x1000,
-                                    &chan->m2mf_ntfy);
-       if (ret)
-               return ret;
-
-       /* Insert NOPS for NOUVEAU_DMA_SKIPS */
-       ret = RING_SPACE(chan, NOUVEAU_DMA_SKIPS);
-       if (ret)
-               return ret;
-
-       for (i = 0; i < NOUVEAU_DMA_SKIPS; i++)
-               OUT_RING(chan, 0);
-
-       /* Initialise NV_MEMORY_TO_MEMORY_FORMAT */
-       ret = RING_SPACE(chan, 6);
-       if (ret)
-               return ret;
-       BEGIN_RING(chan, NvSubM2MF, NV_MEMORY_TO_MEMORY_FORMAT_NAME, 1);
-       OUT_RING  (chan, NvM2MF);
-       BEGIN_RING(chan, NvSubM2MF, NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3);
-       OUT_RING  (chan, NvNotify0);
-       OUT_RING  (chan, chan->vram_handle);
-       OUT_RING  (chan, chan->gart_handle);
-
-       /* Sit back and pray the channel works.. */
-       FIRE_RING(chan);
-
-       return 0;
-}
-
 void
 OUT_RINGp(struct nouveau_channel *chan, const void *data, unsigned nr_dwords)
 {
index 3dd620fc7837b4776ec3256e8728aba023c6563b..2d6032e2063fa057d21e6ce5f042ae109829c945 100644 (file)
@@ -1089,8 +1089,7 @@ nouveau_debugfs_channel_fini(struct nouveau_channel *chan)
 #endif
 
 /* nouveau_dma.c */
-extern void nouveau_dma_pre_init(struct nouveau_channel *);
-extern int  nouveau_dma_init(struct nouveau_channel *);
+extern void nouveau_dma_init(struct nouveau_channel *);
 extern int  nouveau_dma_wait(struct nouveau_channel *, int slots, int size);
 
 /* nouveau_acpi.c */
index 9c144fb8bbba0634981e3b51d6f4c56a52a65339..6476cf604cc4afa8c4710f26cbba24d276a5a105 100644 (file)
@@ -552,6 +552,75 @@ static bool nouveau_switcheroo_can_switch(struct pci_dev *pdev)
        return can_switch;
 }
 
+static void
+nouveau_card_channel_fini(struct drm_device *dev)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+
+       if (dev_priv->channel)
+               nouveau_channel_put_unlocked(&dev_priv->channel);
+}
+
+static int
+nouveau_card_channel_init(struct drm_device *dev)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct nouveau_channel *chan;
+       int ret, oclass;
+
+       ret = nouveau_channel_alloc(dev, &chan, NULL, NvDmaFB, NvDmaTT);
+       dev_priv->channel = chan;
+       if (ret)
+               return ret;
+
+       mutex_unlock(&dev_priv->channel->mutex);
+
+       if (dev_priv->card_type <= NV_50) {
+               if (dev_priv->card_type < NV_50)
+                       oclass = 0x0039;
+               else
+                       oclass = 0x5039;
+
+               ret = nouveau_gpuobj_gr_new(chan, NvM2MF, oclass);
+               if (ret)
+                       goto error;
+
+               ret = nouveau_notifier_alloc(chan, NvNotify0, 32, 0xfe0, 0x1000,
+                                            &chan->m2mf_ntfy);
+               if (ret)
+                       goto error;
+
+               ret = RING_SPACE(chan, 6);
+               if (ret)
+                       goto error;
+
+               BEGIN_RING(chan, NvSubM2MF, NV_MEMORY_TO_MEMORY_FORMAT_NAME, 1);
+               OUT_RING  (chan, NvM2MF);
+               BEGIN_RING(chan, NvSubM2MF, NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 3);
+               OUT_RING  (chan, NvNotify0);
+               OUT_RING  (chan, chan->vram_handle);
+               OUT_RING  (chan, chan->gart_handle);
+       } else
+       if (dev_priv->card_type <= NV_C0) {
+               ret = nouveau_gpuobj_gr_new(chan, 0x9039, 0x9039);
+               if (ret)
+                       goto error;
+
+               ret = RING_SPACE(chan, 2);
+               if (ret)
+                       goto error;
+
+               BEGIN_NVC0(chan, 2, NvSubM2MF, 0x0000, 1);
+               OUT_RING  (chan, 0x00009039);
+       }
+
+       FIRE_RING (chan);
+error:
+       if (ret)
+               nouveau_card_channel_fini(dev);
+       return ret;
+}
+
 int
 nouveau_card_init(struct drm_device *dev)
 {
@@ -738,17 +807,14 @@ nouveau_card_init(struct drm_device *dev)
        nouveau_backlight_init(dev);
        nouveau_pm_init(dev);
 
-       if (dev_priv->eng[NVOBJ_ENGINE_GR]) {
-               ret = nouveau_fence_init(dev);
-               if (ret)
-                       goto out_pm;
+       ret = nouveau_fence_init(dev);
+       if (ret)
+               goto out_pm;
 
-               ret = nouveau_channel_alloc(dev, &dev_priv->channel, NULL,
-                                           NvDmaFB, NvDmaTT);
+       if (!dev_priv->noaccel) {
+               ret = nouveau_card_channel_init(dev);
                if (ret)
                        goto out_fence;
-
-               mutex_unlock(&dev_priv->channel->mutex);
        }
 
        if (dev->mode_config.num_crtc) {
@@ -762,7 +828,7 @@ nouveau_card_init(struct drm_device *dev)
        return 0;
 
 out_chan:
-       nouveau_channel_put_unlocked(&dev_priv->channel);
+       nouveau_card_channel_fini(dev);
 out_fence:
        nouveau_fence_fini(dev);
 out_pm:
@@ -820,11 +886,8 @@ static void nouveau_card_takedown(struct drm_device *dev)
                nouveau_display_fini(dev);
        }
 
-       if (dev_priv->channel) {
-               nouveau_channel_put_unlocked(&dev_priv->channel);
-               nouveau_fence_fini(dev);
-       }
-
+       nouveau_card_channel_fini(dev);
+       nouveau_fence_fini(dev);
        nouveau_pm_fini(dev);
        nouveau_backlight_exit(dev);
        nouveau_display_destroy(dev);