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 3e9d181..a623fb6 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 85c1bd3..fb04d5c 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 d89f5b6..b648a5e 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 45f509c..9b39ec3 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 5e831d3..0fa4df2 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 c630dbd..e228ca3 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 faf0fe9..f56369d 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 260b197..b800cfc 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 21c975a..23cd21b 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 682ca3e..3aa042e 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 979402d..626b642 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 83dd79b..ddd39d7 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 174817c..e6f4365 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 999e50f..9e1745d 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;
+}