drm/nouveau/ce/ga100-: initial support
authorBen Skeggs <bskeggs@redhat.com>
Wed, 1 Jun 2022 10:47:38 +0000 (20:47 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 9 Nov 2022 00:44:50 +0000 (10:44 +1000)
- replaces the hacked-up version that existed solely to support TTM
- noop until the next commit, adding proper support for ampere host

v2. fixup for ga103 early merge

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvif/class.h
drivers/gpu/drm/nouveau/include/nvkm/engine/ce.h
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nvkm/engine/ce/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/ce/ga100.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/ce/ga102.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/ce/priv.h
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c

index ceea074..36c59c7 100644 (file)
 #define PASCAL_DMA_COPY_B                                            0x0000c1b5
 #define VOLTA_DMA_COPY_A                                             0x0000c3b5
 #define TURING_DMA_COPY_A                                            0x0000c5b5
+#define AMPERE_DMA_COPY_A                                            0x0000c6b5
 #define AMPERE_DMA_COPY_B                                            0x0000c7b5
 
 #define FERMI_DECOMPRESS                                             0x000090b8
index cfd2da8..b616a1e 100644 (file)
@@ -12,4 +12,6 @@ int gp100_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct n
 int gp102_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
 int gv100_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
 int tu102_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
+int ga100_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
+int ga102_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
 #endif
index 813937a..a11871e 100644 (file)
@@ -856,6 +856,9 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
                int (*init)(struct nouveau_channel *, u32 handle);
        } _methods[] = {
                {  "COPY", 4, 0xc7b5, nve0_bo_move_copy, nve0_bo_move_init },
+               {  "GRCE", 0, 0xc7b5, nve0_bo_move_copy, nvc0_bo_move_init },
+               {  "COPY", 4, 0xc6b5, nve0_bo_move_copy, nve0_bo_move_init },
+               {  "GRCE", 0, 0xc6b5, nve0_bo_move_copy, nvc0_bo_move_init },
                {  "COPY", 4, 0xc5b5, nve0_bo_move_copy, nve0_bo_move_init },
                {  "GRCE", 0, 0xc5b5, nve0_bo_move_copy, nvc0_bo_move_init },
                {  "COPY", 4, 0xc3b5, nve0_bo_move_copy, nve0_bo_move_init },
index ba88613..8bf1635 100644 (file)
@@ -8,3 +8,5 @@ nvkm-y += nvkm/engine/ce/gp100.o
 nvkm-y += nvkm/engine/ce/gp102.o
 nvkm-y += nvkm/engine/ce/gv100.o
 nvkm-y += nvkm/engine/ce/tu102.o
+nvkm-y += nvkm/engine/ce/ga100.o
+nvkm-y += nvkm/engine/ce/ga102.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/ce/ga100.c b/drivers/gpu/drm/nouveau/nvkm/engine/ce/ga100.c
new file mode 100644 (file)
index 0000000..6648ed6
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+#include "priv.h"
+
+#include <subdev/vfn.h>
+
+#include <nvif/class.h>
+
+static irqreturn_t
+ga100_ce_intr(struct nvkm_inth *inth)
+{
+       struct nvkm_subdev *subdev = container_of(inth, typeof(*subdev), inth);
+
+       /*TODO*/
+       nvkm_error(subdev, "intr\n");
+       return IRQ_NONE;
+}
+
+int
+ga100_ce_fini(struct nvkm_engine *engine, bool suspend)
+{
+       nvkm_inth_block(&engine->subdev.inth);
+       return 0;
+}
+
+int
+ga100_ce_init(struct nvkm_engine *engine)
+{
+       nvkm_inth_allow(&engine->subdev.inth);
+       return 0;
+}
+
+int
+ga100_ce_oneinit(struct nvkm_engine *engine)
+{
+       struct nvkm_subdev *subdev = &engine->subdev;
+       struct nvkm_device *device = subdev->device;
+       u32 vector;
+
+       vector = nvkm_rd32(device, 0x10442c + (subdev->inst * 0x80)) & 0x00000fff;
+
+       return nvkm_inth_add(&device->vfn->intr, vector, NVKM_INTR_PRIO_NORMAL,
+                            subdev, ga100_ce_intr, &subdev->inth);
+}
+
+static const struct nvkm_engine_func
+ga100_ce = {
+       .oneinit = ga100_ce_oneinit,
+       .init = ga100_ce_init,
+       .fini = ga100_ce_fini,
+       .cclass = &gv100_ce_cclass,
+       .sclass = {
+               { -1, -1, AMPERE_DMA_COPY_A },
+               {}
+       }
+};
+
+int
+ga100_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
+            struct nvkm_engine **pengine)
+{
+       return nvkm_engine_new_(&ga100_ce, device, type, inst, true, pengine);
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/ce/ga102.c b/drivers/gpu/drm/nouveau/nvkm/engine/ce/ga102.c
new file mode 100644 (file)
index 0000000..9f3448a
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+#include "priv.h"
+
+#include <nvif/class.h>
+
+static const struct nvkm_engine_func
+ga102_ce = {
+       .oneinit = ga100_ce_oneinit,
+       .init = ga100_ce_init,
+       .fini = ga100_ce_fini,
+       .cclass = &gv100_ce_cclass,
+       .sclass = {
+               { -1, -1, AMPERE_DMA_COPY_A },
+               { -1, -1, AMPERE_DMA_COPY_B },
+               {}
+       }
+};
+
+int
+ga102_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
+            struct nvkm_engine **pengine)
+{
+       return nvkm_engine_new_(&ga102_ce, device, type, inst, true, pengine);
+}
index cd53b93..c4c0469 100644 (file)
@@ -8,4 +8,8 @@ void gk104_ce_intr(struct nvkm_engine *);
 void gp100_ce_intr(struct nvkm_engine *);
 
 extern const struct nvkm_object_func gv100_ce_cclass;
