Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/nouveau: pass flag to engine fini() method on suspend

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>

+21 -20
+7 -4
drivers/gpu/drm/nouveau/nouveau_drv.c
··· 214 214 pfifo->unload_context(dev); 215 215 216 216 for (e = NVOBJ_ENGINE_NR - 1; e >= 0; e--) { 217 - if (dev_priv->eng[e]) { 218 - ret = dev_priv->eng[e]->fini(dev, e); 219 - if (ret) 220 - goto out_abort; 217 + if (!dev_priv->eng[e]) 218 + continue; 219 + 220 + ret = dev_priv->eng[e]->fini(dev, e, true); 221 + if (ret) { 222 + NV_ERROR(dev, "... engine %d failed: %d\n", i, ret); 223 + goto out_abort; 221 224 } 222 225 } 223 226
+1 -1
drivers/gpu/drm/nouveau/nouveau_drv.h
··· 312 312 struct nouveau_exec_engine { 313 313 void (*destroy)(struct drm_device *, int engine); 314 314 int (*init)(struct drm_device *, int engine); 315 - int (*fini)(struct drm_device *, int engine); 315 + int (*fini)(struct drm_device *, int engine, bool suspend); 316 316 int (*context_new)(struct nouveau_channel *, int engine); 317 317 void (*context_del)(struct nouveau_channel *, int engine); 318 318 int (*object_new)(struct nouveau_channel *, int engine,
+2 -2
drivers/gpu/drm/nouveau/nouveau_state.c
··· 695 695 for (e = e - 1; e >= 0; e--) { 696 696 if (!dev_priv->eng[e]) 697 697 continue; 698 - dev_priv->eng[e]->fini(dev, e); 698 + dev_priv->eng[e]->fini(dev, e, false); 699 699 dev_priv->eng[e]->destroy(dev,e ); 700 700 } 701 701 } ··· 747 747 engine->fifo.takedown(dev); 748 748 for (e = NVOBJ_ENGINE_NR - 1; e >= 0; e--) { 749 749 if (dev_priv->eng[e]) { 750 - dev_priv->eng[e]->fini(dev, e); 750 + dev_priv->eng[e]->fini(dev, e, false); 751 751 dev_priv->eng[e]->destroy(dev,e ); 752 752 } 753 753 }
+1 -1
drivers/gpu/drm/nouveau/nv04_graph.c
··· 538 538 } 539 539 540 540 static int 541 - nv04_graph_fini(struct drm_device *dev, int engine) 541 + nv04_graph_fini(struct drm_device *dev, int engine, bool suspend) 542 542 { 543 543 nv04_graph_unload_context(dev); 544 544 nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0x00000000);
+1 -1
drivers/gpu/drm/nouveau/nv10_graph.c
··· 957 957 } 958 958 959 959 static int 960 - nv10_graph_fini(struct drm_device *dev, int engine) 960 + nv10_graph_fini(struct drm_device *dev, int engine, bool suspend) 961 961 { 962 962 nv10_graph_unload_context(dev); 963 963 nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0x00000000);
+1 -1
drivers/gpu/drm/nouveau/nv20_graph.c
··· 654 654 } 655 655 656 656 int 657 - nv20_graph_fini(struct drm_device *dev, int engine) 657 + nv20_graph_fini(struct drm_device *dev, int engine, bool suspend) 658 658 { 659 659 nv20_graph_unload_context(dev); 660 660 nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0x00000000);
+1 -1
drivers/gpu/drm/nouveau/nv40_graph.c
··· 346 346 } 347 347 348 348 static int 349 - nv40_graph_fini(struct drm_device *dev, int engine) 349 + nv40_graph_fini(struct drm_device *dev, int engine, bool suspend) 350 350 { 351 351 u32 inst = nv_rd32(dev, 0x40032c); 352 352 if (inst & 0x01000000) {
+1 -1
drivers/gpu/drm/nouveau/nv40_mpeg.c
··· 137 137 } 138 138 139 139 static int 140 - nv40_mpeg_fini(struct drm_device *dev, int engine) 140 + nv40_mpeg_fini(struct drm_device *dev, int engine, bool suspend) 141 141 { 142 142 /*XXX: context save? */ 143 143 nv_mask(dev, 0x00b32c, 0x00000001, 0x00000000);
+1 -3
drivers/gpu/drm/nouveau/nv50_graph.c
··· 125 125 nv50_graph_init_reset(struct drm_device *dev) 126 126 { 127 127 uint32_t pmc_e = NV_PMC_ENABLE_PGRAPH | (1 << 21); 128 - 129 128 NV_DEBUG(dev, "\n"); 130 129 131 130 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) & ~pmc_e); ··· 254 255 } 255 256 256 257 static int 257 - nv50_graph_fini(struct drm_device *dev, int engine) 258 + nv50_graph_fini(struct drm_device *dev, int engine, bool suspend) 258 259 { 259 - NV_DEBUG(dev, "\n"); 260 260 nv50_graph_unload_context(dev); 261 261 nv_wr32(dev, 0x40013c, 0x00000000); 262 262 return 0;
+1 -1
drivers/gpu/drm/nouveau/nv50_mpeg.c
··· 160 160 } 161 161 162 162 static int 163 - nv50_mpeg_fini(struct drm_device *dev, int engine) 163 + nv50_mpeg_fini(struct drm_device *dev, int engine, bool suspend) 164 164 { 165 165 /*XXX: context save for s/r */ 166 166 nv_mask(dev, 0x00b32c, 0x00000001, 0x00000000);
+1 -1
drivers/gpu/drm/nouveau/nv84_crypt.c
··· 138 138 } 139 139 140 140 static int 141 - nv84_crypt_fini(struct drm_device *dev, int engine) 141 + nv84_crypt_fini(struct drm_device *dev, int engine, bool suspend) 142 142 { 143 143 nv_wr32(dev, 0x102140, 0x00000000); 144 144 return 0;
+1 -1
drivers/gpu/drm/nouveau/nva3_copy.c
··· 140 140 } 141 141 142 142 static int 143 - nva3_copy_fini(struct drm_device *dev, int engine) 143 + nva3_copy_fini(struct drm_device *dev, int engine, bool suspend) 144 144 { 145 145 nv_mask(dev, 0x104048, 0x00000003, 0x00000000); 146 146
+1 -1
drivers/gpu/drm/nouveau/nvc0_copy.c
··· 127 127 } 128 128 129 129 static int 130 - nvc0_copy_fini(struct drm_device *dev, int engine) 130 + nvc0_copy_fini(struct drm_device *dev, int engine, bool suspend) 131 131 { 132 132 struct nvc0_copy_engine *pcopy = nv_engine(dev, engine); 133 133
+1 -1
drivers/gpu/drm/nouveau/nvc0_graph.c
··· 304 304 } 305 305 306 306 static int 307 - nvc0_graph_fini(struct drm_device *dev, int engine) 307 + nvc0_graph_fini(struct drm_device *dev, int engine, bool suspend) 308 308 { 309 309 return 0; 310 310 }