Skip to content

Commit b5ce219

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/ce/r535: initial support
Adds support for allocating DMA_COPY classes from RM. Signed-off-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 2a77d01 commit b5ce219

File tree

13 files changed

+193
-3
lines changed

13 files changed

+193
-3
lines changed

drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ struct nvkm_chan *nvkm_chan_get_chid(struct nvkm_engine *, int id, unsigned long
5252
struct nvkm_chan *nvkm_chan_get_inst(struct nvkm_engine *, u64 inst, unsigned long *irqflags);
5353
void nvkm_chan_put(struct nvkm_chan **, unsigned long irqflags);
5454

55+
struct nvkm_chan *nvkm_uchan_chan(struct nvkm_object *);
56+
5557
struct nvkm_fifo {
5658
const struct nvkm_fifo_func *func;
5759
struct nvkm_engine engine;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef __src_common_sdk_nvidia_inc_class_clc0b5sw_h__
2+
#define __src_common_sdk_nvidia_inc_class_clc0b5sw_h__
3+
4+
/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */
5+
6+
/*
7+
* SPDX-FileCopyrightText: Copyright (c) 2014-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
8+
* SPDX-License-Identifier: MIT
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a
11+
* copy of this software and associated documentation files (the "Software"),
12+
* to deal in the Software without restriction, including without limitation
13+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
* and/or sell copies of the Software, and to permit persons to whom the
15+
* Software is furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
* DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
typedef struct NVC0B5_ALLOCATION_PARAMETERS {
30+
NvU32 version;
31+
NvU32 engineType;
32+
} NVC0B5_ALLOCATION_PARAMETERS;
33+
34+
#endif

drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828

2929
#define MC_ENGINE_IDX_DISP 2
3030

31+
#define MC_ENGINE_IDX_CE0 15
32+
33+
#define MC_ENGINE_IDX_CE9 24
34+
3135
#define MC_ENGINE_IDX_GSP 49
3236

3337
#endif

drivers/gpu/drm/nouveau/nvkm/engine/ce/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ nvkm-y += nvkm/engine/ce/gv100.o
1010
nvkm-y += nvkm/engine/ce/tu102.o
1111
nvkm-y += nvkm/engine/ce/ga100.o
1212
nvkm-y += nvkm/engine/ce/ga102.o
13+
14+
nvkm-y += nvkm/engine/ce/r535.o

drivers/gpu/drm/nouveau/nvkm/engine/ce/ga100.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ ga100_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
9090
struct nvkm_engine **pengine)
9191
{
9292
if (nvkm_gsp_rm(device->gsp))
93-
return -ENODEV;
93+
return r535_ce_new(&ga100_ce, device, type, inst, pengine);
9494

9595
return nvkm_engine_new_(&ga100_ce, device, type, inst, true, pengine);
9696
}

drivers/gpu/drm/nouveau/nvkm/engine/ce/ga102.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ga102_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
4444
struct nvkm_engine **pengine)
4545
{
4646
if (nvkm_gsp_rm(device->gsp))
47-
return -ENODEV;
47+
return r535_ce_new(&ga102_ce, device, type, inst, pengine);
4848

4949
return nvkm_engine_new_(&ga102_ce, device, type, inst, true, pengine);
5050
}

drivers/gpu/drm/nouveau/nvkm/engine/ce/priv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#define __NVKM_CE_PRIV_H__
44
#include <engine/ce.h>
55

6+
int r535_ce_new(const struct nvkm_engine_func *, struct nvkm_device *,
7+
enum nvkm_subdev_type, int, struct nvkm_engine **);
8+
69
void gt215_ce_intr(struct nvkm_falcon *, struct nvkm_chan *);
710
void gk104_ce_intr(struct nvkm_engine *);
811
void gp100_ce_intr(struct nvkm_engine *);
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright 2023 Red Hat Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
#include "priv.h"
23+
24+
#include <core/object.h>
25+
#include <subdev/gsp.h>
26+
#include <engine/fifo.h>
27+
28+
#include <nvrm/nvtypes.h>
29+
#include <nvrm/535.54.03/common/sdk/nvidia/inc/class/cl2080_notification.h>
30+
#include <nvrm/535.54.03/common/sdk/nvidia/inc/class/clc0b5sw.h>
31+
32+
struct r535_ce_obj {
33+
struct nvkm_object object;
34+
struct nvkm_gsp_object rm;
35+
};
36+
37+
static void *
38+
r535_ce_obj_dtor(struct nvkm_object *object)
39+
{
40+
struct r535_ce_obj *obj = container_of(object, typeof(*obj), object);
41+
42+
nvkm_gsp_rm_free(&obj->rm);
43+
return obj;
44+
}
45+
46+
static const struct nvkm_object_func
47+
r535_ce_obj = {
48+
.dtor = r535_ce_obj_dtor,
49+
};
50+
51+
static int
52+
r535_ce_obj_ctor(const struct nvkm_oclass *oclass, void *argv, u32 argc,
53+
struct nvkm_object **pobject)
54+
{
55+
struct nvkm_chan *chan = nvkm_uchan_chan(oclass->parent);
56+
struct r535_ce_obj *obj;
57+
NVC0B5_ALLOCATION_PARAMETERS *args;
58+
59+
if (!(obj = kzalloc(sizeof(*obj), GFP_KERNEL)))
60+
return -ENOMEM;
61+
62+
nvkm_object_ctor(&r535_ce_obj, oclass, &obj->object);
63+
*pobject = &obj->object;
64+
65+
args = nvkm_gsp_rm_alloc_get(&chan->rm.object, oclass->handle, oclass->base.oclass,
66+
sizeof(*args), &obj->rm);
67+
if (WARN_ON(IS_ERR(args)))
68+
return PTR_ERR(args);
69+
70+
args->version = 1;
71+
args->engineType = NV2080_ENGINE_TYPE_COPY0 + oclass->engine->subdev.inst;
72+
73+
return nvkm_gsp_rm_alloc_wr(&obj->rm, args);
74+
}
75+
76+
static void *
77+
r535_ce_dtor(struct nvkm_engine *engine)
78+
{
79+
kfree(engine->func);
80+
return engine;
81+
}
82+
83+
int
84+
r535_ce_new(const struct nvkm_engine_func *hw, struct nvkm_device *device,
85+
enum nvkm_subdev_type type, int inst, struct nvkm_engine **pengine)
86+
{
87+
struct nvkm_engine_func *rm;
88+
int nclass, ret;
89+
90+
for (nclass = 0; hw->sclass[nclass].oclass; nclass++);
91+
92+
if (!(rm = kzalloc(sizeof(*rm) + (nclass + 1) * sizeof(rm->sclass[0]), GFP_KERNEL)))
93+
return -ENOMEM;
94+
95+
rm->dtor = r535_ce_dtor;
96+
for (int i = 0; i < nclass; i++) {
97+
rm->sclass[i].minver = hw->sclass[i].minver;
98+
rm->sclass[i].maxver = hw->sclass[i].maxver;
99+
rm->sclass[i].oclass = hw->sclass[i].oclass;
100+
rm->sclass[i].ctor = r535_ce_obj_ctor;
101+
}
102+
103+
ret = nvkm_engine_new_(rm, device, type, inst, true, pengine);
104+
if (ret)
105+
kfree(rm);
106+
107+
return ret;
108+
}

drivers/gpu/drm/nouveau/nvkm/engine/ce/tu102.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ tu102_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
4040
struct nvkm_engine **pengine)
4141
{
4242
if (nvkm_gsp_rm(device->gsp))
43-
return -ENODEV;
43+
return r535_ce_new(&tu102_ce, device, type, inst, pengine);
4444

4545
return nvkm_engine_new_(&tu102_ce, device, type, inst, true, pengine);
4646
}

drivers/gpu/drm/nouveau/nvkm/engine/device/base.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,6 +2758,7 @@ nv192_chipset = {
27582758
.pci = { 0x00000001, gp100_pci_new },
27592759
.timer = { 0x00000001, gk20a_timer_new },
27602760
.vfn = { 0x00000001, ga100_vfn_new },
2761+
.ce = { 0x0000001f, ga102_ce_new },
27612762
.disp = { 0x00000001, ad102_disp_new },
27622763
.dma = { 0x00000001, gv100_dma_new },
27632764
.fifo = { 0x00000001, ga102_fifo_new },
@@ -2778,6 +2779,7 @@ nv193_chipset = {
27782779
.pci = { 0x00000001, gp100_pci_new },
27792780
.timer = { 0x00000001, gk20a_timer_new },
27802781
.vfn = { 0x00000001, ga100_vfn_new },
2782+
.ce = { 0x0000001f, ga102_ce_new },
27812783
.disp = { 0x00000001, ad102_disp_new },
27822784
.dma = { 0x00000001, gv100_dma_new },
27832785
.fifo = { 0x00000001, ga102_fifo_new },
@@ -2798,6 +2800,7 @@ nv194_chipset = {
27982800
.pci = { 0x00000001, gp100_pci_new },
27992801
.timer = { 0x00000001, gk20a_timer_new },
28002802
.vfn = { 0x00000001, ga100_vfn_new },
2803+
.ce = { 0x0000001f, ga102_ce_new },
28012804
.disp = { 0x00000001, ad102_disp_new },
28022805
.dma = { 0x00000001, gv100_dma_new },
28032806
.fifo = { 0x00000001, ga102_fifo_new },
@@ -2818,6 +2821,7 @@ nv196_chipset = {
28182821
.pci = { 0x00000001, gp100_pci_new },
28192822
.timer = { 0x00000001, gk20a_timer_new },
28202823
.vfn = { 0x00000001, ga100_vfn_new },
2824+
.ce = { 0x0000001f, ga102_ce_new },
28212825
.disp = { 0x00000001, ad102_disp_new },
28222826
.dma = { 0x00000001, gv100_dma_new },
28232827
.fifo = { 0x00000001, ga102_fifo_new },
@@ -2838,6 +2842,7 @@ nv197_chipset = {
28382842
.pci = { 0x00000001, gp100_pci_new },
28392843
.timer = { 0x00000001, gk20a_timer_new },
28402844
.vfn = { 0x00000001, ga100_vfn_new },
2845+
.ce = { 0x0000001f, ga102_ce_new },
28412846
.disp = { 0x00000001, ad102_disp_new },
28422847
.dma = { 0x00000001, gv100_dma_new },
28432848
.fifo = { 0x00000001, ga102_fifo_new },

0 commit comments

Comments
 (0)