GV11B FECS acknowledges SET_WATCHDOG_TIMEOUT by writing 1 to mailbox 0.
Without a wait, the next method can read that response as the main
context size. Wait for the acknowledgement before querying context
sizes and propagate a timeout to the caller.

Signed-off-by: Mikko Perttunen <[email protected]>
---
 drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c | 15 +++++++++++++--
 drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
index c2a9dd9018b8..76f922e24284 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
@@ -969,7 +969,7 @@ gf100_gr_fecs_discover_image_size(struct gf100_gr *gr, u32 
*psize)
        return -ETIMEDOUT;
 }
 
-static void
+static int
 gf100_gr_fecs_set_watchdog_timeout(struct gf100_gr *gr, u32 timeout)
 {
        struct nvkm_device *device = gr->base.engine.subdev.device;
@@ -977,6 +977,15 @@ gf100_gr_fecs_set_watchdog_timeout(struct gf100_gr *gr, 
u32 timeout)
        nvkm_wr32(device, 0x409800, 0x00000000);
        nvkm_wr32(device, 0x409500, timeout);
        nvkm_wr32(device, 0x409504, 0x00000021);
+       if (!gr->func->fecs.watchdog_timeout_ack)
+               return 0;
+
+       nvkm_msec(device, 2000,
+               if (nvkm_rd32(device, 0x409800) == 0x00000001)
+                       return 0;
+       );
+
+       return -ETIMEDOUT;
 }
 
 static bool
@@ -1796,7 +1805,9 @@ gf100_gr_init_ctxctl_ext(struct gf100_gr *gr)
        ) < 0)
                return -EBUSY;
 
-       gf100_gr_fecs_set_watchdog_timeout(gr, 0x7fffffff);
+       ret = gf100_gr_fecs_set_watchdog_timeout(gr, 0x7fffffff);
+       if (ret)
+               return ret;
 
        /* Determine how much memory is required to store main context image. */
        ret = gf100_gr_fecs_discover_image_size(gr, &gr->size);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h 
b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
index 54f686ba39ac..351595966dd8 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
@@ -185,6 +185,7 @@ struct gf100_gr_func {
        struct {
                struct gf100_gr_ucode *ucode;
                void (*reset)(struct gf100_gr *);
+               bool watchdog_timeout_ack;
        } fecs;
        struct {
                struct gf100_gr_ucode *ucode;

-- 
2.56.1

Reply via email to