Skip to content

Commit 142cd60

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/nvdec/r535: initial support
Adds support for allocating VIDEO_DECODER 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 361c3cd commit 142cd60

File tree

16 files changed

+370
-5
lines changed

16 files changed

+370
-5
lines changed

drivers/gpu/drm/nouveau/include/nvif/class.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@
198198

199199
#define NV74_BSP 0x000074b0
200200

201+
#define NVC4B0_VIDEO_DECODER 0x0000c4b0
202+
#define NVC6B0_VIDEO_DECODER 0x0000c6b0
203+
#define NVC7B0_VIDEO_DECODER 0x0000c7b0
204+
#define NVC9B0_VIDEO_DECODER 0x0000c9b0
205+
201206
#define GT212_MSVLD 0x000085b1
202207
#define IGT21A_MSVLD 0x000086b1
203208
#define G98_MSVLD 0x000088b1

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ struct nvkm_nvdec {
1313

1414
int gm107_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
1515
int tu102_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
16+
int ga100_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
1617
int ga102_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
18+
int ad102_nvdec_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvdec **);
1719
#endif

drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080internal.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ typedef struct NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS {
5757

5858
#define NV2080_CTRL_CMD_INTERNAL_STATIC_KGR_GET_CONTEXT_BUFFERS_INFO (0x20800a32) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_STATIC_KGR_GET_CONTEXT_BUFFERS_INFO_PARAMS_MESSAGE_ID" */
5959

60+
typedef struct NV2080_CTRL_INTERNAL_CONSTRUCTED_FALCON_INFO {
61+
NvU32 engDesc;
62+
NvU32 ctxAttr;
63+
NvU32 ctxBufferSize;
64+
NvU32 addrSpaceList;
65+
NvU32 registerBase;
66+
} NV2080_CTRL_INTERNAL_CONSTRUCTED_FALCON_INFO;
67+
#define NV2080_CTRL_CMD_INTERNAL_MAX_CONSTRUCTED_FALCONS 0x40
68+
69+
#define NV2080_CTRL_CMD_INTERNAL_GET_CONSTRUCTED_FALCON_INFO (0x20800a42) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_GET_CONSTRUCTED_FALCON_INFO_PARAMS_MESSAGE_ID" */
70+
71+
typedef struct NV2080_CTRL_INTERNAL_GET_CONSTRUCTED_FALCON_INFO_PARAMS {
72+
NvU32 numConstructedFalcons;
73+
NV2080_CTRL_INTERNAL_CONSTRUCTED_FALCON_INFO constructedFalconsTable[NV2080_CTRL_CMD_INTERNAL_MAX_CONSTRUCTED_FALCONS];
74+
} NV2080_CTRL_INTERNAL_GET_CONSTRUCTED_FALCON_INFO_PARAMS;
75+
6076
#define NV2080_CTRL_CMD_INTERNAL_DISPLAY_WRITE_INST_MEM (0x20800a49) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_DISPLAY_WRITE_INST_MEM_PARAMS_MESSAGE_ID" */
6177

6278
typedef struct NV2080_CTRL_INTERNAL_DISPLAY_WRITE_INST_MEM_PARAMS {

drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/nvos.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ typedef struct
105105
NvP64 pControl NV_ALIGN_BYTES(8); // pControl gives virt addr of control region for PIO channel
106106
} NV50VAIO_CHANNELPIO_ALLOCATION_PARAMETERS;
107107

108+
typedef struct
109+
{
110+
NvU32 size;
111+
NvU32 prohibitMultipleInstances;
112+
NvU32 engineInstance; // Select NVDEC0 or NVDEC1 or NVDEC2
113+
} NV_BSP_ALLOCATION_PARAMETERS;
114+
108115
typedef struct
109116
{
110117
NvU32 index;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434

3535
#define MC_ENGINE_IDX_GSP 49
3636

37+
#define MC_ENGINE_IDX_BSP 64
38+
#define MC_ENGINE_IDX_NVDEC MC_ENGINE_IDX_BSP
39+
#define MC_ENGINE_IDX_NVDEC0 MC_ENGINE_IDX_NVDEC
40+
41+
#define MC_ENGINE_IDX_NVDEC7 71
42+
3743
#define MC_ENGINE_IDX_GR 82
3844
#define MC_ENGINE_IDX_GR0 MC_ENGINE_IDX_GR
3945

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,6 +2592,7 @@ nv170_chipset = {
25922592
.vfn = { 0x00000001, ga100_vfn_new },
25932593
.ce = { 0x000003ff, ga100_ce_new },
25942594
.fifo = { 0x00000001, ga100_fifo_new },
2595+
.nvdec = { 0x0000001f, ga100_nvdec_new },
25952596
};
25962597

25972598
static const struct nvkm_device_chip
@@ -2763,6 +2764,7 @@ nv192_chipset = {
27632764
.dma = { 0x00000001, gv100_dma_new },
27642765
.fifo = { 0x00000001, ga102_fifo_new },
27652766
.gr = { 0x00000001, ad102_gr_new },
2767+
.nvdec = { 0x0000000f, ad102_nvdec_new },
27662768
.sec2 = { 0x00000001, ga102_sec2_new },
27672769
};
27682770

@@ -2785,6 +2787,7 @@ nv193_chipset = {
27852787
.dma = { 0x00000001, gv100_dma_new },
27862788
.fifo = { 0x00000001, ga102_fifo_new },
27872789
.gr = { 0x00000001, ad102_gr_new },
2790+
.nvdec = { 0x0000000f, ad102_nvdec_new },
27882791
.sec2 = { 0x00000001, ga102_sec2_new },
27892792
};
27902793

@@ -2807,6 +2810,7 @@ nv194_chipset = {
28072810
.dma = { 0x00000001, gv100_dma_new },
28082811
.fifo = { 0x00000001, ga102_fifo_new },
28092812
.gr = { 0x00000001, ad102_gr_new },
2813+
.nvdec = { 0x0000000f, ad102_nvdec_new },
28102814
.sec2 = { 0x00000001, ga102_sec2_new },
28112815
};
28122816

@@ -2829,6 +2833,7 @@ nv196_chipset = {
28292833
.dma = { 0x00000001, gv100_dma_new },
28302834
.fifo = { 0x00000001, ga102_fifo_new },
28312835
.gr = { 0x00000001, ad102_gr_new },
2836+
.nvdec = { 0x0000000f, ad102_nvdec_new },
28322837
.sec2 = { 0x00000001, ga102_sec2_new },
28332838
};
28342839

@@ -2851,6 +2856,7 @@ nv197_chipset = {
28512856
.dma = { 0x00000001, gv100_dma_new },
28522857
.fifo = { 0x00000001, ga102_fifo_new },
28532858
.gr = { 0x00000001, ad102_gr_new },
2859+
.nvdec = { 0x0000000f, ad102_nvdec_new },
28542860
.sec2 = { 0x00000001, ga102_sec2_new },
28552861
};
28562862

drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include <nvrm/535.54.03/common/sdk/nvidia/inc/class/cl2080_notification.h>
3939
#include <nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080ce.h>
4040
#include <nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080fifo.h>
41+
#include <nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080gpu.h>
42+
#include <nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080internal.h>
4143
#include <nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrla06f/ctrla06fgpfifo.h>
4244
#include <nvrm/535.54.03/nvidia/generated/g_kernel_channel_nvoc.h>
4345
#include <nvrm/535.54.03/nvidia/generated/g_kernel_fifo_nvoc.h>
@@ -378,6 +380,58 @@ r535_gr = {
378380
.ctor2 = r535_gr_ctor,
379381
};
380382

383+
static int
384+
r535_flcn_bind(struct nvkm_engn *engn, struct nvkm_vctx *vctx, struct nvkm_chan *chan)
385+
{
386+
struct nvkm_gsp_client *client = &chan->vmm->rm.client;
387+
NV2080_CTRL_GPU_PROMOTE_CTX_PARAMS *ctrl;
388+
389+
ctrl = nvkm_gsp_rm_ctrl_get(&chan->vmm->rm.device.subdevice,
390+
NV2080_CTRL_CMD_GPU_PROMOTE_CTX, sizeof(*ctrl));
391+
if (IS_ERR(ctrl))
392+
return PTR_ERR(ctrl);
393+
394+
ctrl->hClient = client->object.handle;
395+
ctrl->hObject = chan->rm.object.handle;
396+
ctrl->hChanClient = client->object.handle;
397+
ctrl->virtAddress = vctx->vma->addr;
398+
ctrl->size = vctx->inst->size;
399+
ctrl->engineType = engn->id;
400+
ctrl->ChID = chan->id;
401+
402+
return nvkm_gsp_rm_ctrl_wr(&chan->vmm->rm.device.subdevice, ctrl);
403+
}
404+
405+
static int
406+
r535_flcn_ctor(struct nvkm_engn *engn, struct nvkm_vctx *vctx, struct nvkm_chan *chan)
407+
{
408+
int ret;
409+
410+
if (WARN_ON(!engn->rm.size))
411+
return -EINVAL;
412+
413+
ret = nvkm_gpuobj_new(engn->engine->subdev.device, engn->rm.size, 0, true, NULL,
414+
&vctx->inst);
415+
if (ret)
416+
return ret;
417+
418+
ret = nvkm_vmm_get(vctx->vmm, 12, vctx->inst->size, &vctx->vma);
419+
if (ret)
420+
return ret;
421+
422+
ret = nvkm_memory_map(vctx->inst, 0, vctx->vmm, vctx->vma, NULL, 0);
423+
if (ret)
424+
return ret;
425+
426+
return r535_flcn_bind(engn, vctx, chan);
427+
}
428+
429+
static const struct nvkm_engn_func
430+
r535_flcn = {
431+
.nonstall = r535_engn_nonstall,
432+
.ctor2 = r535_flcn_ctor,
433+
};
434+
381435
static void
382436
r535_runl_allow(struct nvkm_runl *runl, u32 engm)
383437
{
@@ -447,6 +501,36 @@ r535_fifo_engn_type(RM_ENGINE_TYPE rm, enum nvkm_subdev_type *ptype)
447501
}
448502
}
449503

504+
static int
505+
r535_fifo_ectx_size(struct nvkm_fifo *fifo)
506+
{
507+
NV2080_CTRL_INTERNAL_GET_CONSTRUCTED_FALCON_INFO_PARAMS *ctrl;
508+
struct nvkm_gsp *gsp = fifo->engine.subdev.device->gsp;
509+
struct nvkm_runl *runl;
510+
struct nvkm_engn *engn;
511+
512+
ctrl = nvkm_gsp_rm_ctrl_rd(&gsp->internal.device.subdevice,
513+
NV2080_CTRL_CMD_INTERNAL_GET_CONSTRUCTED_FALCON_INFO,
514+
sizeof(*ctrl));
515+
if (WARN_ON(IS_ERR(ctrl)))
516+
return PTR_ERR(ctrl);
517+
518+
for (int i = 0; i < ctrl->numConstructedFalcons; i++) {
519+
nvkm_runl_foreach(runl, fifo) {
520+
nvkm_runl_foreach_engn(engn, runl) {
521+
if (engn->rm.desc == ctrl->constructedFalconsTable[i].engDesc) {
522+
engn->rm.size =
523+
ctrl->constructedFalconsTable[i].ctxBufferSize;
524+
break;
525+
}
526+
}
527+
}
528+
}
529+
530+
nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, ctrl);
531+
return 0;
532+
}
533+
450534
static int
451535
r535_fifo_runl_ctor(struct nvkm_fifo *fifo)
452536
{
@@ -511,6 +595,9 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo)
511595
case NVKM_ENGINE_GR:
512596
engn = nvkm_runl_add(runl, nv2080, &r535_gr, type, inst);
513597
break;
598+
case NVKM_ENGINE_NVDEC:
599+
engn = nvkm_runl_add(runl, nv2080, &r535_flcn, type, inst);
600+
break;
514601
case NVKM_ENGINE_SW:
515602
continue;
516603
default:
@@ -522,6 +609,8 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo)
522609
nvkm_runl_del(runl);
523610
continue;
524611
}
612+
613+
engn->rm.desc = ctrl->entries[i].engineData[ENGINE_INFO_TYPE_ENG_DESC];
525614
}
526615

