When an engine reports an MMU fault, recovery flags the faulting
channel group and nvkm_runl_rc() resets only the engines whose current
context (cxid) belongs to a flagged group. On Fermi the fault can be
reported after GR has started switching to another channel: the engine
status then reads e.g. 0x01140003 (not busy, chid 3) while channel 4
faulted, so GR is not reset, stays stalled on the fault, and the
runlist update never completes:
fifo: fault 01 [WRITE] at 0 engine 00 [PGRAPH] client 0f [GPC0/PROP] reason
02 [PAGE_NOT_PRESENT] on channel 4
object-namespac[1768]: channel 4 killed!
fifo:000000:00[ gr]: 01140003: busy 0 save 1 unk0 0 unk1 0 chid 3
fifo:000000:00[ gr]: cxid not valid
WARNING: drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv50.c:228 at
nv50_runl_wait+0xe8/0x100 [nouveau]
fifo: SCHED_ERROR 0d []
WARNING: drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.c:251 at
nvkm_runl_preempt_wait+0xf7/0x110 [nouveau]
After that no channel makes progress: the whole GPU is dead until a
reboot, and processes using it hang in D state.
Remember which engine reported the fault, and reset it during recovery
regardless of what its status says. Resetting GR may discard the context
being switched in, but that is far better than losing the GPU.
Tested on a Quadro 600 (GF108): a program that faults (piglit
"object-namespace-pollution glClearTexSubImage texture") while three
other processes keep GR busy hangs the GPU within one to three faults
without this patch. With it, 20 of 20 faults recovered (15 of them hit
the state above), with no runlist timeouts, and the GPU kept working.
On an NVS 315 (GF119) the same test hangs the GPU at the first fault
without this patch; with it, 20 of 20 rounds completed, every fault was
recovered, and the GPU kept working.
Written with help from Claude (Anthropic); reviewed and tested on hardware.
Fixes: 4d60100a23ec ("drm/nouveau/fifo: add common channel recovery")
Cc: [email protected]
Signed-off-by: Frédéric Mahé <[email protected]>
---
Tested on GF108 and GF119 only. gf100_fifo_mmu_fault_recover() is also used by
gk104, gm107, gv100 and tu102 (non-GSP), so the change applies to those
too; feedback from such hardware is welcome.
A small libdrm program reproduces this without Mesa or piglit
(nv-mmu-fault.c, available on request):
nv-mmu-fault -e noctx
sends one graphics method on a channel that has no graphics object.
PGRAPH's context-switch unit then faults (READ at 0, HUB/CTXCTL)
while the engine status no longer names the channel. On an NVS 315
(GF119), without this patch the GPU is dead after the first run;
with it, 60 of 60 runs recovered. "nv-mmu-fault -e gr" in a loop
with three processes keeping PGRAPH busy gives the WRITE fault of
the log above: dead at the 4th fault without the patch, 40 of 40
recovered with it.
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c | 11 +++++++++--
drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.c | 11 ++++++++---
drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.h | 1 +
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
index e4a4fad..4f221c0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
@@ -597,9 +597,16 @@ gf100_fifo_mmu_fault_recover(struct nvkm_fifo *fifo,
struct nvkm_fault_data *inf
info->reason, er ? er->name : "",
chan ? chan->id : -1, info->inst, chan ? chan->name :
"unknown");
- /* Handle host/engine faults. */
- if (chan)
+ /* Handle host/engine faults. The engine that reported the fault must
+ * be reset even if it has already switched to another channel (its
+ * status then no longer points at the faulting channel), otherwise it
+ * stays stalled and the runlist update never completes.
+ */
+ if (chan) {
+ if (engine)
+ atomic_set(&engn->rc_reset, 1);
nvkm_runl_rc_cgrp(chan->cgrp);
+ }
nvkm_chan_put(&chan, flags);
}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.c
b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.c
index 2092521..76fabe8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.c
@@ -99,14 +99,19 @@ nvkm_runl_rc(struct nvkm_runl *runl)
/* Look for engines that are still on flagged channel groups - reset
them. */
nvkm_runl_foreach_engn_cond(engn, runl, engn->func->cxid) {
+ bool faulted = atomic_xchg(&engn->rc_reset, 0);
+
cgrp = nvkm_engn_cgrp_get(engn, &flags);
- if (!cgrp) {
+ if (!cgrp && !faulted) {
ENGN_DEBUG(engn, "cxid not valid");
continue;
}
- reset = atomic_read(&cgrp->rc) == NVKM_CGRP_RC_RUNNING;
- nvkm_cgrp_put(&cgrp, flags);
+ reset = faulted;
+ if (cgrp) {
+ reset |= atomic_read(&cgrp->rc) == NVKM_CGRP_RC_RUNNING;
+ nvkm_cgrp_put(&cgrp, flags);
+ }
if (!reset) {
ENGN_DEBUG(engn, "cxid not in recovery");
continue;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.h
b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.h
index 19e6772..08ba44d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.h
@@ -28,6 +28,7 @@ struct nvkm_engn {
struct nvkm_engine *engine;
int fault;
+ atomic_t rc_reset; /* engine reported a fault: reset it during RC */
struct {
u32 desc;
--
2.53.0