drm/nouveau/nvdec/tu102-: prepare for GSP-RM
authorBen Skeggs <bskeggs@redhat.com>
Mon, 18 Sep 2023 20:21:32 +0000 (06:21 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 31 Oct 2023 05:08:14 +0000 (15:08 +1000)
- (temporarily) disable if GSP-RM detected, will be added later
- provide empty class list for non-GSP paths
- split tu102- from gm107, they will provide host classes later
- fixup HW engine instance masks

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230918202149.4343-28-skeggsb@gmail.com
drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/base.c
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/ga102.c
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/gm107.c
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/priv.h
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/tu102.c [new file with mode: 0644]

index 9baf197ac8336f3a0b6c5d25125ce33981c24f0e..ca83caa55157da9d509a63a4657dea7d310c1158 100644 (file)
@@ -12,5 +12,6 @@ struct nvkm_nvdec {
 };
 
 int gm107_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
+int tu102_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
 int ga102_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
 #endif
index 395702870872bb11986925ce63383c752d412ca8..c0f1a8110452e8767ebf3b07a050494274c5185e 100644 (file)
@@ -2426,7 +2426,7 @@ nv162_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, tu102_fifo_new },
        .gr       = { 0x00000001, tu102_gr_new },
-       .nvdec    = { 0x00000001, gm107_nvdec_new },
+       .nvdec    = { 0x00000001, tu102_nvdec_new },
        .nvenc    = { 0x00000001, gm107_nvenc_new },
        .sec2     = { 0x00000001, tu102_sec2_new },
 };
@@ -2461,7 +2461,7 @@ nv164_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, tu102_fifo_new },
        .gr       = { 0x00000001, tu102_gr_new },
-       .nvdec    = { 0x00000003, gm107_nvdec_new },
+       .nvdec    = { 0x00000003, tu102_nvdec_new },
        .nvenc    = { 0x00000001, gm107_nvenc_new },
        .sec2     = { 0x00000001, tu102_sec2_new },
 };
@@ -2496,7 +2496,7 @@ nv166_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, tu102_fifo_new },
        .gr       = { 0x00000001, tu102_gr_new },
-       .nvdec    = { 0x00000007, gm107_nvdec_new },
+       .nvdec    = { 0x00000007, tu102_nvdec_new },
        .nvenc    = { 0x00000001, gm107_nvenc_new },
        .sec2     = { 0x00000001, tu102_sec2_new },
 };
@@ -2531,7 +2531,7 @@ nv167_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, tu102_fifo_new },
        .gr       = { 0x00000001, tu102_gr_new },
-       .nvdec    = { 0x00000001, gm107_nvdec_new },
+       .nvdec    = { 0x00000001, tu102_nvdec_new },
        .nvenc    = { 0x00000001, gm107_nvenc_new },
        .sec2     = { 0x00000001, tu102_sec2_new },
 };
@@ -2566,7 +2566,7 @@ nv168_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, tu102_fifo_new },
        .gr       = { 0x00000001, tu102_gr_new },
-       .nvdec    = { 0x00000001, gm107_nvdec_new },
+       .nvdec    = { 0x00000001, tu102_nvdec_new },
        .nvenc    = { 0x00000001, gm107_nvenc_new },
        .sec2     = { 0x00000001, tu102_sec2_new },
 };
@@ -2620,7 +2620,7 @@ nv172_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
        .gr       = { 0x00000001, ga102_gr_new },
-       .nvdec    = { 0x00000001, ga102_nvdec_new },
+       .nvdec    = { 0x00000003, ga102_nvdec_new },
        .sec2     = { 0x00000001, ga102_sec2_new },
 };
 
@@ -2650,7 +2650,7 @@ nv173_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
        .gr       = { 0x00000001, ga102_gr_new },
-       .nvdec    = { 0x00000001, ga102_nvdec_new },
+       .nvdec    = { 0x00000003, ga102_nvdec_new },
        .sec2     = { 0x00000001, ga102_sec2_new },
 };
 
@@ -2680,7 +2680,7 @@ nv174_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
        .gr       = { 0x00000001, ga102_gr_new },
