drm/nouveau/fault/tu104: initial support
authorBen Skeggs <bskeggs@redhat.com>
Tue, 11 Dec 2018 04:50:02 +0000 (14:50 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 11 Dec 2018 05:37:54 +0000 (15:37 +1000)
New registers.

Currently uncertain how exactly to mask fault buffer interrupts.  This will
likely be corrected at around the same time as the new MC interrupt stuff
has been properly figured out and implemented.

For the moment, it shouldn't matter too much.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/subdev/fault.h
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/fault/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/fault/gv100.c
drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h
drivers/gpu/drm/nouveau/nvkm/subdev/fault/tu104.c [new file with mode: 0644]

index 5a77498fe6a09a304c1d63cf297cc3977c9bf5ac..127f48066026eaa55dea0c3d7cb666b9767ed17a 100644 (file)
@@ -30,4 +30,5 @@ struct nvkm_fault_data {
 
 int gp100_fault_new(struct nvkm_device *, int, struct nvkm_fault **);
 int gv100_fault_new(struct nvkm_device *, int, struct nvkm_fault **);
+int tu104_fault_new(struct nvkm_device *, int, struct nvkm_fault **);
 #endif
index eb14584fb3861da028554d73de451d20637ffcab..eea40d1071abeb45fc0cc289860371da26199220 100644 (file)
@@ -2441,6 +2441,7 @@ nv164_chipset = {
        .bios = nvkm_bios_new,
        .bus = gf100_bus_new,
        .devinit = tu104_devinit_new,
+       .fault = tu104_fault_new,
        .fb = gv100_fb_new,
        .fuse = gm107_fuse_new,
        .gpio = gk104_gpio_new,
index 45bb46fb0929a4638cb354eca51038817f7797ab..794eb1745b2fcc808aaaf035b0c8f0715936eb5e 100644 (file)
@@ -1,3 +1,4 @@
 nvkm-y += nvkm/subdev/fault/base.o
 nvkm-y += nvkm/subdev/fault/gp100.o
 nvkm-y += nvkm/subdev/fault/gv100.o
+nvkm-y += nvkm/subdev/fault/tu104.o
index 5de916fc5ccddd23c3bc7fe95685e3218feedb4a..6fc54e17c9354d17f0dba41f2915b0bd72f70728 100644 (file)
@@ -188,7 +188,7 @@ gv100_fault_init(struct nvkm_fault *fault)
        nvkm_notify_get(&fault->nrpfb);
 }
 
-static int
+int
 gv100_fault_oneinit(struct nvkm_fault *fault)
 {
        return nvkm_notify_init(&fault->buffer[0]->object, &fault->event,
index ec085dcb5c5c6c89693707d20db7041ab8f65fa0..8ca8b2876dadf30b1b6eb16c2b1acdff8b091624 100644 (file)
@@ -35,4 +35,6 @@ struct nvkm_fault_func {
                void (*intr)(struct nvkm_fault_buffer *, bool enable);
        } buffer;
 };
+
+int gv100_fault_oneinit(struct nvkm_fault *);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fault/tu104.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fault/tu104.c
new file mode 100644 (file)
index 0000000..9c8a3ad
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2018 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include "priv.h"
+
+#include <core/memory.h>
+#include <subdev/mmu.h>
+#include <engine/fifo.h>
+
+#include <nvif/class.h>
+
+static void
+tu104_fault_buffer_intr(struct nvkm_fault_buffer *buffer, bool enable)
+{
+       /*XXX: Earlier versions of RM touched the old regs on Turing,
+        *     which don't appear to actually work anymore, but newer
+        *     versions of RM don't appear to touch anything at all..
+        */
+}
+
+static void
+tu104_fault_buffer_fini(struct nvkm_fault_buffer *buffer)
+{
+       struct nvkm_device *device = buffer->fault->subdev.device;
+       const u32 foff = buffer->id * 0x20;
+       nvkm_mask(device, 0xb83010 + foff, 0x80000000, 0x00000000);
+}
+
+static void
+tu104_fault_buffer_init(struct nvkm_fault_buffer *buffer)
+{
+       struct nvkm_device *device = buffer->fault->subdev.device;
+       const u32 foff = buffer->id * 0x20;
+
+       nvkm_mask(device, 0xb83010 + foff, 0xc0000000, 0x40000000);
+       nvkm_wr32(device, 0xb83004 + foff, upper_32_bits(buffer->addr));
+       nvkm_wr32(device, 0xb83000 + foff, lower_32_bits(buffer->addr));
+       nvkm_mask(device, 0xb83010 + foff, 0x80000000, 0x80000000);
+}
+
+static void
+tu104_fault_buffer_info(struct nvkm_fault_buffer *buffer)
+{
+       struct nvkm_device *device = buffer->fault->subdev.device;
+       const u32 foff = buffer->id * 0x20;
+
+       nvkm_mask(device, 0xb83010 + foff, 0x40000000, 0x40000000);
+
+       buffer->entries = nvkm_rd32(device, 0xb83010 + foff) & 0x000fffff;
+       buffer->get = 0xb83008 + foff;
+       buffer->put = 0xb8300c + foff;
+}
+
+static void
+tu104_fault_intr_fault(struct nvkm_fault *fault)
+{
+       struct nvkm_subdev *subdev = &fault->subdev;
+       struct nvkm_device *device = subdev->device;
+       struct nvkm_fault_data info;
+       const u32 addrlo = nvkm_rd32(device, 0xb83080);
+       const u32 addrhi = nvkm_rd32(device, 0xb83084);
+       const u32  info0 = nvkm_rd32(device, 0xb83088);
+       const u32 insthi = nvkm_rd32(device, 0xb8308c);
+       const u32  info1 = nvkm_rd32(device, 0xb83090);
+
+       info.addr = ((u64)addrhi << 32) | addrlo;
+       info.inst = ((u64)insthi << 32) | (info0 & 0xfffff000);
+       info.time = 0;
+       info.engine = (info0 & 0x000000ff);
+       info.valid  = (info1 & 0x80000000) >> 31;
+       info.gpc    = (info1 & 0x1f000000) >> 24;
+       info.hub    = (info1 & 0x00100000) >> 20;
+       info.access = (info1 & 0x000f0000) >> 16;
+       info.client = (info1 & 0x00007f00) >> 8;
+       info.reason = (info1 & 0x0000001f);
+
+       nvkm_fifo_fault(device->fifo, &info);
+}
+
+static void
+tu104_fault_intr(struct nvkm_fault *fault)
+{
+       struct nvkm_subdev *subdev = &fault->subdev;
+       struct nvkm_device *device = subdev->device;
+       u32 stat = nvkm_rd32(device, 0xb83094);
+
+       if (stat & 0x80000000) {
+               tu104_fault_intr_fault(fault);
+               nvkm_wr32(device, 0xb83094, 0x80000000);
+               stat &= ~0x80000000;
+       }
+
+       if (stat & 0x00000200) {
+               if (fault->buffer[0]) {
+                       nvkm_event_send(&fault->event, 1, 0, NULL, 0);
+                       stat &= ~0x00000200;
+               }
+       }
+
+       /*XXX: guess, can't confirm until we get fw... */
+       if (stat & 0x00000100) {
+               if (fault->buffer[1]) {
+                       nvkm_event_send(&fault->event, 1, 1, NULL, 0);
+                       stat &= ~0x00000100;
+               }
+       }
+
+       if (stat) {
+               nvkm_debug(subdev, "intr %08x\n", stat);
+       }
+}
+
+static void
+tu104_fault_fini(struct nvkm_fault *fault)
+{
+       nvkm_notify_put(&fault->nrpfb);
+       if (fault->buffer[0])
+               fault->func->buffer.fini(fault->buffer[0]);
+       /*XXX: disable priv faults */
+}
+
+static void
+tu104_fault_init(struct nvkm_fault *fault)
+{
+       /*XXX: enable priv faults */
+       fault->func->buffer.init(fault->buffer[0]);
+       nvkm_notify_get(&fault->nrpfb);
+}
+
+static const struct nvkm_fault_func
+tu104_fault = {
+       .oneinit = gv100_fault_oneinit,
+       .init = tu104_fault_init,
+       .fini = tu104_fault_fini,
+       .intr = tu104_fault_intr,
+       .buffer.nr = 2,
+       .buffer.entry_size = 32,
+       .buffer.info = tu104_fault_buffer_info,
+       .buffer.init = tu104_fault_buffer_init,
+       .buffer.fini = tu104_fault_buffer_fini,
+       .buffer.intr = tu104_fault_buffer_intr,
+};
+
+int
+tu104_fault_new(struct nvkm_device *device, int index,
+               struct nvkm_fault **pfault)
+{
+       return nvkm_fault_new_(&tu104_fault, device, index, pfault);
+}