drm/nouveau/nvdec: 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:27 +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/engine/nvdec.h
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/base.c
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/gp102.c
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/priv.h
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gp102.c

index b941fbf465d1fef6b01141227317ecb52b586a9b..ae3c294a63d5908a105b75549c3564721fe5fd6c 100644 (file)
@@ -3,13 +3,12 @@
 #define __NVKM_NVDEC_H__
 #define nvkm_nvdec(p) container_of((p), struct nvkm_nvdec, engine)
 #include <core/engine.h>
+#include <core/falcon.h>
 
 struct nvkm_nvdec {
        const struct nvkm_nvdec_func *func;
        struct nvkm_engine engine;
-       u32 addr;
-
-       struct nvkm_falcon *falcon;
+       struct nvkm_falcon falcon;
 };
 
 int gp102_nvdec_new(struct nvkm_device *, int, struct nvkm_nvdec **);
index ae7a7616113a4874b97d521c4410c9525ab6b6b7..9b23c1b70ebfe07c9820e9976045b435b2cf33d8 100644 (file)
  * DEALINGS IN THE SOFTWARE.
  */
 #include "priv.h"
-
 #include <core/firmware.h>
-#include <subdev/top.h>
-#include <engine/falcon.h>
-
-static int
-nvkm_nvdec_oneinit(struct nvkm_engine *engine)
-{
-       struct nvkm_nvdec *nvdec = nvkm_nvdec(engine);
-       struct nvkm_subdev *subdev = &nvdec->engine.subdev;
-
-       nvdec->addr = nvkm_top_addr(subdev->device, subdev->index);
-       if (!nvdec->addr)
-               return -EINVAL;
-
-       /*XXX: fix naming of this when adding support for multiple-NVDEC */
-       return nvkm_falcon_v1_new(subdev, "NVDEC", nvdec->addr,
-                                 &nvdec->falcon);
-}
 
 static void *
 nvkm_nvdec_dtor(struct nvkm_engine *engine)
 {
        struct nvkm_nvdec *nvdec = nvkm_nvdec(engine);
-       nvkm_falcon_del(&nvdec->falcon);
+       nvkm_falcon_dtor(&nvdec->falcon);
        return nvdec;
 }
 
 static const struct nvkm_engine_func
 nvkm_nvdec = {
        .dtor = nvkm_nvdec_dtor,
-       .oneinit = nvkm_nvdec_oneinit,
 };
 
 int
@@ -74,5 +55,7 @@ nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *device,
                return -ENODEV;
 
        nvdec->func = fwif->func;
-       return 0;
+
+       return nvkm_falcon_ctor(nvdec->func->flcn, &nvdec->engine.subdev,
+                               nvkm_subdev_name[index], 0, &nvdec->falcon);
 };
index f2cc69c424b1abc287b52c02b874fab662899fb9..bd520c77b206dccda07b004c25b7382170189774 100644 (file)
  */
 #include "priv.h"
 
+static const struct nvkm_falcon_func
+gp102_nvdec_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 const struct nvkm_nvdec_func
 gp102_nvdec = {
+       .flcn = &gp102_nvdec_flcn,
 };
 
 static int
index c23c1f48c967e2bbadb44f10cc8971c654932b1a..e14da8b000d02f815b6356756b982b1a06d4e4fd 100644 (file)
@@ -4,6 +4,7 @@
 #include <engine/nvdec.h>
 
 struct nvkm_nvdec_func {
+       const struct nvkm_falcon_func *flcn;
 };
 
 struct nvkm_nvdec_fwif {
index b378a50e151a4e03493fa056628ddd4639d3fc10..5f4357de54be7528b87a08d6a1328b5c5abb713d 100644 (file)
@@ -62,7 +62,7 @@ gp102_run_secure_scrub(struct nvkm_secboot *sb)
        engine = nvkm_engine_ref(&device->nvdec[0]->engine);
        if (IS_ERR(engine))
                return PTR_ERR(engine);
-       falcon = device->nvdec[0]->falcon;
+       falcon = &device->nvdec[0]->falcon;
 
        nvkm_falcon_get(falcon, &sb->subdev);