drm/nouveau/vfn: move NV_USERMODE class from host
authorBen Skeggs <bskeggs@redhat.com>
Wed, 1 Jun 2022 10:46:53 +0000 (20:46 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 9 Nov 2022 00:44:36 +0000 (10:44 +1000)
- uses proper class IDs for Turing/Ampere

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
18 files changed:
drivers/gpu/drm/nouveau/include/nvif/class.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/vfn.h
drivers/gpu/drm/nouveau/nvif/user.c
drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/fifo/ga102.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gv100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/tu102.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/user.h [deleted file]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/usergv100.c [deleted file]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/usertu102.c [deleted file]
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/ga100.c
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/gv100.c
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/priv.h
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/tu102.c
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c [new file with mode: 0644]

index 3e9d181b5dda1e7ddcc5f58a9214503a6892fc4c..a623fb67280b06711472f4de3471a9d0d20d8b55 100644 (file)
@@ -63,6 +63,8 @@
 #define NV04_DISP                                     /* cl0046.h */ 0x00000046
 
 #define VOLTA_USERMODE_A                                             0x0000c361
+#define TURING_USERMODE_A                                            0x0000c461
+#define AMPERE_USERMODE_A                                            0x0000c561
 
 #define MAXWELL_FAULT_BUFFER_A                        /* clb069.h */ 0x0000b069
 #define VOLTA_FAULT_BUFFER_A                          /* clb069.h */ 0x0000c369
index 85c1bd36ee50f05114d632f7dd266a9dc65af3eb..fb04d5cd34bf4f8f5baa5808660e7f804072412a 100644 (file)
@@ -9,7 +9,10 @@ struct nvkm_vfn {
 
        struct {
                u32 priv;
+               u32 user;
        } addr;
+
+       struct nvkm_device_oclass user;
 };
 
 int gv100_vfn_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_vfn **);
index d89f5b67b3046518d9735c593611cffb38d10259..b648a5e036afb452bc0e52cc0169fabe74e27681 100644 (file)
@@ -41,7 +41,9 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
                int version;
                const struct nvif_user_func *func;
        } users[] = {
-               { VOLTA_USERMODE_A, -1, &nvif_userc361 },
+               { AMPERE_USERMODE_A, -1, &nvif_userc361 },
+               { TURING_USERMODE_A, -1, &nvif_userc361 },
+               {  VOLTA_USERMODE_A, -1, &nvif_userc361 },
                {}
        };
        int cid, ret;
index 45f509c11c361ad9ed6c6ae3a7483094acbcf54a..9b39ec34161501bdcc91514e8ca4ec7b99e82719 100644 (file)
@@ -342,6 +342,8 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
                        sclass = &device->mmu->user;
                else if (device->fault && index-- == 0)
                        sclass = &device->fault->user;
+               else if (device->vfn && index-- == 0)
+                       sclass = &device->vfn->user;
                else
                        return -EINVAL;
 
index 5e831d347a95795f3b22217b532afd4ceeb81714..0fa4df2990095062f1a1da0c5a271d2b84923d08 100644 (file)
@@ -35,6 +35,3 @@ nvkm-y += nvkm/engine/fifo/gpfifogf100.o
 nvkm-y += nvkm/engine/fifo/gpfifogk104.o
 nvkm-y += nvkm/engine/fifo/gpfifogv100.o
 nvkm-y += nvkm/engine/fifo/gpfifotu102.o
-
-nvkm-y += nvkm/engine/fifo/usergv100.o
-nvkm-y += nvkm/engine/fifo/usertu102.o
index c630dbd2911aef914750520673670512a09995a7..e228ca3a520321e4d60c8a076ee5c4f491c060b8 100644 (file)
@@ -22,7 +22,6 @@
 #define ga102_fifo(p) container_of((p), struct ga102_fifo, base.engine)
 #define ga102_chan(p) container_of((p), struct ga102_chan, object)
 #include <engine/fifo.h>
-#include "user.h"
 
 #include <core/memory.h>
 #include <subdev/mmu.h>
@@ -242,33 +241,16 @@ ga102_chan_oclass = {
        .ctor = ga102_chan_new,
 };
 
