drm/nouveau/fifo/gf100-: protect channel preempt with subdev mutex
authorBen Skeggs <bskeggs@redhat.com>
Sat, 5 Nov 2016 04:33:14 +0000 (14:33 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Mon, 7 Nov 2016 04:05:13 +0000 (14:05 +1000)
This avoids an issue that occurs when we're attempting to preempt multiple
channels simultaneously.  HW seems to ignore preempt requests while it's
still processing a previous one, which, well, makes sense.

Fixes random "fifo: SCHED_ERROR 0d []" + GPCCS page faults during parallel
piglit runs on (at least) GM107.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c

index cbc67f2623223177d084395294facda07375e694..12d964260a29921ed71cb25b2a299824ac4442f2 100644 (file)
@@ -60,6 +60,7 @@ gf100_fifo_gpfifo_engine_fini(struct nvkm_fifo_chan *base,
        struct nvkm_gpuobj *inst = chan->base.inst;
        int ret = 0;
 
+       mutex_lock(&subdev->mutex);
        nvkm_wr32(device, 0x002634, chan->base.chid);
        if (nvkm_msec(device, 2000,
                if (nvkm_rd32(device, 0x002634) == chan->base.chid)
@@ -67,10 +68,12 @@ gf100_fifo_gpfifo_engine_fini(struct nvkm_fifo_chan *base,
        ) < 0) {
                nvkm_error(subdev, "channel %d [%s] kick timeout\n",
                           chan->base.chid, chan->base.object.client->name);
-               ret = -EBUSY;
-               if (suspend)
-                       return ret;
+               ret = -ETIMEDOUT;
        }
+       mutex_unlock(&subdev->mutex);
+
+       if (ret && suspend)
+               return ret;
 
        if (offset) {
                nvkm_kmap(inst);
index ed4351032ed603df4180a4113c114459c9e5a372..a2df4f3e7763494acf93acc5a46c2f15720b19d3 100644 (file)
@@ -40,7 +40,9 @@ gk104_fifo_gpfifo_kick(struct gk104_fifo_chan *chan)
        struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
        struct nvkm_device *device = subdev->device;
        struct nvkm_client *client = chan->base.object.client;
+       int ret = 0;
 
+       mutex_lock(&subdev->mutex);
        nvkm_wr32(device, 0x002634, chan->base.chid);
        if (nvkm_msec(device, 2000,
                if (!(nvkm_rd32(device, 0x002634) & 0x00100000))
@@ -48,10 +50,10 @@ gk104_fifo_gpfifo_kick(struct gk104_fifo_chan *chan)
        ) < 0) {
                nvkm_error(subdev, "channel %d [%s] kick timeout\n",
                           chan->base.chid, client->name);
-               return -EBUSY;
+               ret = -ETIMEDOUT;
        }
-
-       return 0;
+       mutex_unlock(&subdev->mutex);
+       return ret;
 }
 
 static u32