527616
nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, ctrl);
@@ -540,7 +629,7 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo)
540629
nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, ctrl);
541630
}
542631

543-
return 0;
632+
return r535_fifo_ectx_size(fifo);
544633
}
545634

546635
static void

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ struct nvkm_engn {
2929

3030
int fault;
3131

32+
struct {
33+
u32 desc;
34+
u32 size;
35+
} rm;
36+
3237
struct list_head head;
3338
};
3439

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
nvkm-y += nvkm/engine/nvdec/base.o
33
nvkm-y += nvkm/engine/nvdec/gm107.o
44
nvkm-y += nvkm/engine/nvdec/tu102.o
5+
nvkm-y += nvkm/engine/nvdec/ga100.o
56
nvkm-y += nvkm/engine/nvdec/ga102.o
7+
nvkm-y += nvkm/engine/nvdec/ad102.o
8+
9+
nvkm-y += nvkm/engine/nvdec/r535.o
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 <subdev/gsp.h>
25+
26+
#include <nvif/class.h>
27+
28+
static const struct nvkm_engine_func
29+
ad102_nvdec = {
30+
.sclass = {
31+
{ -1, -1, NVC9B0_VIDEO_DECODER },
32+
{}
33+
}
34+
};
35+
36+
int
37+
ad102_nvdec_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
38+
struct nvkm_nvdec **pnvdec)
39+
{
40+
if (nvkm_gsp_rm(device->gsp))
41+
return r535_nvdec_new(&ad102_nvdec, device, type, inst, pnvdec);
42+
43+
return -ENODEV;
44+
}

0 commit comments

Comments
 (0)