diff options
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_channel.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/nouveau/nv50_graph.c | 10 | 
2 files changed, 10 insertions, 7 deletions
| diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c index 343d718a9667..2281f99da7fc 100644 --- a/drivers/gpu/drm/nouveau/nouveau_channel.c +++ b/drivers/gpu/drm/nouveau/nouveau_channel.c | |||
| @@ -278,12 +278,11 @@ nouveau_channel_free(struct nouveau_channel *chan) | |||
| 278 | /* Ensure the channel is no longer active on the GPU */ | 278 | /* Ensure the channel is no longer active on the GPU */ | 
| 279 | pfifo->reassign(dev, false); | 279 | pfifo->reassign(dev, false); | 
| 280 | 280 | ||
| 281 | if (pgraph->channel(dev) == chan) { | 281 | pgraph->fifo_access(dev, false); | 
| 282 | pgraph->fifo_access(dev, false); | 282 | if (pgraph->channel(dev) == chan) | 
| 283 | pgraph->unload_context(dev); | 283 | pgraph->unload_context(dev); | 
| 284 | pgraph->fifo_access(dev, true); | ||
| 285 | } | ||
| 286 | pgraph->destroy_context(chan); | 284 | pgraph->destroy_context(chan); | 
| 285 | pgraph->fifo_access(dev, true); | ||
| 287 | 286 | ||
| 288 | if (pfifo->channel_id(dev) == chan->id) { | 287 | if (pfifo->channel_id(dev) == chan->id) { | 
| 289 | pfifo->disable(dev); | 288 | pfifo->disable(dev); | 
| diff --git a/drivers/gpu/drm/nouveau/nv50_graph.c b/drivers/gpu/drm/nouveau/nv50_graph.c index 20319e59d368..6d504801b514 100644 --- a/drivers/gpu/drm/nouveau/nv50_graph.c +++ b/drivers/gpu/drm/nouveau/nv50_graph.c | |||
| @@ -165,6 +165,12 @@ nv50_graph_channel(struct drm_device *dev) | |||
| 165 | uint32_t inst; | 165 | uint32_t inst; | 
| 166 | int i; | 166 | int i; | 
| 167 | 167 | ||
| 168 | /* Be sure we're not in the middle of a context switch or bad things | ||
| 169 | * will happen, such as unloading the wrong pgraph context. | ||
| 170 | */ | ||
| 171 | if (!nv_wait(0x400300, 0x00000001, 0x00000000)) | ||
| 172 | NV_ERROR(dev, "Ctxprog is still running\n"); | ||
| 173 | |||
| 168 | inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_CUR); | 174 | inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_CUR); | 
| 169 | if (!(inst & NV50_PGRAPH_CTXCTL_CUR_LOADED)) | 175 | if (!(inst & NV50_PGRAPH_CTXCTL_CUR_LOADED)) | 
| 170 | return NULL; | 176 | return NULL; | 
| @@ -275,7 +281,7 @@ nv50_graph_load_context(struct nouveau_channel *chan) | |||
| 275 | int | 281 | int | 
| 276 | nv50_graph_unload_context(struct drm_device *dev) | 282 | nv50_graph_unload_context(struct drm_device *dev) | 
| 277 | { | 283 | { | 
| 278 | uint32_t inst, fifo = nv_rd32(dev, 0x400500); | 284 | uint32_t inst; | 
| 279 | 285 | ||
| 280 | inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_CUR); | 286 | inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_CUR); | 
| 281 | if (!(inst & NV50_PGRAPH_CTXCTL_CUR_LOADED)) | 287 | if (!(inst & NV50_PGRAPH_CTXCTL_CUR_LOADED)) | 
| @@ -283,12 +289,10 @@ nv50_graph_unload_context(struct drm_device *dev) | |||
| 283 | inst &= NV50_PGRAPH_CTXCTL_CUR_INSTANCE; | 289 | inst &= NV50_PGRAPH_CTXCTL_CUR_INSTANCE; | 
| 284 | 290 | ||
| 285 | nouveau_wait_for_idle(dev); | 291 | nouveau_wait_for_idle(dev); | 
| 286 | nv_wr32(dev, 0x400500, fifo & ~1); | ||
| 287 | nv_wr32(dev, 0x400784, inst); | 292 | nv_wr32(dev, 0x400784, inst); | 
| 288 | nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) | 0x20); | 293 | nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) | 0x20); | 
| 289 | nv_wr32(dev, 0x400304, nv_rd32(dev, 0x400304) | 0x01); | 294 | nv_wr32(dev, 0x400304, nv_rd32(dev, 0x400304) | 0x01); | 
| 290 | nouveau_wait_for_idle(dev); | 295 | nouveau_wait_for_idle(dev); | 
| 291 | nv_wr32(dev, 0x400500, fifo); | ||
| 292 | 296 | ||
| 293 | nv_wr32(dev, NV50_PGRAPH_CTXCTL_CUR, inst); | 297 | nv_wr32(dev, NV50_PGRAPH_CTXCTL_CUR, inst); | 
| 294 | return 0; | 298 | return 0; | 