-       .nvdec    = { 0x00000001, ga102_nvdec_new },
+       .nvdec    = { 0x00000003, ga102_nvdec_new },
        .sec2     = { 0x00000001, ga102_sec2_new },
 };
 
@@ -2710,7 +2710,7 @@ nv176_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
        .gr       = { 0x00000001, ga102_gr_new },
-       .nvdec    = { 0x00000001, ga102_nvdec_new },
+       .nvdec    = { 0x00000003, ga102_nvdec_new },
        .sec2     = { 0x00000001, ga102_sec2_new },
 };
 
@@ -2740,7 +2740,7 @@ nv177_chipset = {
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
        .gr       = { 0x00000001, ga102_gr_new },
-       .nvdec    = { 0x00000001, ga102_nvdec_new },
+       .nvdec    = { 0x00000003, ga102_nvdec_new },
        .sec2     = { 0x00000001, ga102_sec2_new },
 };
 
index f05e79670d22736647b3995b0065907bbfd0573a..37b0cdc760c763af44752a9c51c99bf9e8309aac 100644 (file)
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: MIT
 nvkm-y += nvkm/engine/nvdec/base.o
 nvkm-y += nvkm/engine/nvdec/gm107.o
+nvkm-y += nvkm/engine/nvdec/tu102.o
 nvkm-y += nvkm/engine/nvdec/ga102.o
index 1f6e3b32ba163cfc70c8e21acbb1cdb58c3d94e8..7d1c6791ae8265721177179521c5b0982bc71188 100644 (file)
@@ -33,6 +33,7 @@ nvkm_nvdec_dtor(struct nvkm_engine *engine)
 static const struct nvkm_engine_func
 nvkm_nvdec = {
        .dtor = nvkm_nvdec_dtor,
+       .sclass = { {} },
 };
 
 int
@@ -58,4 +59,4 @@ nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *device,
 
        return nvkm_falcon_ctor(nvdec->func->flcn, &nvdec->engine.subdev,
                                nvdec->engine.subdev.name, addr, &nvdec->falcon);
-};
+}
index 37d8c3c0f3abc08bb2f442d3c664bc624827dee8..1ec88a9b65047fd467667e6fd1163cc0a98c8971 100644 (file)
@@ -21,6 +21,7 @@
  */
 #include "priv.h"
 
+#include <subdev/gsp.h>
 #include <subdev/mc.h>
 #include <subdev/timer.h>
 
@@ -57,5 +58,8 @@ int
 ga102_nvdec_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
                struct nvkm_nvdec **pnvdec)
 {
+       if (nvkm_gsp_rm(device->gsp))
+               return -ENODEV;
+
        return nvkm_nvdec_new_(ga102_nvdec_fwif, device, type, inst, 0x848000, pnvdec);
 }
index 564f7e8960a2016d1af1cade0bbf16156c15f862..51c9d0e68ee41acb6879fd80a19d8aee64de8432 100644 (file)
@@ -44,7 +44,7 @@ gm107_nvdec_nofw(struct nvkm_nvdec *nvdec, int ver,
        return 0;
 }
 
-static const struct nvkm_nvdec_fwif
+const struct nvkm_nvdec_fwif
 gm107_nvdec_fwif[] = {
        { -1, gm107_nvdec_nofw, &gm107_nvdec },
        {}
index 61e1f7aaa50933ae2ef32bd699fad679bd5c03fe..2a7ef527ed313dacda1dda15b2e8c8268808c34d 100644 (file)
@@ -14,6 +14,8 @@ struct nvkm_nvdec_fwif {
        const struct nvkm_nvdec_func *func;
 };
 
+extern const struct nvkm_nvdec_fwif gm107_nvdec_fwif[];
+
 int nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *,
                    enum nvkm_subdev_type, int, u32 addr, struct nvkm_nvdec **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/tu102.c b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/tu102.c
new file mode 100644 (file)
index 0000000..fe95b6e
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2023 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include "priv.h"
+
+#include <subdev/gsp.h>
+
+int
+tu102_nvdec_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
+               struct nvkm_nvdec **pnvdec)
+{
+       if (nvkm_gsp_rm(device->gsp))
+               return -ENODEV;
+
+       return nvkm_nvdec_new_(gm107_nvdec_fwif, device, type, inst, 0, pnvdec);
+}