drm/nouveau/top: parse device topology right after devinit
authorBen Skeggs <bskeggs@redhat.com>
Wed, 1 Jun 2022 10:46:51 +0000 (20:46 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 9 Nov 2022 00:44:35 +0000 (10:44 +1000)
We're going to want this information available earlier than it is now.

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/device/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/top/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/top/ga100.c
drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.c
drivers/gpu/drm/nouveau/nvkm/subdev/top/priv.h

index ee75c5524c436888eae67e15bfe90350872c4151..73e717b980b85c2609edd5d9676b4398178c3b0d 100644 (file)
@@ -21,6 +21,7 @@ struct nvkm_top_device {
        struct list_head head;
 };
 
+int nvkm_top_parse(struct nvkm_device *);
 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);
index d8cf71fb0512813f14732bf5d142a17cb17cfe60..c45ff9df072734a05150749b23bc135590c7923a 100644 (file)
@@ -2775,6 +2775,10 @@ nvkm_device_preinit(struct nvkm_device *device)
        if (ret)
                goto fail;
 
+       ret = nvkm_top_parse(device);
+       if (ret)
+               goto fail;
+
        time = ktime_to_us(ktime_get()) - time;
        nvdev_trace(device, "preinit completed in %lldus\n", time);
        return 0;
index 28d0789f50fecca9059087eaba7dafcb1f1de6dc..eb348dfc1d7a26837a3ac184e651808131a5cc59 100644 (file)
@@ -117,11 +117,15 @@ nvkm_top_fault(struct nvkm_device *device, int fault)
        return NULL;
 }
 
-static int
-nvkm_top_oneinit(struct nvkm_subdev *subdev)
+int
+nvkm_top_parse(struct nvkm_device *device)
 {
-       struct nvkm_top *top = nvkm_top(subdev);
-       return top->func->oneinit(top);
+       struct nvkm_top *top = device->top;
+
+       if (!top || !list_empty(&top->device))
+               return 0;
+
+       return top->func->parse(top);
 }
 
 static void *
@@ -141,7 +145,6 @@ nvkm_top_dtor(struct nvkm_subdev *subdev)
 static const struct nvkm_subdev_func
 nvkm_top = {
        .dtor = nvkm_top_dtor,
-       .oneinit = nvkm_top_oneinit,
 };
 
 int
index c982d834c8d98579dd436eb632a6086c84f594d0..84790cf52b9029b97cc62da1e08d9f8ae1a96950 100644 (file)
@@ -22,7 +22,7 @@
 #include "priv.h"
 
 static int
-ga100_top_oneinit(struct nvkm_top *top)
+ga100_top_parse(struct nvkm_top *top)
 {
        struct nvkm_subdev *subdev = &top->subdev;
        struct nvkm_device *device = subdev->device;
@@ -97,7 +97,7 @@ ga100_top_oneinit(struct nvkm_top *top)
 
 static const struct nvkm_top_func
 ga100_top = {
-       .oneinit = ga100_top_oneinit,
+       .parse = ga100_top_parse,
 };
 
 int
index 4dcad97bd505bd12fb17b44026b5fe40906a4bd1..2bbba8244cbf14354007984206b39ac417cd7123 100644 (file)
@@ -24,7 +24,7 @@
 #include "priv.h"
 
 static int
-gk104_top_oneinit(struct nvkm_top *top)
+gk104_top_parse(struct nvkm_top *top)
 {
        struct nvkm_subdev *subdev = &top->subdev;
        struct nvkm_device *device = subdev->device;
@@ -108,7 +108,7 @@ gk104_top_oneinit(struct nvkm_top *top)
 
 static const struct nvkm_top_func
 gk104_top = {
-       .oneinit = gk104_top_oneinit,
+       .parse = gk104_top_parse,
 };
 
 int
index 8e103a83670591caeef823abeb33b970afe27511..532be91d8fd9088931edc1e13f54fdeb9b7100ff 100644 (file)
@@ -5,7 +5,7 @@
 #include <subdev/top.h>
 
 struct nvkm_top_func {
-       int (*oneinit)(struct nvkm_top *);
+       int (*parse)(struct nvkm_top *);
 };
 
 int nvkm_top_new_(const struct nvkm_top_func *, struct nvkm_device *, enum nvkm_subdev_type, int,