drm/nouveau: fence: fail to emit when fence context is killed
authorDanilo Krummrich <dakr@redhat.com>
Fri, 4 Aug 2023 18:23:48 +0000 (20:23 +0200)
committerDanilo Krummrich <dakr@redhat.com>
Fri, 4 Aug 2023 18:34:37 +0000 (20:34 +0200)
The new VM_BIND UAPI implementation introduced in subsequent commits
will allow asynchronous jobs processing push buffers and emitting
fences.

If a fence context is killed, e.g. due to a channel fault, jobs which
are already queued for execution might still emit new fences. In such a
case a job would hang forever.

To fix that, fail to emit a new fence on a killed fence context with
-ENODEV to unblock the job.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230804182406.5222-9-dakr@redhat.com
drivers/gpu/drm/nouveau/nouveau_fence.c
drivers/gpu/drm/nouveau/nouveau_fence.h

index e946408..77c739a 100644 (file)
@@ -96,6 +96,7 @@ nouveau_fence_context_kill(struct nouveau_fence_chan *fctx, int error)
                if (nouveau_fence_signal(fence))
                        nvif_event_block(&fctx->event);
        }
+       fctx->killed = 1;
        spin_unlock_irqrestore(&fctx->lock, flags);
 }
 
@@ -229,6 +230,12 @@ nouveau_fence_emit(struct nouveau_fence *fence, struct nouveau_channel *chan)
                dma_fence_get(&fence->base);
                spin_lock_irq(&fctx->lock);
 
+               if (unlikely(fctx->killed)) {
+                       spin_unlock_irq(&fctx->lock);
+                       dma_fence_put(&fence->base);
+                       return -ENODEV;
+               }
+
                if (nouveau_fence_update(chan, fctx))
                        nvif_event_block(&fctx->event);
 
index 7c73c7c..2c72d96 100644 (file)
@@ -44,7 +44,7 @@ struct nouveau_fence_chan {
        char name[32];
 
        struct nvif_event event;
-       int notify_ref, dead;
+       int notify_ref, dead, killed;
 };
 
 struct nouveau_fence_priv {