drm/nouveau: chan: provide nouveau_channel_kill()
[linux-2.6-microblaze.git] / drivers / gpu / drm / nouveau / nouveau_chan.c
index f69be4c..1fd5ccf 100644 (file)
@@ -40,6 +40,14 @@ MODULE_PARM_DESC(vram_pushbuf, "Create DMA push buffers in VRAM");
 int nouveau_vram_pushbuf;
 module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
 
+void
+nouveau_channel_kill(struct nouveau_channel *chan)
+{
+       atomic_set(&chan->killed, 1);
+       if (chan->fence)
+               nouveau_fence_context_kill(chan->fence, -ENODEV);
+}
+
 static int
 nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc)
 {
@@ -47,9 +55,9 @@ nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc)
        struct nouveau_cli *cli = (void *)chan->user.client;
 
        NV_PRINTK(warn, cli, "channel %d killed!\n", chan->chid);
-       atomic_set(&chan->killed, 1);
-       if (chan->fence)
-               nouveau_fence_context_kill(chan->fence, -ENODEV);
+
+       if (unlikely(!atomic_read(&chan->killed)))
+               nouveau_channel_kill(chan);
 
        return NVIF_EVENT_DROP;
 }