drm/nouveau: pass flag to engine fini() method on suspend
authorBen Skeggs <bskeggs@redhat.com>
Wed, 20 Jul 2011 01:22:33 +0000 (11:22 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Sun, 24 Jul 2011 23:43:22 +0000 (09:43 +1000)
It may not be necessary to fail in certain cases (such as failing to idle)
on module unload, whereas on suspend it's important to ensure a consistent
state can be restored on resume.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
14 files changed:
drivers/gpu/drm/nouveau/nouveau_drv.c
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_state.c
drivers/gpu/drm/nouveau/nv04_graph.c
drivers/gpu/drm/nouveau/nv10_graph.c
drivers/gpu/drm/nouveau/nv20_graph.c
drivers/gpu/drm/nouveau/nv40_graph.c
drivers/gpu/drm/nouveau/nv40_mpeg.c
drivers/gpu/drm/nouveau/nv50_graph.c
drivers/gpu/drm/nouveau/nv50_mpeg.c
drivers/gpu/drm/nouveau/nv84_crypt.c
drivers/gpu/drm/nouveau/nva3_copy.c
drivers/gpu/drm/nouveau/nvc0_copy.c
drivers/gpu/drm/nouveau/nvc0_graph.c

index 8256370..b30ddd8 100644 (file)
@@ -214,10 +214,13 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
        pfifo->unload_context(dev);
 
        for (e = NVOBJ_ENGINE_NR - 1; e >= 0; e--) {
-               if (dev_priv->eng[e]) {
-                       ret = dev_priv->eng[e]->fini(dev, e);
-                       if (ret)
-                               goto out_abort;
+               if (!dev_priv->eng[e])
+                       continue;
+
+               ret = dev_priv->eng[e]->fini(dev, e, true);
+               if (ret) {
+                       NV_ERROR(dev, "... engine %d failed: %d\n", i, ret);
+                       goto out_abort;
                }
        }
 
index d0bd010..d7d51de 100644 (file)
@@ -312,7 +312,7 @@ struct nouveau_channel {
 struct nouveau_exec_engine {
        void (*destroy)(struct drm_device *, int engine);
        int  (*init)(struct drm_device *, int engine);
-       int  (*fini)(struct drm_device *, int engine);
+       int  (*fini)(struct drm_device *, int engine, bool suspend);
        int  (*context_new)(struct nouveau_channel *, int engine);
        void (*context_del)(struct nouveau_channel *, int engine);
        int  (*object_new)(struct nouveau_channel *, int engine,
index 1d08875..c7d87bc 100644 (file)
@@ -695,7 +695,7 @@ out_engine:
                for (e = e - 1; e >= 0; e--) {
                        if (!dev_priv->eng[e])
                                continue;
-                       dev_priv->eng[e]->fini(dev, e);
+                       dev_priv->eng[e]->fini(dev, e, false);
                        dev_priv->eng[e]->destroy(dev,e );
                }
        }
@@ -747,7 +747,7 @@ static void nouveau_card_takedown(struct drm_device *dev)
                engine->fifo.takedown(dev);
                for (e = NVOBJ_ENGINE_NR - 1; e >= 0; e--) {
                        if (dev_priv->eng[e]) {
-                               dev_priv->eng[e]->fini(dev, e);
+                               dev_priv->eng[e]->fini(dev, e, false);
                                dev_priv->eng[e]->destroy(dev,e );
                        }
                }
index 4129793..774cb7a 100644 (file)
@@ -538,7 +538,7 @@ nv04_graph_init(struct drm_device *dev, int engine)
 }
 
 static int
-nv04_graph_fini(struct drm_device *dev, int engine)
+nv04_graph_fini(struct drm_device *dev, int engine, bool suspend)
 {
        nv04_graph_unload_context(dev);
        nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0x00000000);
index 2567522..f22b323 100644 (file)
@@ -957,7 +957,7 @@ nv10_graph_init(struct drm_device *dev, int engine)
 }
 
 static int
-nv10_graph_fini(struct drm_device *dev, int engine)
+nv10_graph_fini(struct drm_device *dev, int engine, bool suspend)
 {
        nv10_graph_unload_context(dev);
        nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0x00000000);
index 3791222..a54b7d9 100644 (file)
@@ -654,7 +654,7 @@ nv30_graph_init(struct drm_device *dev, int engine)
 }
 
 int
-nv20_graph_fini(struct drm_device *dev, int engine)
+nv20_graph_fini(struct drm_device *dev, int engine, bool suspend)
 {
        nv20_graph_unload_context(dev);
        nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0x00000000);
index c7885e9..ba14a93 100644 (file)
@@ -346,7 +346,7 @@ nv40_graph_init(struct drm_device *dev, int engine)
 }
 
 static int
