drm/nouveau/gsp: initialise SW state for falcon from constructor
authorBen Skeggs <bskeggs@redhat.com>
Tue, 14 Jan 2020 20:34:21 +0000 (06:34 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 15 Jan 2020 00:50:26 +0000 (10:50 +1000)
This will allow us to register the falcon with ACR, and further customise
its behaviour by providing the nvkm_falcon_func structure directly.

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

index 4c672a5..06db676 100644 (file)
@@ -2,12 +2,11 @@
 #define __NVKM_GSP_H__
 #define nvkm_gsp(p) container_of((p), struct nvkm_gsp, subdev)
 #include <core/subdev.h>
+#include <core/falcon.h>
 
 struct nvkm_gsp {
        struct nvkm_subdev subdev;
-       u32 addr;
-
-       struct nvkm_falcon *falcon;
+       struct nvkm_falcon falcon;
 };
 
 int gv100_gsp_new(struct nvkm_device *, int, struct nvkm_gsp **);
index 872280d..5a32df0 100644 (file)
 #include <subdev/acr.h>
 #include <subdev/top.h>
 
-static int
-nvkm_gsp_oneinit(struct nvkm_subdev *subdev)
-{
-       struct nvkm_gsp *gsp = nvkm_gsp(subdev);
-
-       gsp->addr = nvkm_top_addr(subdev->device, subdev->index);
-       if (!gsp->addr)
-               return -EINVAL;
-
-       return nvkm_falcon_v1_new(subdev, "GSP", gsp->addr, &gsp->falcon);
-}
-
 static void *
 nvkm_gsp_dtor(struct nvkm_subdev *subdev)
 {
        struct nvkm_gsp *gsp = nvkm_gsp(subdev);
-       nvkm_falcon_del(&gsp->falcon);
+       nvkm_falcon_dtor(&gsp->falcon);
        return gsp;
 }
 
 static const struct nvkm_subdev_func
 nvkm_gsp = {
        .dtor = nvkm_gsp_dtor,
-       .oneinit = nvkm_gsp_oneinit,
 };
 
 int
@@ -66,5 +53,7 @@ nvkm_gsp_new_(const struct nvkm_gsp_fwif *fwif, struct nvkm_device *device,
        if (IS_ERR(fwif))
                return PTR_ERR(fwif);
 
-       return 0;
+       return nvkm_falcon_ctor(fwif->flcn, &gsp->subdev,
+                               nvkm_subdev_name[gsp->subdev.index], 0,
+                               &gsp->falcon);
 }
index 61188c1..e935c1b 100644 (file)
  */
 #include "priv.h"
 
+static const struct nvkm_falcon_func
+gv100_gsp_flcn = {
+       .load_imem = nvkm_falcon_v1_load_imem,
+       .load_dmem = nvkm_falcon_v1_load_dmem,
+       .read_dmem = nvkm_falcon_v1_read_dmem,
+       .bind_context = nvkm_falcon_v1_bind_context,
+       .wait_for_halt = nvkm_falcon_v1_wait_for_halt,
+       .clear_interrupt = nvkm_falcon_v1_clear_interrupt,
+       .set_start_addr = nvkm_falcon_v1_set_start_addr,
+       .start = nvkm_falcon_v1_start,
+       .enable = nvkm_falcon_v1_enable,
+       .disable = nvkm_falcon_v1_disable,
+};
+
 static int
 gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)
 {
@@ -29,7 +43,7 @@ gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)
 
 struct nvkm_gsp_fwif
 gv100_gsp[] = {
-       { -1, gv100_gsp_nofw },
+       { -1, gv100_gsp_nofw, &gv100_gsp_flcn },
        {}
 };
 
index 3200209..92820fb 100644 (file)
@@ -7,6 +7,7 @@ enum nvkm_acr_lsf_id;
 struct nvkm_gsp_fwif {
        int version;
        int (*load)(struct nvkm_gsp *, int ver, const struct nvkm_gsp_fwif *);
+       const struct nvkm_falcon_func *flcn;
 };
 
 int nvkm_gsp_new_(const struct nvkm_gsp_fwif *, struct nvkm_device *, int,