+
+int ga100_ce_oneinit(struct nvkm_engine *);
+int ga100_ce_init(struct nvkm_engine *);
+int ga100_ce_fini(struct nvkm_engine *, bool);
 #endif
index 4f5921a..490fac3 100644 (file)
@@ -2589,6 +2589,7 @@ nv170_chipset = {
        .timer    = { 0x00000001, gk20a_timer_new },
        .top      = { 0x00000001, ga100_top_new },
        .vfn      = { 0x00000001, ga100_vfn_new },
+       .ce       = { 0x000003ff, ga100_ce_new },
 };
 
 static const struct nvkm_device_chip
@@ -2609,6 +2610,7 @@ nv172_chipset = {
        .timer    = { 0x00000001, gk20a_timer_new },
        .top      = { 0x00000001, ga100_top_new },
        .vfn      = { 0x00000001, ga100_vfn_new },
+       .ce       = { 0x0000001f, ga102_ce_new },
        .disp     = { 0x00000001, ga102_disp_new },
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
@@ -2632,6 +2634,7 @@ nv173_chipset = {
        .timer    = { 0x00000001, gk20a_timer_new },
        .top      = { 0x00000001, ga100_top_new },
        .vfn      = { 0x00000001, ga100_vfn_new },
+       .ce       = { 0x0000001f, ga102_ce_new },
        .disp     = { 0x00000001, ga102_disp_new },
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
@@ -2655,6 +2658,7 @@ nv174_chipset = {
        .timer    = { 0x00000001, gk20a_timer_new },
        .top      = { 0x00000001, ga100_top_new },
        .vfn      = { 0x00000001, ga100_vfn_new },
+       .ce       = { 0x0000001f, ga102_ce_new },
        .disp     = { 0x00000001, ga102_disp_new },
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
@@ -2678,6 +2682,7 @@ nv176_chipset = {
        .timer    = { 0x00000001, gk20a_timer_new },
        .top      = { 0x00000001, ga100_top_new },
        .vfn      = { 0x00000001, ga100_vfn_new },
+       .ce       = { 0x0000001f, ga102_ce_new },
        .disp     = { 0x00000001, ga102_disp_new },
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },
@@ -2701,6 +2706,7 @@ nv177_chipset = {
        .timer    = { 0x00000001, gk20a_timer_new },
        .top      = { 0x00000001, ga100_top_new },
        .vfn      = { 0x00000001, ga100_vfn_new },
+       .ce       = { 0x0000001f, ga102_ce_new },
        .disp     = { 0x00000001, ga102_disp_new },
        .dma      = { 0x00000001, gv100_dma_new },
        .fifo     = { 0x00000001, ga102_fifo_new },