drm/nouveau/fifo/gk104-: switch dev_top fault handling to type+inst
authorBen Skeggs <bskeggs@redhat.com>
Mon, 8 Feb 2021 01:23:56 +0000 (11:23 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 11 Feb 2021 01:49:57 +0000 (11:49 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/subdev/top.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/tu102.c
drivers/gpu/drm/nouveau/nvkm/subdev/top/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c

index ea82b5d..a642f5c 100644 (file)
@@ -12,7 +12,6 @@ struct nvkm_top {
 struct nvkm_top_device {
        enum nvkm_subdev_type type;
        int inst;
-       enum nvkm_devidx index;
        u32 addr;
        int fault;
        int engine;
@@ -26,7 +25,7 @@ u32 nvkm_top_addr(struct nvkm_device *, enum nvkm_subdev_type, int);
 u32 nvkm_top_reset(struct nvkm_device *, enum nvkm_subdev_type, int);
 u32 nvkm_top_intr_mask(struct nvkm_device *, enum nvkm_subdev_type, int);
 int nvkm_top_fault_id(struct nvkm_device *, enum nvkm_subdev_type, int);
-enum nvkm_devidx nvkm_top_fault(struct nvkm_device *, int fault);
+struct nvkm_subdev *nvkm_top_fault(struct nvkm_device *, int fault);
 
 int gk104_top_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_top **);
 #endif
index fc6603b..8266b9b 100644 (file)
@@ -483,7 +483,8 @@ gk104_fifo_fault(struct nvkm_fifo *base, struct nvkm_fault_data *info)
        struct nvkm_engine *engine = NULL;
        struct nvkm_fifo_chan *chan;
        unsigned long flags;
-       char ct[8] = "HUB/", en[16] = "";
+       const char *en = "";
+       char ct[8] = "HUB/";
 
        er = nvkm_enum_find(fifo->func->fault.reason, info->reason);
        ee = nvkm_enum_find(fifo->func->fault.engine, info->engine);
@@ -513,17 +514,14 @@ gk104_fifo_fault(struct nvkm_fifo *base, struct nvkm_fault_data *info)
        }
 
        if (ee == NULL) {
-               enum nvkm_devidx engidx = nvkm_top_fault(device, info->engine);
-               if (engidx < NVKM_SUBDEV_NR) {
-                       const char *src = nvkm_subdev_type[engidx];
-                       char *dst = en;
-                       do {
-                               *dst++ = toupper(*src++);
-                       } while(*src);
-                       engine = nvkm_device_engine(device, engidx, 0);
+               struct nvkm_subdev *subdev = nvkm_top_fault(device, info->engine);
+               if (subdev) {
+                       if (subdev->func == &nvkm_engine)
+                               engine = container_of(subdev, typeof(*engine), subdev);
+                       en = engine->subdev.name;
                }
        } else {
-               snprintf(en, sizeof(en), "%s", ee->name);
+               en = ee->name;
        }
 
        spin_lock_irqsave(&fifo->base.lock, flags);
index 1bc6b25..e417044 100644 (file)
@@ -278,7 +278,8 @@ tu102_fifo_fault(struct nvkm_fifo *base, struct nvkm_fault_data *info)
        struct nvkm_engine *engine = NULL;
        struct nvkm_fifo_chan *chan;
        unsigned long flags;
-       char ct[8] = "HUB/", en[16] = "";
+       const char *en = "";
+       char ct[8] = "HUB/";
        int engn;
 
        er = nvkm_enum_find(fifo->func->fault.reason, info->reason);
@@ -309,19 +310,14 @@ tu102_fifo_fault(struct nvkm_fifo *base, struct nvkm_fault_data *info)
        }
 
        if (ee == NULL) {
-               enum nvkm_devidx engidx = nvkm_top_fault(device, info->engine);
-
-               if (engidx < NVKM_SUBDEV_NR) {
-                       const char *src = nvkm_subdev_type[engidx];
-                       char *dst = en;
-
-                       do {
-                               *dst++ = toupper(*src++);
-                       } while (*src);
-                       engine = nvkm_device_engine(device, engidx, 0);
+               struct nvkm_subdev *subdev = nvkm_top_fault(device, info->engine);
+               if (subdev) {
+                       if (subdev->func == &nvkm_engine)
+                               engine = container_of(subdev, typeof(*engine), subdev);
+                       en = engine->subdev.name;
                }
        } else {
-               snprintf(en, sizeof(en), "%s", ee->name);
+               en = ee->name;
        }
 
        spin_lock_irqsave(&fifo->base.lock, flags);
index c340468..28d0789 100644 (file)
@@ -30,7 +30,6 @@ nvkm_top_device_new(struct nvkm_top *top)
        if (info) {
                info->type = NVKM_SUBDEV_NR;
                info->inst = -1;
-               info->index = NVKM_SUBDEV_NR;
                info->addr = 0;
                info->fault = -1;
                info->engine = -1;
@@ -104,7 +103,7 @@ nvkm_top_fault_id(struct nvkm_device *device, enum nvkm_subdev_type type, int in
        return -ENOENT;
 }
 
-enum nvkm_devidx
+struct nvkm_subdev *
 nvkm_top_fault(struct nvkm_device *device, int fault)
 {
        struct nvkm_top *top = device->top;
@@ -112,10 +111,10 @@ nvkm_top_fault(struct nvkm_device *device, int fault)
 
        list_for_each_entry(info, &top->device, head) {
                if (info->fault == fault)
-                       return info->index;
+                       return nvkm_device_subdev(device, info->type, info->inst);
        }
 
-       return NVKM_SUBDEV_NR;
+       return NULL;
 }
 
 static int
index 4bf0740..870f926 100644 (file)
@@ -70,7 +70,7 @@ gk104_top_oneinit(struct nvkm_top *top)
                        continue;
 
                /* Translate engine type to NVKM engine identifier. */
-#define I_(T,I) do { info->type = (T); info->inst = (I); info->index = (T) + (I); } while(0)
+#define I_(T,I) do { info->type = (T); info->inst = (I); } while(0)
 #define O_(T,I) do { WARN_ON(inst); I_(T, I); } while (0)
                switch (type) {
                case 0x00000000: O_(NVKM_ENGINE_GR    ,    0); break;