-nv40_graph_fini(struct drm_device *dev, int engine)
+nv40_graph_fini(struct drm_device *dev, int engine, bool suspend)
 {
        u32 inst = nv_rd32(dev, 0x40032c);
        if (inst & 0x01000000) {
index 6d2af29..ad03a0e 100644 (file)
@@ -137,7 +137,7 @@ nv40_mpeg_init(struct drm_device *dev, int engine)
 }
 
 static int
-nv40_mpeg_fini(struct drm_device *dev, int engine)
+nv40_mpeg_fini(struct drm_device *dev, int engine, bool suspend)
 {
        /*XXX: context save? */
        nv_mask(dev, 0x00b32c, 0x00000001, 0x00000000);
index e25cbb4..cce95dd 100644 (file)
@@ -125,7 +125,6 @@ static void
 nv50_graph_init_reset(struct drm_device *dev)
 {
        uint32_t pmc_e = NV_PMC_ENABLE_PGRAPH | (1 << 21);
-
        NV_DEBUG(dev, "\n");
 
        nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) & ~pmc_e);
@@ -255,9 +254,8 @@ nv50_graph_init(struct drm_device *dev, int engine)
 }
 
 static int
-nv50_graph_fini(struct drm_device *dev, int engine)
+nv50_graph_fini(struct drm_device *dev, int engine, bool suspend)
 {
-       NV_DEBUG(dev, "\n");
        nv50_graph_unload_context(dev);
        nv_wr32(dev, 0x40013c, 0x00000000);
        return 0;
index 1dc5913..b57a2d1 100644 (file)
@@ -160,7 +160,7 @@ nv50_mpeg_init(struct drm_device *dev, int engine)
 }
 
 static int
-nv50_mpeg_fini(struct drm_device *dev, int engine)
+nv50_mpeg_fini(struct drm_device *dev, int engine, bool suspend)
 {
        /*XXX: context save for s/r */
        nv_mask(dev, 0x00b32c, 0x00000001, 0x00000000);
index 75b809a..edece9c 100644 (file)
@@ -138,7 +138,7 @@ nv84_crypt_isr(struct drm_device *dev)
 }
 
 static int
-nv84_crypt_fini(struct drm_device *dev, int engine)
+nv84_crypt_fini(struct drm_device *dev, int engine, bool suspend)
 {
        nv_wr32(dev, 0x102140, 0x00000000);
        return 0;
index b86820a..8f356d5 100644 (file)
@@ -140,7 +140,7 @@ nva3_copy_init(struct drm_device *dev, int engine)
 }
 
 static int
-nva3_copy_fini(struct drm_device *dev, int engine)
+nva3_copy_fini(struct drm_device *dev, int engine, bool suspend)
 {
        nv_mask(dev, 0x104048, 0x00000003, 0x00000000);
 
index 5ebcd74..dddf006 100644 (file)
@@ -127,7 +127,7 @@ nvc0_copy_init(struct drm_device *dev, int engine)
 }
 
 static int
-nvc0_copy_fini(struct drm_device *dev, int engine)
+nvc0_copy_fini(struct drm_device *dev, int engine, bool suspend)
 {
        struct nvc0_copy_engine *pcopy = nv_engine(dev, engine);
 
index 3a97431..5b2f6f4 100644 (file)
@@ -304,7 +304,7 @@ nvc0_graph_object_new(struct nouveau_channel *chan, int engine,
 }
 
 static int
-nvc0_graph_fini(struct drm_device *dev, int engine)
+nvc0_graph_fini(struct drm_device *dev, int engine, bool suspend)
 {
        return 0;
 }