drm/nouveau/gsp: prepare for GSP-RM
authorBen Skeggs <bskeggs@redhat.com>
Mon, 18 Sep 2023 20:21:09 +0000 (06:21 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 31 Oct 2023 05:08:10 +0000 (15:08 +1000)
- move TOP after GSP, so we can disable TOP if GSP is in use
- provide plumbing to support falcon-only and GSP-RM paths
- provide a method for subdevs to detect GSP-RM paths
- split tu102/tu116/ga100 paths from gv100, which can't support GSP-RM

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-5-skeggsb@gmail.com
drivers/gpu/drm/nouveau/include/nvkm/core/layout.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga100.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga102.c
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gv100.c
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/priv.h
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu116.c [new file with mode: 0644]

index 6af0352a4873743ae732ae48f24465c5524ec0a2..30c17db483cb53cd90cc121285f5dd2cc89a388f 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: MIT */
-NVKM_LAYOUT_ONCE(NVKM_SUBDEV_TOP     , struct nvkm_top     ,      top)
 NVKM_LAYOUT_ONCE(NVKM_SUBDEV_GSP     , struct nvkm_gsp     ,      gsp)
+NVKM_LAYOUT_ONCE(NVKM_SUBDEV_TOP     , struct nvkm_top     ,      top)
 NVKM_LAYOUT_ONCE(NVKM_SUBDEV_VFN     , struct nvkm_vfn     ,      vfn)
 NVKM_LAYOUT_ONCE(NVKM_SUBDEV_PCI     , struct nvkm_pci     ,      pci)
 NVKM_LAYOUT_ONCE(NVKM_SUBDEV_VBIOS   , struct nvkm_bios    ,     bios)
index 72619d7df73e7047d2ac9764ce0301d53d0e8ced..688270f62e0985e8d44911381ad82428de0d2faf 100644 (file)
@@ -11,6 +11,15 @@ struct nvkm_gsp {
        struct nvkm_falcon falcon;
 };
 
+static inline bool
+nvkm_gsp_rm(struct nvkm_gsp *gsp)
+{
+       return false;
+}
+
 int gv100_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
+int tu102_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
+int tu116_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
+int ga100_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
 int ga102_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
 #endif
index 1c81e5b34d29d871b35431c47b9d1ff651fc5245..395702870872bb11986925ce63383c752d412ca8 100644 (file)
@@ -2408,7 +2408,7 @@ nv162_chipset = {
        .fb       = { 0x00000001, tu102_fb_new },
        .fuse     = { 0x00000001, gm107_fuse_new },
        .gpio     = { 0x00000001, gk104_gpio_new },
-       .gsp      = { 0x00000001, gv100_gsp_new },
+       .gsp      = { 0x00000001, tu102_gsp_new },
        .i2c      = { 0x00000001, gm200_i2c_new },
        .imem     = { 0x00000001, nv50_instmem_new },
        .ltc      = { 0x00000001, gp102_ltc_new },
@@ -2443,7 +2443,7 @@ nv164_chipset = {
        .fb       = { 0x00000001, tu102_fb_new },
        .fuse     = { 0x00000001, gm107_fuse_new },
        .gpio     = { 0x00000001, gk104_gpio_new },
-       .gsp      = { 0x00000001, gv100_gsp_new },
+       .gsp      = { 0x00000001, tu102_gsp_new },
        .i2c      = { 0x00000001, gm200_i2c_new },
        .imem     = { 0x00000001, nv50_instmem_new },
        .ltc      = { 0x00000001, gp102_ltc_new },
@@ -2478,7 +2478,7 @@ nv166_chipset = {
        .fb       = { 0x00000001, tu102_fb_new },
        .fuse     = { 0x00000001, gm107_fuse_new },
        .gpio     = { 0x00000001, gk104_gpio_new },
-       .gsp      = { 0x00000001, gv100_gsp_new },
+       .gsp      = { 0x00000001, tu102_gsp_new },
        .i2c      = { 0x00000001, gm200_i2c_new },
        .imem     = { 0x00000001, nv50_instmem_new },
        .ltc      = { 0x00000001, gp102_ltc_new },
@@ -2513,7 +2513,7 @@ nv167_chipset = {
        .fb       = { 0x00000001, tu102_fb_new },
        .fuse     = { 0x00000001, gm107_fuse_new },
        .gpio     = { 0x00000001, gk104_gpio_new },
-       .gsp      = { 0x00000001, gv100_gsp_new },
+       .gsp      = { 0x00000001, tu116_gsp_new },
        .i2c      = { 0x00000001, gm200_i2c_new },
        .imem     = { 0x00000001, nv50_instmem_new },
        .ltc      = { 0x00000001, gp102_ltc_new },
@@ -2548,7 +2548,7 @@ nv168_chipset = {
        .fb       = { 0x00000001, tu102_fb_new },
        .fuse     = { 0x00000001, gm107_fuse_new },
        .gpio     = { 0x00000001, gk104_gpio_new },
-       .gsp      = { 0x00000001, gv100_gsp_new },
+       .gsp      = { 0x00000001, tu116_gsp_new },
        .i2c      = { 0x00000001, gm200_i2c_new },
        .imem     = { 0x00000001, nv50_instmem_new },
        .ltc      = { 0x00000001, gp102_ltc_new },
@@ -2580,6 +2580,7 @@ nv170_chipset = {
        .fault    = { 0x00000001, tu102_fault_new },
        .fb       = { 0x00000001, ga100_fb_new },
        .gpio     = { 0x00000001, gk104_gpio_new },
+       .gsp      = { 0x00000001, ga100_gsp_new },
        .i2c      = { 0x00000001, gm200_i2c_new },
        .imem     = { 0x00000001, nv50_instmem_new },
        .mc       = { 0x00000001, ga100_mc_new },
index 7f61a1ed158b98148d77180662854a6ff7dc988d..4b497ad9bb91722e5564492e7d30bb0f2f17ed1b 100644 (file)
@@ -1,4 +1,7 @@
 # SPDX-License-Identifier: MIT
 nvkm-y += nvkm/subdev/gsp/base.o
 nvkm-y += nvkm/subdev/gsp/gv100.o
+nvkm-y += nvkm/subdev/gsp/tu102.o
+nvkm-y += nvkm/subdev/gsp/tu116.o
+nvkm-y += nvkm/subdev/gsp/ga100.o
 nvkm-y += nvkm/subdev/gsp/ga102.o
index 591ac95c26699c2a67e7c8506401c493c23b43e0..9424d104f2bea2eafc4f13787267e3ae69eaa5e7 100644 (file)
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "priv.h"
-#include <core/falcon.h>
-#include <core/firmware.h>
-#include <subdev/acr.h>
-#include <subdev/top.h>
+
+static int
+nvkm_gsp_fini(struct nvkm_subdev *subdev, bool suspend)
+{
+       struct nvkm_gsp *gsp = nvkm_gsp(subdev);
+
+       if (!gsp->func->fini)
+               return 0;
+
+       return gsp->func->fini(gsp, suspend);
+}
+
+static int
+nvkm_gsp_init(struct nvkm_subdev *subdev)
+{
+       struct nvkm_gsp *gsp = nvkm_gsp(subdev);
+
+       if (!gsp->func->init)
+               return 0;
+
+       return gsp->func->init(gsp);
+}
+
+static int
+nvkm_gsp_oneinit(struct nvkm_subdev *subdev)
+{
+       struct nvkm_gsp *gsp = nvkm_gsp(subdev);
+
+       if (!gsp->func->oneinit)
+               return 0;
+
+       return gsp->func->oneinit(gsp);
+}
 
 static void *
 nvkm_gsp_dtor(struct nvkm_subdev *subdev)
 {
        struct nvkm_gsp *gsp = nvkm_gsp(subdev);
+
+       if (gsp->func && gsp->func->dtor)
+               gsp->func->dtor(gsp);
+
        nvkm_falcon_dtor(&gsp->falcon);
        return gsp;
 }
@@ -36,6 +69,9 @@ nvkm_gsp_dtor(struct nvkm_subdev *subdev)
 static const struct nvkm_subdev_func
 nvkm_gsp = {
        .dtor = nvkm_gsp_dtor,
+       .oneinit = nvkm_gsp_oneinit,
+       .init = nvkm_gsp_init,
+       .fini = nvkm_gsp_fini,
 };
 
 int
@@ -55,5 +91,6 @@ nvkm_gsp_new_(const struct nvkm_gsp_fwif *fwif, struct nvkm_device *device,
 
        gsp->func = fwif->func;
 
-       return nvkm_falcon_ctor(gsp->func->flcn, &gsp->subdev, gsp->subdev.name, 0, &gsp->falcon);
+       return nvkm_falcon_ctor(gsp->func->flcn, &gsp->subdev, gsp->subdev.name, 0x110000,
+                               &gsp->falcon);
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga100.c
new file mode 100644 (file)
index 0000000..73c3676
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2022 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"
+
+static struct nvkm_gsp_fwif
+ga100_gsps[] = {
+       { -1, gv100_gsp_nofw, &gv100_gsp },
+       {}
+};
+
+int
+ga100_gsp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
+             struct nvkm_gsp **pgsp)
+{
+       return nvkm_gsp_new_(ga100_gsps, device, type, inst, pgsp);
+}
index a3996ceca99552de6415056d4b821285918279be..ec6380f8bac520fd0fd301c3f9cdafe5ee184a48 100644 (file)
@@ -39,15 +39,9 @@ ga102_gsp = {
        .flcn = &ga102_gsp_flcn,
 };
 
-static int
-ga102_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)
-{
-       return 0;
-}
-
 static struct nvkm_gsp_fwif
 ga102_gsps[] = {
-       { -1, ga102_gsp_nofw, &ga102_gsp },
+       { -1, gv100_gsp_nofw, &ga102_gsp },
        {}
 };
 
index da6a809cd31731dca04ca2ea623c1be5415f6bbd..62d9289bcaa5f971cd5aef3a10ddb50808eaa0c7 100644 (file)
@@ -34,12 +34,12 @@ gv100_gsp_flcn = {
        .dmem_pio = &gm200_flcn_dmem_pio,
 };
 
-static const struct nvkm_gsp_func
+const struct nvkm_gsp_func
 gv100_gsp = {
        .flcn = &gv100_gsp_flcn,
 };
 
-static int
+int
 gv100_gsp_nofw(struct nvkm_gsp *gsp, int ver, const struct nvkm_gsp_fwif *fwif)
 {
        return 0;
index 89749a40203c46b95f78eda42fa1d29745bed8fa..351c959476ecf8bc4f733de4970b0652ad040e83 100644 (file)
@@ -4,16 +4,25 @@
 #include <subdev/gsp.h>
 enum nvkm_acr_lsf_id;
 
-struct nvkm_gsp_func {
-       const struct nvkm_falcon_func *flcn;
-};
-
 struct nvkm_gsp_fwif {
        int version;
        int (*load)(struct nvkm_gsp *, int ver, const struct nvkm_gsp_fwif *);
        const struct nvkm_gsp_func *func;
 };
 
+int gv100_gsp_nofw(struct nvkm_gsp *, int, const struct nvkm_gsp_fwif *);
+
+struct nvkm_gsp_func {
+       const struct nvkm_falcon_func *flcn;
+
+       void (*dtor)(struct nvkm_gsp *);
+       int (*oneinit)(struct nvkm_gsp *);
+       int (*init)(struct nvkm_gsp *);
+       int (*fini)(struct nvkm_gsp *, bool suspend);
+};
+
 int nvkm_gsp_new_(const struct nvkm_gsp_fwif *, struct nvkm_device *, enum nvkm_subdev_type, int,
                  struct nvkm_gsp **);
+
+extern const struct nvkm_gsp_func gv100_gsp;
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
new file mode 100644 (file)
index 0000000..be3c4de
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2022 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"
+
+static struct nvkm_gsp_fwif
+tu102_gsps[] = {
+       { -1, gv100_gsp_nofw, &gv100_gsp },
+       {}
+};
+
+int
+tu102_gsp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
+             struct nvkm_gsp **pgsp)
+{
+       return nvkm_gsp_new_(tu102_gsps, device, type, inst, pgsp);
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu116.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu116.c
new file mode 100644 (file)
index 0000000..d4a94c1
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2022 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"
+
+static struct nvkm_gsp_fwif
+tu116_gsps[] = {
+       { -1, gv100_gsp_nofw, &gv100_gsp },
+       {}
+};
+
+int
+tu116_gsp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
+             struct nvkm_gsp **pgsp)
+{
+       return nvkm_gsp_new_(tu116_gsps, device, type, inst, pgsp);
+}