drm/nouveau/fault: store get/put pri address in nvkm_fault_buffer
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:46 +0000 (15:37 +1000)
Will allow more shared fault buffer handling code between Pascal/Volta.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/fault/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/fault/gp100.c
drivers/gpu/drm/nouveau/nvkm/subdev/fault/gv100.c
drivers/gpu/drm/nouveau/nvkm/subdev/fault/priv.h

index 494a4a4265b3563fb0c0ef6b1992ba771e304d3f..75587cafa0cedb85c0efd1a00b5ff421f98229c1 100644 (file)
@@ -96,7 +96,7 @@ nvkm_fault_oneinit_buffer(struct nvkm_fault *fault, int id)
                return -ENOMEM;
        buffer->fault = fault;
        buffer->id = id;
-       buffer->entries = fault->func->buffer.entries(buffer);
+       fault->func->buffer.info(buffer);
        fault->buffer[id] = buffer;
 
        nvkm_debug(subdev, "buffer %d: %d entries\n", id, buffer->entries);
index 65822652dca51a9cfaf86827c9feefd4c2e0b694..67d587a50f147086b2de6b623eef209fb64c174e 100644 (file)
@@ -37,10 +37,12 @@ gp100_fault_buffer_init(struct nvkm_fault_buffer *buffer)
        nvkm_mask(device, 0x002a70, 0x00000001, 0x00000001);
 }
 
-static u32
-gp100_fault_buffer_entries(struct nvkm_fault_buffer *buffer)
+static void
+gp100_fault_buffer_info(struct nvkm_fault_buffer *buffer)
 {
-       return nvkm_rd32(buffer->fault->subdev.device, 0x002a78);
+       buffer->entries = nvkm_rd32(buffer->fault->subdev.device, 0x002a78);
+       buffer->get = 0x002a7c;
+       buffer->put = 0x002a80;
 }
 
 static void
@@ -54,7 +56,7 @@ gp100_fault = {
        .intr = gp100_fault_intr,
        .buffer.nr = 1,
        .buffer.entry_size = 32,
-       .buffer.entries = gp100_fault_buffer_entries,
+       .buffer.info = gp100_fault_buffer_info,
        .buffer.init = gp100_fault_buffer_init,
        .buffer.fini = gp100_fault_buffer_fini,
 };
index f836fcef8b72c74d8a5b7a828ad7ee3f7c48f3ed..c5f735cf8eb36ead406fb33efad248c6c1058971 100644 (file)
@@ -30,9 +30,8 @@ gv100_fault_buffer_process(struct nvkm_fault_buffer *buffer)
 {
        struct nvkm_device *device = buffer->fault->subdev.device;
        struct nvkm_memory *mem = buffer->mem;
-       const u32 foff = buffer->id * 0x14;
-       u32 get = nvkm_rd32(device, 0x100e2c + foff);
-       u32 put = nvkm_rd32(device, 0x100e30 + foff);
+       u32 get = nvkm_rd32(device, buffer->get);
+       u32 put = nvkm_rd32(device, buffer->put);
        if (put == get)
                return;
 
@@ -51,7 +50,7 @@ gv100_fault_buffer_process(struct nvkm_fault_buffer *buffer)
 
                if (++get == buffer->entries)
                        get = 0;
-               nvkm_wr32(device, 0x100e2c + foff, get);
+               nvkm_wr32(device, buffer->get, get);
 
                info.addr   = ((u64)addrhi << 32) | addrlo;
                info.inst   = ((u64)insthi << 32) | instlo;
@@ -94,13 +93,17 @@ gv100_fault_buffer_init(struct nvkm_fault_buffer *buffer)
        nvkm_mask(device, 0x100a2c, intr, intr);
 }
 
-static u32
-gv100_fault_buffer_entries(struct nvkm_fault_buffer *buffer)
+static void
+gv100_fault_buffer_info(struct nvkm_fault_buffer *buffer)
 {
        struct nvkm_device *device = buffer->fault->subdev.device;
        const u32 foff = buffer->id * 0x14;
+
        nvkm_mask(device, 0x100e34 + foff, 0x40000000, 0x40000000);
-       return nvkm_rd32(device, 0x100e34 + foff) & 0x000fffff;
+
+       buffer->entries = nvkm_rd32(device, 0x100e34 + foff) & 0x000fffff;
+       buffer->get = 0x100e2c + foff;
+       buffer->put = 0x100e30 + foff;
 }
 
 static int
@@ -192,7 +195,7 @@ gv100_fault = {
        .intr = gv100_fault_intr,
        .buffer.nr = 2,
        .buffer.entry_size = 32,
-       .buffer.entries = gv100_fault_buffer_entries,
+       .buffer.info = gv100_fault_buffer_info,
        .buffer.init = gv100_fault_buffer_init,
        .buffer.fini = gv100_fault_buffer_fini,
 };
index 6439bc591cc716de9e6ba347434c7d09df443c37..b9a30a6f6aafb390c050fbaa18f95b2a1a5012e1 100644 (file)
@@ -12,6 +12,8 @@ struct nvkm_fault_buffer {
        struct nvkm_fault *fault;
        int id;
        int entries;
+       u32 get;
+       u32 put;
        struct nvkm_memory *mem;
        u64 addr;
 };
@@ -27,7 +29,7 @@ struct nvkm_fault_func {
        struct {
                int nr;
                u32 entry_size;
-               u32 (*entries)(struct nvkm_fault_buffer *);
+               void (*info)(struct nvkm_fault_buffer *);
                void (*init)(struct nvkm_fault_buffer *);
                void (*fini)(struct nvkm_fault_buffer *);
        } buffer;