-static int
-ga102_user_new(struct nvkm_device *device,
-              const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nvkm_object **pobject)
-{
-       return tu102_fifo_user_new(oclass, argv, argc, pobject);
-}
-
-static const struct nvkm_device_oclass
-ga102_user_oclass = {
-       .ctor = ga102_user_new,
-};
-
 static int
 ga102_fifo_sclass(struct nvkm_oclass *oclass, int index, const struct nvkm_device_oclass **class)
 {
        if (index == 0) {
-               oclass->base = (struct nvkm_sclass) { -1, -1, VOLTA_USERMODE_A };
-               *class = &ga102_user_oclass;
-               return 0;
-       } else
-       if (index == 1) {
                oclass->base = (struct nvkm_sclass) { 0, 0, AMPERE_CHANNEL_GPFIFO_B };
                *class = &ga102_chan_oclass;
                return 0;
        }
 
-       return 2;
+       return 1;
 }
 
 static int
index faf0fe9f704cf14edc2dee3618d5962c7b0af374..f56369d592193ef6a29d35f46b6136c8dd84f59a 100644 (file)
@@ -22,7 +22,6 @@
 #include "gk104.h"
 #include "cgrp.h"
 #include "changk104.h"
-#include "user.h"
 
 #include <core/gpuobj.h>
 
@@ -295,7 +294,6 @@ gv100_fifo = {
        .fault.hubclient = gv100_fifo_fault_hubclient,
        .fault.gpcclient = gv100_fifo_fault_gpcclient,
        .runlist = &gv100_fifo_runlist,
-       .user = {{-1,-1,VOLTA_USERMODE_A      }, gv100_fifo_user_new   },
        .chan = {{ 0, 0,VOLTA_CHANNEL_GPFIFO_A}, gv100_fifo_gpfifo_new },
        .cgrp_force = true,
 };
index 260b197f81bc357491e1e5a0674af166cfd30546..b800cfc5bfd919da2887acae2b933ce9ffc48317 100644 (file)
@@ -22,7 +22,6 @@
 #include "gk104.h"
 #include "cgrp.h"
 #include "changk104.h"
-#include "user.h"
 
 #include <core/client.h>
 #include <core/gpuobj.h>
@@ -110,7 +109,6 @@ tu102_fifo = {
        .fault.hubclient = gv100_fifo_fault_hubclient,
        .fault.gpcclient = gv100_fifo_fault_gpcclient,
        .runlist = &tu102_fifo_runlist,
-       .user = {{-1,-1,VOLTA_USERMODE_A       }, tu102_fifo_user_new   },
        .chan = {{ 0, 0,TURING_CHANNEL_GPFIFO_A}, tu102_fifo_gpfifo_new },
        .cgrp_force = true,
 };
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/user.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/user.h
deleted file mode 100644 (file)
index 54a3a30..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __NVKM_FIFO_USER_H__
-#define __NVKM_FIFO_USER_H__
-#include "priv.h"
-int gv100_fifo_user_new(const struct nvkm_oclass *, void *, u32,
-                       struct nvkm_object **);
-int tu102_fifo_user_new(const struct nvkm_oclass *, void *, u32,
-                       struct nvkm_object **);
-#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/usergv100.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/usergv100.c
deleted file mode 100644 (file)
index 3dc3b8b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2018 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 "user.h"
-
-static int
-gv100_fifo_user_map(struct nvkm_object *object, void *argv, u32 argc,
-                   enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
-       struct nvkm_device *device = object->engine->subdev.device;
-       *addr = 0x810000 + device->func->resource_addr(device, 0);
-       *size = 0x010000;
-       *type = NVKM_OBJECT_MAP_IO;
-       return 0;
-}
-
-static const struct nvkm_object_func
-gv100_fifo_user = {
-       .map = gv100_fifo_user_map,
-};
-
-int
-gv100_fifo_user_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
-                   struct nvkm_object **pobject)
-{
-       return nvkm_object_new_(&gv100_fifo_user, oclass, argv, argc, pobject);
-}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/usertu102.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/usertu102.c
deleted file mode 100644 (file)
index 217268f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2018 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 "user.h"
-
-static int
-tu102_fifo_user_map(struct nvkm_object *object, void *argv, u32 argc,
-                   enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
-       struct nvkm_device *device = object->engine->subdev.device;
-       *addr = 0xbb0000 + device->func->resource_addr(device, 0);
-       *size = 0x010000;
-       *type = NVKM_OBJECT_MAP_IO;
-       return 0;
-}
-
-static const struct nvkm_object_func
-tu102_fifo_user = {
-       .map = tu102_fifo_user_map,
-};
-
-int
-tu102_fifo_user_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
-                   struct nvkm_object **pobject)
-{
-       return nvkm_object_new_(&tu102_fifo_user, oclass, argv, argc, pobject);
-}
index 21c975a6b206066f3ac6bd0d82ef76a6d4d1fde7..23cd21b40a25e463c52480e6e859290898e86a72 100644 (file)
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: MIT
 nvkm-y += nvkm/subdev/vfn/base.o
