OSDN Git Service

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 b941fbf..ae3c294 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 ae7a761..9b23c1b 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 f2cc69c..bd520c7 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 c23c1f4..e14da8b 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 b378a50..5f4357d 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);