Skip to content

Commit f124eef

Browse files
committed
drm/nouveau: fence: fail to emit when fence context is killed
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 <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 7f2a0b5 commit f124eef

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/gpu/drm/nouveau/nouveau_fence.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ nouveau_fence_context_kill(struct nouveau_fence_chan *fctx, int error)
9696
if (nouveau_fence_signal(fence))
9797
nvif_event_block(&fctx->event);
9898
}
99+
fctx->killed = 1;
99100
spin_unlock_irqrestore(&fctx->lock, flags);
100101
}
101102

@@ -229,6 +230,12 @@ nouveau_fence_emit(struct nouveau_fence *fence, struct nouveau_channel *chan)
229230
dma_fence_get(&fence->base);
230231
spin_lock_irq(&fctx->lock);
231232

233+
if (unlikely(fctx->killed)) {
234+
spin_unlock_irq(&fctx->lock);
235+
dma_fence_put(&fence->base);
236+
return -ENODEV;
237+
}
238+
232239
if (nouveau_fence_update(chan, fctx))
233240
nvif_event_block(&fctx->event);
234241

drivers/gpu/drm/nouveau/nouveau_fence.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct nouveau_fence_chan {
4444
char name[32];
4545

4646
struct nvif_event event;
47-
int notify_ref, dead;
47+
int notify_ref, dead, killed;
4848
};
4949

5050
struct nouveau_fence_priv {

0 commit comments

Comments
 (0)