]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/nouveau/sec2/tu102-: prepare for GSP-RM
authorBen Skeggs <bskeggs@redhat.com>
Mon, 18 Sep 2023 20:21:34 +0000 (06:21 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 31 Oct 2023 05:08:15 +0000 (15:08 +1000)
- add (initial) R535 implementation of SEC2, needed for boot

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-30-skeggsb@gmail.com
drivers/gpu/drm/nouveau/nvkm/engine/sec2/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/sec2/ga102.c
drivers/gpu/drm/nouveau/nvkm/engine/sec2/priv.h
drivers/gpu/drm/nouveau/nvkm/engine/sec2/r535.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/sec2/tu102.c

index 19feadb1f67b4a3acdd333193178d9f7ba43d7a4..b43b7e5e2733e4a5a4997b3e5e832f8dbc197345 100644 (file)
@@ -4,3 +4,5 @@ nvkm-y += nvkm/engine/sec2/gp102.o
 nvkm-y += nvkm/engine/sec2/gp108.o
 nvkm-y += nvkm/engine/sec2/tu102.o
 nvkm-y += nvkm/engine/sec2/ga102.o
+
+nvkm-y += nvkm/engine/sec2/r535.o
index 945abb8156d72657ad48807c93d64b3e6b1c855d..54be7596b046f925d1a7427c5eff4e729efbba24 100644 (file)
@@ -21,6 +21,7 @@
  */
 #include "priv.h"
 #include <subdev/acr.h>
+#include <subdev/gsp.h>
 #include <subdev/vfn.h>
 
 #include <nvfw/flcn.h>
@@ -193,5 +194,10 @@ ga102_sec2_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
        /* TOP info wasn't updated on Turing to reflect the PRI
         * address change for some reason.  We override it here.
         */
-       return nvkm_sec2_new_(ga102_sec2_fwif, device, type, inst, 0x840000, psec2);
+       const u32 addr = 0x840000;
+
+       if (nvkm_gsp_rm(device->gsp))
+               return r535_sec2_new(&ga102_sec2, device, type, inst, addr, psec2);
+
+       return nvkm_sec2_new_(ga102_sec2_fwif, device, type, inst, addr, psec2);
 }
index 172d2705c199234484939762ce0e80752bf527d8..e158a40a4f09a6510c1dd49e2376d3e2d8b5af11 100644 (file)
@@ -4,6 +4,9 @@
 #include <engine/sec2.h>
 struct nvkm_acr_lsfw;
 
+int r535_sec2_new(const struct nvkm_sec2_func *,
+                 struct nvkm_device *, enum nvkm_subdev_type, int, u32 addr, struct nvkm_sec2 **);
+
 struct nvkm_sec2_func {
        const struct nvkm_falcon_func *flcn;
        u8 unit_unload;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sec2/r535.c b/drivers/gpu/drm/nouveau/nvkm/engine/sec2/r535.c
new file mode 100644 (file)
index 0000000..83a6bad
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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"
+
+static void *
+r535_sec2_dtor(struct nvkm_engine *engine)
+{
+       struct nvkm_sec2 *sec2 = nvkm_sec2(engine);
+
+       nvkm_falcon_dtor(&sec2->falcon);
+       return sec2;
+}
+
+static const struct nvkm_engine_func
+r535_sec2 = {
+       .dtor = r535_sec2_dtor,
+};
+
+int
+r535_sec2_new(const struct nvkm_sec2_func *func, struct nvkm_device *device,
+             enum nvkm_subdev_type type, int inst, u32 addr, struct nvkm_sec2 **psec2)
+{
+       struct nvkm_sec2 *sec2;
+       int ret;
+
+       if (!(sec2 = *psec2 = kzalloc(sizeof(*sec2), GFP_KERNEL)))
+               return -ENOMEM;
+
+       ret = nvkm_engine_ctor(&r535_sec2, device, type, inst, true, &sec2->engine);
+       if (ret)
+               return ret;
+
+       return nvkm_falcon_ctor(func->flcn, &sec2->engine.subdev, sec2->engine.subdev.name,
+                               addr, &sec2->falcon);
+}
index 0afc4b2fa5294f917d12e5248a22dd7838f058ec..20452046d7d1ffc3f50a6eff70ccf91b4c1bfaa5 100644 (file)
@@ -21,6 +21,7 @@
  */
 #include "priv.h"
 #include <subdev/acr.h>
+#include <subdev/gsp.h>
 
 #include <nvfw/sec2.h>
 
@@ -82,5 +83,10 @@ tu102_sec2_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
        /* TOP info wasn't updated on Turing to reflect the PRI
         * address change for some reason.  We override it here.
         */
-       return nvkm_sec2_new_(tu102_sec2_fwif, device, type, inst, 0x840000, psec2);
+       const u32 addr = 0x840000;
+
+       if (nvkm_gsp_rm(device->gsp))
+               return r535_sec2_new(&tu102_sec2, device, type, inst, addr, psec2);
+
+       return nvkm_sec2_new_(tu102_sec2_fwif, device, type, inst, addr, psec2);
 }