+nvkm-y += nvkm/subdev/vfn/uvfn.o
 nvkm-y += nvkm/subdev/vfn/gv100.o
 nvkm-y += nvkm/subdev/vfn/tu102.o
 nvkm-y += nvkm/subdev/vfn/ga100.o
index 682ca3ed725b3d4adc5a1cf5dff94449b4434f3d..3aa042eec1042c73756cb5e8e6fc8b85d661720b 100644 (file)
@@ -44,5 +44,9 @@ nvkm_vfn_new_(const struct nvkm_vfn_func *func, struct nvkm_device *device,
        nvkm_subdev_ctor(&nvkm_vfn, device, type, inst, &vfn->subdev);
        vfn->func = func;
        vfn->addr.priv = addr;
+       vfn->addr.user = vfn->addr.priv + func->user.addr;
+
+       vfn->user.ctor = nvkm_uvfn_new;
+       vfn->user.base = func->user.base;
        return 0;
 }
index 979402dff65956e8cde758f18eecd795c1cd360e..626b64230fe594076893415cdb2c7a84773b4b95 100644 (file)
  */
 #include "priv.h"
 
+#include <nvif/class.h>
+
 static const struct nvkm_vfn_func
 ga100_vfn = {
+       .user = { 0x030000, 0x010000, { -1, -1, AMPERE_USERMODE_A } },
 };
 
 int
index 83dd79bddd86757e0311bfadc583d9406c785b8f..ddd39d714c4a9bb5a78edd3280baf41cac8633ed 100644 (file)
  */
 #include "priv.h"
 
+#include <nvif/class.h>
+
 static const struct nvkm_vfn_func
 gv100_vfn = {
+       .user = { 0x810000, 0x010000, { -1, -1, VOLTA_USERMODE_A } },
 };
 
 int
index 174817c76bf9588eaf5dbc56d69762240eb801f6..e6f436532392679b29b771ce8510672bbdd629bf 100644 (file)
@@ -5,8 +5,16 @@
 #include <subdev/vfn.h>
 
 struct nvkm_vfn_func {
+       struct {
+               u32 addr;
+               u32 size;
+               const struct nvkm_sclass base;
+       } user;
 };
 
 int nvkm_vfn_new_(const struct nvkm_vfn_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
                  u32 addr, struct nvkm_vfn **);
+
+int nvkm_uvfn_new(struct nvkm_device *, const struct nvkm_oclass *, void *, u32,
+                 struct nvkm_object **);
 #endif
index 999e50f5c36b22f3a5961c285de20a243a8794a1..9e1745d31fbb15e6059ed4c00c49741d4a60ec94 100644 (file)
  */
 #include "priv.h"
 
+#include <nvif/class.h>
+
 static const struct nvkm_vfn_func
 tu102_vfn = {
+       .user = { 0x030000, 0x010000, { -1, -1, TURING_USERMODE_A } },
 };
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
new file mode 100644 (file)
index 0000000..c5460a1
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2021 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.
+ */
+#define nvkm_uvfn(p) container_of((p), struct nvkm_uvfn, object)
+#include "priv.h"
+
+#include <core/object.h>
+
+struct nvkm_uvfn {
+       struct nvkm_object object;
+       struct nvkm_vfn *vfn;
+};
+
+static int
+nvkm_uvfn_map(struct nvkm_object *object, void *argv, u32 argc,
+             enum nvkm_object_map *type, u64 *addr, u64 *size)
+{
+       struct nvkm_vfn *vfn = nvkm_uvfn(object)->vfn;
+       struct nvkm_device *device = vfn->subdev.device;
+
+       *addr = device->func->resource_addr(device, 0) + vfn->addr.user;
+       *size = vfn->func->user.size;
+       *type = NVKM_OBJECT_MAP_IO;
+       return 0;
+}
+
+static const struct nvkm_object_func
+nvkm_uvfn = {
+       .map = nvkm_uvfn_map,
+};
+
+int
+nvkm_uvfn_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
+             void *argv, u32 argc, struct nvkm_object **pobject)
+{
+       struct nvkm_uvfn *uvfn;
+
+       if (argc != 0)
+               return -ENOSYS;
+
+       if (!(uvfn = kzalloc(sizeof(*uvfn), GFP_KERNEL)))
+               return -ENOMEM;
+
+       nvkm_object_ctor(&nvkm_uvfn, oclass, &uvfn->object);
+       uvfn->vfn = device->vfn;
+
+       *pobject = &uvfn->object;
+       return 0;
+}