drm/nouveau: initial support for GSP-RM 535.54.04 (and Ada GPUs)
Subsystems (4)
PATCH 40/44 drm/nouveau/gr/r535: initial support
In reply to Ben SkeggsFrom: Ben Skeggs <[email protected]>
Adds support for allocating GR classes from RM.
--- drivers/gpu/drm/nouveau/include/nvif/class.h | 3 + .../drm/nouveau/include/nvkm/engine/fifo.h | 1 + .../gpu/drm/nouveau/include/nvkm/engine/gr.h | 1 + .../gpu/drm/nouveau/include/nvkm/subdev/gsp.h | 5 + .../nvidia/inc/ctrl/ctrl0080/ctrl0080fifo.h | 57 ++ .../nvidia/inc/ctrl/ctrl2080/ctrl2080gpu.h | 42 ++ .../inc/ctrl/ctrl2080/ctrl2080internal.h | 19 + .../nvidia/inc/kernel/gpu/intr/engine_idx.h | 3 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 5 + .../gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 34 ++ drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild | 3 + .../gpu/drm/nouveau/nvkm/engine/gr/ad102.c | 46 ++ .../gpu/drm/nouveau/nvkm/engine/gr/ga102.c | 2 +- .../gpu/drm/nouveau/nvkm/engine/gr/gf100.h | 2 + drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c | 508 ++++++++++++++++++ .../gpu/drm/nouveau/nvkm/engine/gr/tu102.c | 2 +- .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 11 + 17 files changed, 742 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl0080/ctrl0080fifo.h create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/gr/ad102.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c
drivers/gpu/drm/nouveau/include/nvif/class.h +3 -0
@@ -194,6 +194,8 @@#define AMPERE_B /* cl9097.h */ 0x0000c797 +#define ADA_A /* cl9097.h */ 0x0000c997 +#define NV74_BSP 0x000074b0#define GT212_MSVLD 0x000085b1
@@ -239,6 +241,7 @@#define VOLTA_COMPUTE_A 0x0000c3c0#define TURING_COMPUTE_A 0x0000c5c0#define AMPERE_COMPUTE_B 0x0000c7c0 +#define ADA_COMPUTE_A 0x0000c9c0#define NV74_CIPHER 0x000074c1#endif
drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h +1 -0
@@ -42,6 +42,7 @@ struct nvkm_chan {dma_addr_t addr;void *ptr; } mthdbuf; +struct nvkm_vctx *grctx; } rm;struct list_head cctxs;
drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h +1 -0
@@ -55,4 +55,5 @@ int gp10b_gr_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nint gv100_gr_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_gr **);int tu102_gr_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_gr **);int ga102_gr_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_gr **); +int ad102_gr_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_gr **);#endif
drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h +5 -0
@@ -176,6 +176,11 @@ struct nvkm_gsp {u64 rm_bar2_pdb; } bar; +struct { +u8 gpcs; +u8 tpcs; + } gr; + const struct nvkm_gsp_rm { void *(*rpc_get)(struct nvkm_gsp *, u32 fn, u32 argc); void *(*rpc_push)(struct nvkm_gsp *, void *argv, bool wait, u32 repc);
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl0080/ctrl0080fifo.h new file +57 -0
57 lines not on this page · raw message
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080gpu.h +42 -0
48 lines not on this page · raw message
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080internal.h +19 -0
@@ -38,6 +38,25 @@ typedef struct NV2080_CTRL_INTERNAL_DISPLAY_GET_STATIC_INFO_PARAMS {NvU32 internalDispActiveMask; }NV2080_CTRL_INTERNAL_DISPLAY_GET_STATIC_INFO_PARAMS ; +#define NV2080_CTRL_INTERNAL_GR_MAX_ENGINES 8 + +#define NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_COUNT 0x19 + +typedef struct NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_BUFFER_INFO { +NvU32 size; +NvU32 alignment; +}NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_BUFFER_INFO ; + +typedef struct NV2080_CTRL_INTERNAL_STATIC_GR_CONTEXT_BUFFERS_INFO { +NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_BUFFER_INFO engine[NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_COUNT ]; +}NV2080_CTRL_INTERNAL_STATIC_GR_CONTEXT_BUFFERS_INFO ; + +typedef struct NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS { +NV2080_CTRL_INTERNAL_STATIC_GR_CONTEXT_BUFFERS_INFO engineContextBuffersInfo[NV2080_CTRL_INTERNAL_GR_MAX_ENGINES ]; +}NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS ; + +#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" */ +#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" */ typedef struct NV2080_CTRL_INTERNAL_DISPLAY_WRITE_INST_MEM_PARAMS {
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h +3 -0
@@ -34,4 +34,7 @@#define MC_ENGINE_IDX_GSP 49 +#define MC_ENGINE_IDX_GR 82 +#define MC_ENGINE_IDX_GR0 MC_ENGINE_IDX_GR +#endif
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +5 -0
@@ -2762,6 +2762,7 @@ nv192_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2783,6 +2784,7 @@ nv193_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2804,6 +2806,7 @@ nv194_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2825,6 +2828,7 @@ nv196_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2846,6 +2850,7 @@ nv197_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +34 -0
@@ -29,6 +29,7 @@#include <subdev/gsp.h> #include <subdev/mmu.h> #include <subdev/vfn.h> +#include <engine/gr.h> #include <nvhw/drf.h>
@@ -67,6 +68,8 @@ r535_chan_ramfc_clear(struct nvkm_chan *chan)dma_free_coherent (fifo->engine.subdev.device->dev, fifo->rm.mthdbuf_size, chan->rm.mthdbuf.ptr, chan->rm.mthdbuf.addr); + +nvkm_cgrp_vctx_put (chan->cgrp, &chan->rm.grctx); }#define CHID_PER_USERD 8
@@ -76,12 +79,19 @@ r535_chan_ramfc_write(struct nvkm_chan *chan, u64 offset, u64 length, u32 devm, {struct nvkm_fifo *fifo = chan->cgrp->runl->fifo;struct nvkm_engn *engn; +struct nvkm_device *device = fifo->engine.subdev.device;NV_CHANNELGPFIFO_ALLOCATION_PARAMETERS *args;const int userd_p = chan->id /CHID_PER_USERD ;const int userd_i = chan->id %CHID_PER_USERD ;u32 eT = ~0 ;int ret; +if (unlikely (device->gr && !device->gr->engine.subdev.oneinit)) { + ret =nvkm_subdev_oneinit (&device->gr->engine.subdev); +if (ret) +return ret; + } + nvkm_runl_foreach_engn(engn, chan->cgrp->runl) { eT = engn->id;break ;
@@ -347,6 +357,27 @@ r535_ce = { .nonstall = r535_engn_nonstall, }; +static int +r535_gr_ctor (struct nvkm_engn *engn,struct nvkm_vctx *vctx,struct nvkm_chan *chan) +{ +/* RM requires GR context buffers to remain mapped until after the +* channel has been destroyed (as opposed to after the last gr obj +* has been deleted). +* +* Take an extra ref here, which will be released once the channel +* object has been deleted. +*/ +refcount_inc (&vctx->refs); + chan->rm.grctx = vctx; +return 0 ; +} + +static const struct nvkm_engn_func +r535_gr = { + .nonstall = r535_engn_nonstall, + .ctor2 = r535_gr_ctor, +}; +static void r535_runl_allow (struct nvkm_runl *runl,u32 engm) {
@@ -477,6 +508,9 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo)case NVKM_ENGINE_CE : engn =nvkm_runl_add (runl, nv2080, &r535_ce, type, inst);break ; +case NVKM_ENGINE_GR : + engn =nvkm_runl_add (runl, nv2080, &r535_gr, type, inst); +break ;case NVKM_ENGINE_SW :continue ;default :
drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild +3 -0
@@ -41,6 +41,9 @@ nvkm-y += nvkm/engine/gr/gp10b.o nvkm-y += nvkm/engine/gr/gv100.o nvkm-y += nvkm/engine/gr/tu102.o nvkm-y += nvkm/engine/gr/ga102.o +nvkm-y += nvkm/engine/gr/ad102.o + +nvkm-y += nvkm/engine/gr/r535.o nvkm-y += nvkm/engine/gr/ctxnv40.o nvkm-y += nvkm/engine/gr/ctxnv50.o
drivers/gpu/drm/nouveau/nvkm/engine/gr/ad102.c new file +46 -0
46 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/gr/ga102.c +1 -1
@@ -352,7 +352,7 @@ int ga102_gr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_gr **pgr) { if (nvkm_gsp_rm(device->gsp)) - return -ENODEV; + return r535_gr_new(&ga102_gr, device, type, inst, pgr);return gf100_gr_new_ (ga102_gr_fwif, device, type, inst, pgr); }
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h +2 -0
@@ -445,4 +445,6 @@ void gp108_gr_acr_bld_patch(struct nvkm_acr *, u32, s64);int gf100_gr_new_ (const struct gf100_gr_fwif *,struct nvkm_device *,enum nvkm_subdev_type ,int ,struct nvkm_gr **); +int r535_gr_new (const struct gf100_gr_func *,struct nvkm_device *,enum nvkm_subdev_type ,int , +struct nvkm_gr **);#endif
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +508 -0
508 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/gr/tu102.c +1 -1
@@ -219,7 +219,7 @@ int tu102_gr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_gr **pgr) { if (nvkm_gsp_rm(device->gsp)) - return -ENODEV; + return r535_gr_new(&tu102_gr, device, type, inst, pgr);return gf100_gr_new_ (tu102_gr_fwif, device, type, inst, pgr); }
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +11 -0
@@ -855,6 +855,10 @@ r535_gsp_intr_get_table(struct nvkm_gsp *gsp) type =NVKM_ENGINE_CE ; inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_CE0 ;break ; +case MC_ENGINE_IDX_GR0 : + type =NVKM_ENGINE_GR ; + inst =0 ; +break ;default :continue ; }
@@ -930,6 +934,13 @@ r535_gsp_rpc_get_gsp_static_info(struct nvkm_gsp *gsp) gsp->fb.rsvd_size = gsp->fb.heap.addr - rsvd_base; } +for (int gpc =0 ; gpc <ARRAY_SIZE (rpc->tpcInfo); gpc++) { +if (rpc->gpcInfo.gpcMask &BIT (gpc)) { + gsp->gr.tpcs +=hweight32 (rpc->tpcInfo[gpc].tpcMask); + gsp->gr.gpcs++; + } + } +nvkm_gsp_rpc_done (gsp, rpc);return 0 ; }
Signature · 1 line
2.41.0
Re: [Nouveau] [PATCH 40/44] drm/nouveau/gr/r535: initial support
Quoted 335 lines · Ben Skeggs
From: Ben Skeggs <[email protected]>
Adds support for allocating GR classes from RM.
Signed-off-by Ben Skeggs <[email protected]>--- drivers/gpu/drm/nouveau/include/nvif/class.h | 3 + .../drm/nouveau/include/nvkm/engine/fifo.h | 1 + .../gpu/drm/nouveau/include/nvkm/engine/gr.h | 1 + .../gpu/drm/nouveau/include/nvkm/subdev/gsp.h | 5 + .../nvidia/inc/ctrl/ctrl0080/ctrl0080fifo.h | 57 ++ .../nvidia/inc/ctrl/ctrl2080/ctrl2080gpu.h | 42 ++ .../inc/ctrl/ctrl2080/ctrl2080internal.h | 19 + .../nvidia/inc/kernel/gpu/intr/engine_idx.h | 3 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 5 + .../gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 34 ++ drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild | 3 + .../gpu/drm/nouveau/nvkm/engine/gr/ad102.c | 46 ++ .../gpu/drm/nouveau/nvkm/engine/gr/ga102.c | 2 +- .../gpu/drm/nouveau/nvkm/engine/gr/gf100.h | 2 + drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c | 508 ++++++++++++++++++ .../gpu/drm/nouveau/nvkm/engine/gr/tu102.c | 2 +- .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 11 + 17 files changed, 742 insertions(+), 2 deletions(-)create mode 100644
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl0080/ctrl0080fifo.hcreate mode 100644drivers/gpu/drm/nouveau/nvkm/engine/gr/ad102.c
create mode 100644drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.cdrivers/gpu/drm/nouveau/include/nvif/class.h +3
-0@@ -194,6 +194,8 @@#define AMPERE_B /* cl9097.h */ 0x0000c797 +#define ADA_A /* cl9097.h */ 0x0000c997 +#define NV74_BSP 0x000074b0#define GT212_MSVLD 0x000085b1@@ -239,6 +241,7 @@#define VOLTA_COMPUTE_A 0x0000c3c0#define TURING_COMPUTE_A 0x0000c5c0#define AMPERE_COMPUTE_B 0x0000c7c0 +#define ADA_COMPUTE_A 0x0000c9c0#define NV74_CIPHER 0x000074c1#endif drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h +1
-0@@ -42,6 +42,7 @@ struct nvkm_chan {dma_addr_t addr;void *ptr; } mthdbuf; +struct nvkm_vctx *grctx; } rm;struct list_head cctxs;drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h +1
-0@@ -55,4 +55,5 @@ int gp10b_gr_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nint gv100_gr_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_gr **);int tu102_gr_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_gr **);int ga102_gr_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_gr **); +int ad102_gr_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_gr **);#endif drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h +5
-0@@ -176,6 +176,11 @@ struct nvkm_gsp {u64 rm_bar2_pdb; } bar; +struct { +u8 gpcs; +u8 tpcs; + } gr; + const struct nvkm_gsp_rm { void *(*rpc_get)(struct nvkm_gsp *, u32 fn, u32 argc); void *(*rpc_push)(struct nvkm_gsp *, void *argv, bool wait, u32 repc);drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl0080/ctrl0080fifo.h new file +57
-0@@ -0,0 +1,57 @@ +#ifndef __src_common_sdk_nvidia_inc_ctrl_ctrl0080_ctrl0080fifo_h__ +#define __src_common_sdk_nvidia_inc_ctrl_ctrl0080_ctrl0080fifo_h__ + +/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */ + +/* +* SPDX-FileCopyrightText: Copyright (c) 2006-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +* SPDX-License-Identifier: MIT +* +* 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 AUTHORS OR COPYRIGHT HOLDERS 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 NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID 4:0 +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS (0x00000000) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_VLD (0x00000001) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_VIDEO (0x00000002) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_MPEG (0x00000003) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_CAPTURE (0x00000004) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_DISPLAY (0x00000005) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_ENCRYPTION (0x00000006) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_POSTPROCESS (0x00000007) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_ZCULL (0x00000008) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_PM (0x00000009) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_COMPUTE_PREEMPT (0x0000000a) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_PREEMPT (0x0000000b) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_SPILL (0x0000000c) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_PAGEPOOL (0x0000000d) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_BETACB (0x0000000e) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_RTV (0x0000000f) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_PATCH (0x00000010) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_BUNDLE_CB (0x00000011) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_PAGEPOOL_GLOBAL (0x00000012) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_ATTRIBUTE_CB (0x00000013) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_RTV_CB_GLOBAL (0x00000014) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_GFXP_POOL (0x00000015) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_GFXP_CTRL_BLK (0x00000016) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_FECS_EVENT (0x00000017) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_GRAPHICS_PRIV_ACCESS_MAP (0x00000018) +#define NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_COUNT (0x00000019) + +#endif drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080gpu.h +42
-0@@ -32,6 +32,48 @@#define NV2080_CTRL_GPU_SET_POWER_STATE_GPU_LEVEL_3 (0x00000003U) +typedef struct NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ENTRY { + NV_DECLARE_ALIGNED(NvU64 gpuPhysAddr, 8); + NV_DECLARE_ALIGNED(NvU64 gpuVirtAddr, 8); + NV_DECLARE_ALIGNED(NvU64 size, 8); +NvU32 physAttr; +NvU16 bufferId; +NvU8 bInitialize; +NvU8 bNonmapped; +}NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ENTRY ; + +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_MAIN 0U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_PM 1U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_PATCH 2U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_BUFFER_BUNDLE_CB 3U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_PAGEPOOL 4U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_ATTRIBUTE_CB 5U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_RTV_CB_GLOBAL 6U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_GFXP_POOL 7U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_GFXP_CTRL_BLK 8U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_FECS_EVENT 9U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_PRIV_ACCESS_MAP 10U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_UNRESTRICTED_PRIV_ACCESS_MAP 11U +#define NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_GLOBAL_PRIV_ACCESS_MAP 12U + +#define NV2080_CTRL_GPU_PROMOTE_CONTEXT_MAX_ENTRIES 16U + +#define NV2080_CTRL_CMD_GPU_PROMOTE_CTX (0x2080012bU)/* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_GPU_INTERFACE_ID << 8) | NV2080_CTRL_GPU_PROMOTE_CTX_PARAMS_MESSAGE_ID" */ + +typedef struct NV2080_CTRL_GPU_PROMOTE_CTX_PARAMS { +NvU32 engineType; +NvHandle hClient; +NvU32 ChID; +NvHandle hChanClient; +NvHandle hObject; +NvHandle hVirtMemory; + NV_DECLARE_ALIGNED(NvU64 virtAddress, 8); + NV_DECLARE_ALIGNED(NvU64 size, 8); +NvU32 entryCount; +// C form: NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ENTRY promoteEntry[NV2080_CTRL_GPU_PROMOTE_CONTEXT_MAX_ENTRIES]; + NV_DECLARE_ALIGNED(NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ENTRY promoteEntry[NV2080_CTRL_GPU_PROMOTE_CONTEXT_MAX_ENTRIES], 8); +}NV2080_CTRL_GPU_PROMOTE_CTX_PARAMS ; +typedef struct NV2080_CTRL_GPU_GET_FERMI_GPC_INFO_PARAMS {NvU32 gpcMask; }NV2080_CTRL_GPU_GET_FERMI_GPC_INFO_PARAMS ;drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080internal.h +19
-0@@ -38,6 +38,25 @@ typedef struct NV2080_CTRL_INTERNAL_DISPLAY_GET_STATIC_INFO_PARAMS {NvU32 internalDispActiveMask; }NV2080_CTRL_INTERNAL_DISPLAY_GET_STATIC_INFO_PARAMS ; +#define NV2080_CTRL_INTERNAL_GR_MAX_ENGINES 8 + +#define NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_COUNT 0x19 + +typedef struct NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_BUFFER_INFO { +NvU32 size; +NvU32 alignment; +}NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_BUFFER_INFO ; + +typedef struct NV2080_CTRL_INTERNAL_STATIC_GR_CONTEXT_BUFFERS_INFO { +NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_BUFFER_INFO engine[NV2080_CTRL_INTERNAL_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_COUNT ]; +}NV2080_CTRL_INTERNAL_STATIC_GR_CONTEXT_BUFFERS_INFO ; + +typedef struct NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS { +NV2080_CTRL_INTERNAL_STATIC_GR_CONTEXT_BUFFERS_INFO engineContextBuffersInfo[NV2080_CTRL_INTERNAL_GR_MAX_ENGINES ]; +}NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS ; + +#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" */ +#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" */ typedef struct NV2080_CTRL_INTERNAL_DISPLAY_WRITE_INST_MEM_PARAMS {drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h +3
-0@@ -34,4 +34,7 @@#define MC_ENGINE_IDX_GSP 49 +#define MC_ENGINE_IDX_GR 82 +#define MC_ENGINE_IDX_GR0 MC_ENGINE_IDX_GR +#endif drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +5
-0@@ -2762,6 +2762,7 @@ nv192_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };@@ -2783,6 +2784,7 @@ nv193_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };@@ -2804,6 +2806,7 @@ nv194_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };@@ -2825,6 +2828,7 @@ nv196_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };@@ -2846,6 +2850,7 @@ nv197_chipset = { .disp = { 0x00000001, ad102_disp_new }, .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, + .gr = { 0x00000001, ad102_gr_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +11
-0@@ -29,6 +29,7 @@#include <subdev/gsp.h> #include <subdev/mmu.h> #include <subdev/vfn.h> +#include <engine/gr.h> #include <nvhw/drf.h> @@ -67,6 +68,8 @@ r535_chan_ramfc_clear(struct nvkm_chan *chan)dma_free_coherent (fifo->engine.subdev.device->dev, fifo->rm.mthdbuf_size, chan->rm.mthdbuf.ptr, chan->rm.mthdbuf.addr); + +nvkm_cgrp_vctx_put (chan->cgrp, &chan->rm.grctx); }#define CHID_PER_USERD 8@@ -76,12 +79,19 @@ r535_chan_ramfc_write(struct nvkm_chan *chan, u64 offset, u64 length, u32 devm, {struct nvkm_fifo *fifo = chan->cgrp->runl->fifo;struct nvkm_engn *engn; +struct nvkm_device *device = fifo->engine.subdev.device;NV_CHANNELGPFIFO_ALLOCATION_PARAMETERS *args;const int userd_p = chan->id /CHID_PER_USERD ;const int userd_i = chan->id %CHID_PER_USERD ;u32 eT = ~0 ;int ret; +if (unlikely (device->gr && !device->gr->engine.subdev.oneinit)) { + ret =nvkm_subdev_oneinit (&device->gr->engine.subdev); +if (ret) +return ret; + } + nvkm_runl_foreach_engn(engn, chan->cgrp->runl) { eT = engn->id;break ;@@ -347,6 +357,27 @@ r535_ce = { .nonstall = r535_engn_nonstall, }; +static int
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c r535_ce = { · line 370
Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +10
-0+r535_gr_ctor(struct nvkm_engn *engn, struct nvkm_vctx *vctx, struct nvkm_chan *chan) +{ +/* RM requires GR context buffers to remain mapped until after the +* channel has been destroyed (as opposed to after the last gr obj +* has been deleted). +* +* Take an extra ref here, which will be released once the channel +* object has been deleted. +*/ + refcount_inc(&vctx->refs);
The corresponding decrement doesn't seem to be in this patch, which seems unexpected.
Quoted 196 lines
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +13
-0+ chan->rm.grctx = vctx; +return 0 ; +} + +static const struct nvkm_engn_func +r535_gr = { + .nonstall = r535_engn_nonstall, + .ctor2 = r535_gr_ctor, +}; +static void r535_runl_allow (struct nvkm_runl *runl,u32 engm) {@@ -477,6 +508,9 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo)case NVKM_ENGINE_CE : engn =nvkm_runl_add (runl, nv2080, &r535_ce, type, inst);break ; +case NVKM_ENGINE_GR : + engn =nvkm_runl_add (runl, nv2080, &r535_gr, type, inst); +break ;case NVKM_ENGINE_SW :continue ;default :drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild +3
-0@@ -41,6 +41,9 @@ nvkm-y += nvkm/engine/gr/gp10b.o nvkm-y += nvkm/engine/gr/gv100.o nvkm-y += nvkm/engine/gr/tu102.o nvkm-y += nvkm/engine/gr/ga102.o +nvkm-y += nvkm/engine/gr/ad102.o + +nvkm-y += nvkm/engine/gr/r535.o nvkm-y += nvkm/engine/gr/ctxnv40.o nvkm-y += nvkm/engine/gr/ctxnv50.odrivers/gpu/drm/nouveau/nvkm/engine/gr/ad102.c new file +46
-0@@ -0,0 +1,46 @@ +/* +* Copyright 2023 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 "gf100.h" + +#include <subdev/gsp.h> + +#include <nvif/class.h> + +static const struct gf100_gr_func +ad102_gr = { + .sclass = { + {-1 ,-1 ,FERMI_TWOD_A }, + {-1 ,-1 ,KEPLER_INLINE_TO_MEMORY_B }, + {-1 ,-1 ,ADA_A }, + {-1 ,-1 ,ADA_COMPUTE_A }, + {} + } +}; + +int +ad102_gr_new (struct nvkm_device *device,enum nvkm_subdev_type type,int inst,struct nvkm_gr **pgr) +{ +if (nvkm_gsp_rm (device->gsp)) +return r535_gr_new (&ad102_gr, device, type, inst, pgr); + +return -ENODEV ; +}drivers/gpu/drm/nouveau/nvkm/engine/gr/ga102.c +1
-1@@ -352,7 +352,7 @@ int ga102_gr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_gr **pgr) { if (nvkm_gsp_rm(device->gsp)) - return -ENODEV; + return r535_gr_new(&ga102_gr, device, type, inst, pgr);return gf100_gr_new_ (ga102_gr_fwif, device, type, inst, pgr); }drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h +2
-0@@ -445,4 +445,6 @@ void gp108_gr_acr_bld_patch(struct nvkm_acr *, u32, s64);int gf100_gr_new_ (const struct gf100_gr_fwif *,struct nvkm_device *,enum nvkm_subdev_type ,int ,struct nvkm_gr **); +int r535_gr_new (const struct gf100_gr_func *,struct nvkm_device *,enum nvkm_subdev_type ,int , +struct nvkm_gr **);#endif drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +77
-0@@ -0,0 +1,508 @@ +/* +* Copyright 2023 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 "gf100.h" + +#include <core/memory.h> +#include <subdev/gsp.h> +#include <subdev/mmu/vmm.h> +#include <engine/fifo/priv.h> + +#include <nvif/if900d.h> + +#include <nvhw/drf.h> + +#include <nvrm/nvtypes.h> +#include <nvrm/535.54.03/common/sdk/nvidia/inc/alloc/alloc_channel.h> +#include <nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl0080/ctrl0080fifo.h> +#include <nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080gpu.h> +#include <nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080internal.h> +#include <nvrm/535.54.03/nvidia/generated/g_kernel_channel_nvoc.h> + +#define r535_gr (p) container_of((p), struct r535_gr, base) + +#define R515_GR_MAX_CTXBUFS 9 + +struct r535_gr { +struct nvkm_gr base; + +struct { +u16 bufferId; +u32 size; +u8 page; +u8 align; +bool global; +bool init; +bool ro; + } ctxbuf[R515_GR_MAX_CTXBUFS ]; +int ctxbuf_nr; + +struct nvkm_memory *ctxbuf_mem[R515_GR_MAX_CTXBUFS ]; +}; + +struct r535_gr_chan { +struct nvkm_object object; +struct r535_gr *gr; + +struct nvkm_vmm *vmm; +struct nvkm_chan *chan; + +struct nvkm_memory *mem[R515_GR_MAX_CTXBUFS ]; +struct nvkm_vma *vma[R515_GR_MAX_CTXBUFS ]; +}; + +struct r535_gr_obj { +struct nvkm_object object; +struct nvkm_gsp_object rm; +}; + +static void *
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c line 87
Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +10
-0+r535_gr_obj_dtor(struct nvkm_object *object) +{ +struct r535_gr_obj *obj =container_of (object,typeof (*obj), object); + +nvkm_gsp_rm_free (&obj->rm); +return obj; +} + +static const struct nvkm_object_func +r535_gr_obj = {
Prefer naming this r535_gr_obj_funcs, makes it easier to read the code and leads to more distinct symbol names.
Quoted 8 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +8
-0+ .dtor = r535_gr_obj_dtor, +}; + +static int +r535_gr_obj_ctor (const struct nvkm_oclass *oclass,void *argv,u32 argc, +struct nvkm_object **pobject) +{ +struct r535_gr_chan *chan =container_of (oclass->parent,typeof (*chan), object);
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c line 105
Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +10
-0+struct r535_gr_obj *obj; + +if (!(obj =kzalloc (sizeof (*obj),GFP_KERNEL ))) +return -ENOMEM ; + +nvkm_object_ctor (&r535_gr_obj, oclass, &obj->object); + *pobject = &obj->object; + +return nvkm_gsp_rm_alloc (&chan->chan->rm.object, oclass->handle, oclass->base.oclass,0 , + &obj->rm);
Looks suspicious to return an error here without freeing obj. At a first glance I can't really find where a call to r535_gr_obj_ctor() originates from. This might be another place where the caller must check both ret and *pobject and subsequently must call dtor() or not.
Note: dtor() returns a pointer to the up-casted structure such that nvkm_object_del() can free it.
Quoted 46 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +46
-0+} + +static void * +r535_gr_chan_dtor (struct nvkm_object *object) +{ +struct r535_gr_chan *grc =container_of (object,typeof (*grc), object); +struct r535_gr *gr = grc->gr; + +for (int i =0 ; i < gr->ctxbuf_nr; i++) { +nvkm_vmm_put (grc->vmm, &grc->vma[i]); +nvkm_memory_unref (&grc->mem[i]); + } + +nvkm_vmm_unref (&grc->vmm); +return grc; +} + +static const struct nvkm_object_func +r535_gr_chan = { + .dtor = r535_gr_chan_dtor, +}; + +static int +r535_gr_promote_ctx (struct r535_gr *gr,bool golden,struct nvkm_vmm *vmm, +struct nvkm_memory **pmem,struct nvkm_vma **pvma, +struct nvkm_gsp_object *chan) +{ +struct nvkm_subdev *subdev = &gr->base.engine.subdev; +struct nvkm_device *device = subdev->device; +NV2080_CTRL_GPU_PROMOTE_CTX_PARAMS *ctrl; + + ctrl =nvkm_gsp_rm_ctrl_get (&vmm->rm.device.subdevice, +NV2080_CTRL_CMD_GPU_PROMOTE_CTX ,sizeof (*ctrl)); +if (WARN_ON (IS_ERR (ctrl))) +return PTR_ERR (ctrl); + + ctrl->engineType =1 ; + ctrl->hChanClient = vmm->rm.client.object.handle; + ctrl->hObject = chan->handle; + +for (int i =0 ; i < gr->ctxbuf_nr; i++) { +NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ENTRY *entry = + &ctrl->promoteEntry[ctrl->entryCount]; +const bool alloc = golden || !gr->ctxbuf[i].global; +int ret; +
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c line 161
Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +10
-0+ entry->bufferId = gr->ctxbuf[i].bufferId; + entry->bInitialize = gr->ctxbuf[i].init && alloc; + +if (alloc) { + ret =nvkm_memory_new (device, gr->ctxbuf[i].init ? +NVKM_MEM_TARGET_INST :NVKM_MEM_TARGET_INST_SR_LOST , + gr->ctxbuf[i].size,1 << gr->ctxbuf[i].page, + gr->ctxbuf[i].init, &pmem[i]); +if (WARN_ON (ret)) +return ret;
Looks suspicious that we do not have an unwind path in this function. Who cleans up all the allocations?
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c line 171
Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +10
-0+ +if (gr->ctxbuf[i].bufferId == +NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_PRIV_ACCESS_MAP ) + entry->bNonmapped =1 ; + }else { +if (gr->ctxbuf[i].bufferId == +NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_UNRESTRICTED_PRIV_ACCESS_MAP ) +continue ; + + pmem[i] =nvkm_memory_ref (gr->ctxbuf_mem[i]);
And taken references?
Quoted 8 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +8
-0+ } + +if (!entry->bNonmapped) { +struct gf100_vmm_map_v0 args = { + .priv =1 , + .ro = gr->ctxbuf[i].ro, + }; +
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c line 189
Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +10
-0+mutex_lock (&vmm->mutex.vmm); + ret =nvkm_vmm_get_locked (vmm, false, true, false,0 , gr->ctxbuf[i].align, +nvkm_memory_size (pmem[i]), &pvma[i]); +mutex_unlock (&vmm->mutex.vmm); +if (ret) +return ret; + + ret =nvkm_memory_map (pmem[i],0 , vmm, pvma[i], &args,sizeof (args)); +if (ret) +return ret;
How is that cleaned up - on failure, but also in general?
Quoted 361 lines
drivers/gpu/drm/nouveau/nvkm/engine/gr/r535.c new file +319
-0+ + entry->gpuVirtAddr = pvma[i]->addr; + } + +if (entry->bInitialize) { + entry->gpuPhysAddr =nvkm_memory_addr (pmem[i]); + entry->size = gr->ctxbuf[i].size; + entry->physAttr =4 ; + } + +nvkm_debug (subdev, +"promote %02d: pa %016llx/%08x sz %016llx va %016llx init:%d nm:%d\n" , + entry->bufferId, entry->gpuPhysAddr, entry->physAttr, entry->size, + entry->gpuVirtAddr, entry->bInitialize, entry->bNonmapped); + + ctrl->entryCount++; + } + +return nvkm_gsp_rm_ctrl_wr (&vmm->rm.device.subdevice, ctrl); +} + +static int +r535_gr_chan_new (struct nvkm_gr *base,struct nvkm_chan *chan,const struct nvkm_oclass *oclass, +struct nvkm_object **pobject) +{ +struct r535_gr *gr =r535_gr (base); +struct r535_gr_chan *grc; +int ret; + +if (!(grc =kzalloc (sizeof (*grc),GFP_KERNEL ))) +return -ENOMEM ; + +nvkm_object_ctor (&r535_gr_chan, oclass, &grc->object); + grc->gr = gr; + grc->vmm =nvkm_vmm_ref (chan->vmm); + grc->chan = chan; + *pobject = &grc->object; + + ret =r535_gr_promote_ctx (gr, false, grc->vmm, grc->mem, grc->vma, &chan->rm.object); +if (ret) +return ret; + +return 0 ; +} + +static u64 +r535_gr_units (struct nvkm_gr *gr) +{ +struct nvkm_gsp *gsp = gr->engine.subdev.device->gsp; + +return (gsp->gr.tpcs <<8 ) | gsp->gr.gpcs; +} + +static int +r535_gr_oneinit (struct nvkm_gr *base) +{ +NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS *info; +struct r535_gr *gr =container_of (base,typeof (*gr), base); +struct nvkm_subdev *subdev = &gr->base.engine.subdev; +struct nvkm_device *device = subdev->device; +struct nvkm_gsp *gsp = device->gsp; +struct nvkm_mmu *mmu = device->mmu; +struct { +struct nvkm_memory *inst; +struct nvkm_vmm *vmm; +struct nvkm_gsp_object chan; +struct nvkm_vma *vma[R515_GR_MAX_CTXBUFS ]; + } golden = {}; +int ret; + +/* Allocate a channel to use for golden context init. */ + ret =nvkm_memory_new (device,NVKM_MEM_TARGET_INST ,0x12000 ,0 , true, &golden.inst); +if (ret) + goto done; + + ret =nvkm_vmm_new (device,0x1000 ,0 ,NULL ,0 ,NULL ,"grGoldenVmm" , &golden.vmm); +if (ret) + goto done; + + ret = mmu->func->promote_vmm (golden.vmm); +if (ret) + goto done; + + { +NV_CHANNELGPFIFO_ALLOCATION_PARAMETERS *args; + + args =nvkm_gsp_rm_alloc_get (&golden.vmm->rm.device.object,0xf1f00000 , + device->fifo->func->chan.user.oclass, +sizeof (*args), &golden.chan); +if (IS_ERR (args)) { + ret =PTR_ERR (args); + goto done; + } + + args->gpFifoOffset =0 ; + args->gpFifoEntries =0x1000 /8 ; + args->flags = +NVDEF (NVOS04 ,FLAGS ,CHANNEL_TYPE ,PHYSICAL ) | +NVDEF (NVOS04 ,FLAGS ,VPR , FALSE) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_SKIP_MAP_REFCOUNTING , FALSE) | +NVVAL (NVOS04 ,FLAGS ,GROUP_CHANNEL_RUNQUEUE ,0 ) | +NVDEF (NVOS04 ,FLAGS ,PRIVILEGED_CHANNEL , TRUE) | +NVDEF (NVOS04 ,FLAGS ,DELAY_CHANNEL_SCHEDULING , FALSE) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_DENY_PHYSICAL_MODE_CE , FALSE) | +NVVAL (NVOS04 ,FLAGS ,CHANNEL_USERD_INDEX_VALUE ,0 ) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_USERD_INDEX_FIXED , FALSE) | +NVVAL (NVOS04 ,FLAGS ,CHANNEL_USERD_INDEX_PAGE_VALUE ,0 ) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_USERD_INDEX_PAGE_FIXED , TRUE) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_DENY_AUTH_LEVEL_PRIV , FALSE) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_SKIP_SCRUBBER , FALSE) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_CLIENT_MAP_FIFO , FALSE) | +NVDEF (NVOS04 ,FLAGS ,SET_EVICT_LAST_CE_PREFETCH_CHANNEL , FALSE) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_VGPU_PLUGIN_CONTEXT , FALSE) | +NVDEF (NVOS04 ,FLAGS ,CHANNEL_PBDMA_ACQUIRE_TIMEOUT , FALSE) | +NVDEF (NVOS04 ,FLAGS ,GROUP_CHANNEL_THREAD ,DEFAULT ) | +NVDEF (NVOS04 ,FLAGS ,MAP_CHANNEL , FALSE) | +NVDEF (NVOS04 ,FLAGS ,SKIP_CTXBUFFER_ALLOC , FALSE); + args->hVASpace = golden.vmm->rm.object.handle; + args->engineType =1 ; + args->instanceMem.base =nvkm_memory_addr (golden.inst); + args->instanceMem.size =0x1000 ; + args->instanceMem.addressSpace =2 ; + args->instanceMem.cacheAttrib =1 ; + args->ramfcMem.base =nvkm_memory_addr (golden.inst); + args->ramfcMem.size =0x200 ; + args->ramfcMem.addressSpace =2 ; + args->ramfcMem.cacheAttrib =1 ; + args->userdMem.base =nvkm_memory_addr (golden.inst) +0x1000 ; + args->userdMem.size =0x200 ; + args->userdMem.addressSpace =2 ; + args->userdMem.cacheAttrib =1 ; + args->mthdbufMem.base =nvkm_memory_addr (golden.inst) +0x2000 ; + args->mthdbufMem.size =0x5000 ; + args->mthdbufMem.addressSpace =2 ; + args->mthdbufMem.cacheAttrib =1 ; + args->internalFlags = +NVDEF (NV_KERNELCHANNEL ,ALLOC_INTERNALFLAGS ,PRIVILEGE ,ADMIN ) | +NVDEF (NV_KERNELCHANNEL ,ALLOC_INTERNALFLAGS ,ERROR_NOTIFIER_TYPE ,NONE ) | +NVDEF (NV_KERNELCHANNEL ,ALLOC_INTERNALFLAGS ,ECC_ERROR_NOTIFIER_TYPE ,NONE ); + + ret =nvkm_gsp_rm_alloc_wr (&golden.chan, args); +if (ret) + goto done; + } + +/* Fetch context buffer info from RM and allocate each of them here to use +* during golden context init (or later as a global context buffer). +* +* Also build the information that'll be used to create channel contexts. +*/ + info =nvkm_gsp_rm_ctrl_rd (&gsp->internal.device.subdevice, +NV2080_CTRL_CMD_INTERNAL_STATIC_KGR_GET_CONTEXT_BUFFERS_INFO , +sizeof (*info)); +if (WARN_ON (IS_ERR (info))) { + ret =PTR_ERR (info); + goto done; + } + +for (int i =0 ; i <ARRAY_SIZE (info->engineContextBuffersInfo[0 ].engine); i++) { + static const struct { + u32 id0; /* NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID */ + u32 id1; /* NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID */ + bool global; + bool init; + bool ro; + } map[] = { +#define _A(n,N,G,I,R) { .id0 = NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_ENGINE_ID_##n, \ + .id1 = NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_##N, \ + .global = (G), .init = (I), .ro = (R) } +#define _B (N ,G ,I ,R ) _A(GRAPHICS_##N, N, (G), (I), (R)) +/* global init ro */ +_A (GRAPHICS ,MAIN , false, true, false), +_B (PATCH , false, true, false), +_A (GRAPHICS_BUNDLE_CB ,BUFFER_BUNDLE_CB , true, false, false), +_B (PAGEPOOL , true, false, false), +_B (ATTRIBUTE_CB , true, false, false), +_B (RTV_CB_GLOBAL , true, false, false), +_B (FECS_EVENT , true, true, false), +_B (PRIV_ACCESS_MAP , true, true, true), +#undef _B +#undef _A + }; +u32 size = info->engineContextBuffersInfo[0 ].engine[i].size; +u8 align, page; +int id; + +for (id =0 ; id <ARRAY_SIZE (map); id++) { +if (map[id].id0 == i) +break ; + } + +nvkm_debug (subdev,"%02x: size:0x%08x %s\n" , i, + size, (id <ARRAY_SIZE (map)) ?"*" :"" ); +if (id >=ARRAY_SIZE (map)) +continue ; + +if (map[id].id1 ==NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_MAIN ) + size =ALIGN (size,0x1000 ) +64 *0x1000 ;/* per-subctx headers */ + +if (size >=1 <<21 ) page =21 ; +else if (size >=1 <<16 ) page =16 ; +else page =12 ; + +if (map[id].id1 ==NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_ATTRIBUTE_CB ) + align =order_base_2 (size); +else + align = page; + +if (WARN_ON (gr->ctxbuf_nr ==ARRAY_SIZE (gr->ctxbuf))) +continue ; + + gr->ctxbuf[gr->ctxbuf_nr].bufferId = map[id].id1; + gr->ctxbuf[gr->ctxbuf_nr].size = size; + gr->ctxbuf[gr->ctxbuf_nr].page = page; + gr->ctxbuf[gr->ctxbuf_nr].align = align; + gr->ctxbuf[gr->ctxbuf_nr].global = map[id].global; + gr->ctxbuf[gr->ctxbuf_nr].init = map[id].init; + gr->ctxbuf[gr->ctxbuf_nr].ro = map[id].ro; + gr->ctxbuf_nr++; + +if (map[id].id1 ==NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_PRIV_ACCESS_MAP ) { +if (WARN_ON (gr->ctxbuf_nr ==ARRAY_SIZE (gr->ctxbuf))) +continue ; + + gr->ctxbuf[gr->ctxbuf_nr] = gr->ctxbuf[gr->ctxbuf_nr -1 ]; + gr->ctxbuf[gr->ctxbuf_nr].bufferId = +NV2080_CTRL_GPU_PROMOTE_CTX_BUFFER_ID_UNRESTRICTED_PRIV_ACCESS_MAP ; + gr->ctxbuf_nr++; + } + } + +nvkm_gsp_rm_ctrl_done (&gsp->internal.device.subdevice, info); + +/* Promote golden context to RM. */ + ret =r535_gr_promote_ctx (gr, true, golden.vmm, gr->ctxbuf_mem, golden.vma, &golden.chan); +if (ret) + goto done; + +/* Allocate 3D class on channel to trigger golden context init in RM. */ + { +int i; + +for (i =0 ; gr->base.func->sclass[i].ctor; i++) { +if ((gr->base.func->sclass[i].oclass &0xff ) ==0x97 ) { +struct nvkm_gsp_object threed; + + ret =nvkm_gsp_rm_alloc (&golden.chan,0x97000000 , + gr->base.func->sclass[i].oclass,0 , + &threed); +if (ret) + goto done; + +nvkm_gsp_rm_free (&threed); +break ; + } + } + +if (WARN_ON (!gr->base.func->sclass[i].ctor)) { + ret = -EINVAL ; + goto done; + } + } + +done: +nvkm_gsp_rm_free (&golden.chan); +for (int i = gr->ctxbuf_nr -1 ; i >=0 ; i--) +nvkm_vmm_put (golden.vmm, &golden.vma[i]); +nvkm_vmm_unref (&golden.vmm); +nvkm_memory_unref (&golden.inst); +return ret; + +} + +static void * +r535_gr_dtor (struct nvkm_gr *base) +{ +struct r535_gr *gr =r535_gr (base); + +while (gr->ctxbuf_nr) +nvkm_memory_unref (&gr->ctxbuf_mem[--gr->ctxbuf_nr]); + +kfree (gr->base.func); +return gr; +} + +int +r535_gr_new (const struct gf100_gr_func *hw, +struct nvkm_device *device,enum nvkm_subdev_type type,int inst,struct nvkm_gr **pgr) +{ +struct nvkm_gr_func *rm; +struct r535_gr *gr; +int nclass; + +for (nclass =0 ; hw->sclass[nclass].oclass; nclass++); + +if (!(rm =kzalloc (sizeof (*rm) + (nclass +1 ) *sizeof (rm->sclass[0 ]),GFP_KERNEL ))) +return -ENOMEM ; + + rm->dtor = r535_gr_dtor; + rm->oneinit = r535_gr_oneinit; + rm->units = r535_gr_units; + rm->chan_new = r535_gr_chan_new; + +for (int i =0 ; i < nclass; i++) { + rm->sclass[i].minver = hw->sclass[i].minver; + rm->sclass[i].maxver = hw->sclass[i].maxver; + rm->sclass[i].oclass = hw->sclass[i].oclass; + rm->sclass[i].ctor = r535_gr_obj_ctor; + } + +if (!(gr =kzalloc (sizeof (*gr),GFP_KERNEL ))) { +kfree (rm); +return -ENOMEM ; + } + + *pgr = &gr->base; + +return nvkm_gr_ctor (rm, device, type, inst, true, &gr->base); +}drivers/gpu/drm/nouveau/nvkm/engine/gr/tu102.c +1
-1@@ -219,7 +219,7 @@ int tu102_gr_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_gr **pgr) { if (nvkm_gsp_rm(device->gsp)) - return -ENODEV; + return r535_gr_new(&tu102_gr, device, type, inst, pgr);return gf100_gr_new_ (tu102_gr_fwif, device, type, inst, pgr); }drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +11
-0@@ -855,6 +855,10 @@ r535_gsp_intr_get_table(struct nvkm_gsp *gsp) type =NVKM_ENGINE_CE ; inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_CE0 ;break ; +case MC_ENGINE_IDX_GR0 : + type =NVKM_ENGINE_GR ; + inst =0 ; +break ;default :continue ; }@@ -930,6 +934,13 @@ r535_gsp_rpc_get_gsp_static_info(struct nvkm_gsp *gsp) gsp->fb.rsvd_size = gsp->fb.heap.addr - rsvd_base; } +for (int gpc =0 ; gpc <ARRAY_SIZE (rpc->tpcInfo); gpc++) { +if (rpc->gpcInfo.gpcMask &BIT (gpc)) { + gsp->gr.tpcs +=hweight32 (rpc->tpcInfo[gpc].tpcMask); + gsp->gr.gpcs++; + } + } +nvkm_gsp_rpc_done (gsp, rpc);return 0 ; }
PATCH 41/44 drm/nouveau/nvdec/r535: initial support
In reply to Ben SkeggsFrom: Ben Skeggs <[email protected]>
Adds support for allocating VIDEO_DECODER classes from RM.
--- drivers/gpu/drm/nouveau/include/nvif/class.h | 5 + .../drm/nouveau/include/nvkm/engine/nvdec.h | 2 + .../inc/ctrl/ctrl2080/ctrl2080internal.h | 16 +++ .../535.54.03/common/sdk/nvidia/inc/nvos.h | 7 ++ .../nvidia/inc/kernel/gpu/intr/engine_idx.h | 6 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 6 + .../gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 91 ++++++++++++++- .../gpu/drm/nouveau/nvkm/engine/fifo/runl.h | 5 + .../gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild | 4 + .../gpu/drm/nouveau/nvkm/engine/nvdec/ad102.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/nvdec/ga100.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/nvdec/ga102.c | 14 ++- .../gpu/drm/nouveau/nvkm/engine/nvdec/priv.h | 5 + .../gpu/drm/nouveau/nvkm/engine/nvdec/r535.c | 110 ++++++++++++++++++ .../gpu/drm/nouveau/nvkm/engine/nvdec/tu102.c | 12 +- .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 4 + 16 files changed, 370 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvdec/ad102.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvdec/ga100.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvdec/r535.c
drivers/gpu/drm/nouveau/include/nvif/class.h +5 -0
@@ -198,6 +198,11 @@#define NV74_BSP 0x000074b0 +#define NVC4B0_VIDEO_DECODER 0x0000c4b0 +#define NVC6B0_VIDEO_DECODER 0x0000c6b0 +#define NVC7B0_VIDEO_DECODER 0x0000c7b0 +#define NVC9B0_VIDEO_DECODER 0x0000c9b0 +#define GT212_MSVLD 0x000085b1#define IGT21A_MSVLD 0x000086b1#define G98_MSVLD 0x000088b1
drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h +2 -0
@@ -13,5 +13,7 @@ struct nvkm_nvdec {int gm107_nvdec_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvdec **);int tu102_nvdec_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvdec **); +int ga100_nvdec_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvdec **);int ga102_nvdec_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvdec **); +int ad102_nvdec_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvdec **);#endif
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/ctrl/ctrl2080/ctrl2080internal.h +16 -0
@@ -57,6 +57,22 @@ typedef struct NV2080_CTRL_INTERNAL_STATIC_GR_GET_CONTEXT_BUFFERS_INFO_PARAMS {#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" */ +typedef struct NV2080_CTRL_INTERNAL_CONSTRUCTED_FALCON_INFO { +NvU32 engDesc; +NvU32 ctxAttr; +NvU32 ctxBufferSize; +NvU32 addrSpaceList; +NvU32 registerBase; +}NV2080_CTRL_INTERNAL_CONSTRUCTED_FALCON_INFO ; +#define NV2080_CTRL_CMD_INTERNAL_MAX_CONSTRUCTED_FALCONS 0x40 + +#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" */ + +typedef struct NV2080_CTRL_INTERNAL_GET_CONSTRUCTED_FALCON_INFO_PARAMS { +NvU32 numConstructedFalcons; +NV2080_CTRL_INTERNAL_CONSTRUCTED_FALCON_INFO constructedFalconsTable[NV2080_CTRL_CMD_INTERNAL_MAX_CONSTRUCTED_FALCONS ]; +}NV2080_CTRL_INTERNAL_GET_CONSTRUCTED_FALCON_INFO_PARAMS ; +#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" */ 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 +7 -0
@@ -105,6 +105,13 @@ typedef struct NvP64 pControl NV_ALIGN_BYTES(8); // pControl gives virt addr of control region for PIO channel }NV50VAIO_CHANNELPIO_ALLOCATION_PARAMETERS ; +typedef struct +{ +NvU32 size; +NvU32 prohibitMultipleInstances; +NvU32 engineInstance;// Select NVDEC0 or NVDEC1 or NVDEC2 +}NV_BSP_ALLOCATION_PARAMETERS ; + typedef struct { NvU32 index;
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h +6 -0
@@ -34,6 +34,12 @@#define MC_ENGINE_IDX_GSP 49 +#define MC_ENGINE_IDX_BSP 64 +#define MC_ENGINE_IDX_NVDEC MC_ENGINE_IDX_BSP +#define MC_ENGINE_IDX_NVDEC0 MC_ENGINE_IDX_NVDEC + +#define MC_ENGINE_IDX_NVDEC7 71 +#define MC_ENGINE_IDX_GR 82#define MC_ENGINE_IDX_GR0 MC_ENGINE_IDX_GR
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +6 -0
@@ -2592,6 +2592,7 @@ nv170_chipset = { .vfn = { 0x00000001, ga100_vfn_new }, .ce = { 0x000003ff, ga100_ce_new }, .fifo = { 0x00000001, ga100_fifo_new }, + .nvdec = { 0x0000001f, ga100_nvdec_new }, }; static const struct nvkm_device_chip
@@ -2763,6 +2764,7 @@ nv192_chipset = { .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, + .nvdec = { 0x0000000f, ad102_nvdec_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2785,6 +2787,7 @@ nv193_chipset = { .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, + .nvdec = { 0x0000000f, ad102_nvdec_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2807,6 +2810,7 @@ nv194_chipset = { .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, + .nvdec = { 0x0000000f, ad102_nvdec_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2829,6 +2833,7 @@ nv196_chipset = { .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, + .nvdec = { 0x0000000f, ad102_nvdec_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2851,6 +2856,7 @@ nv197_chipset = { .dma = { 0x00000001, gv100_dma_new }, .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, + .nvdec = { 0x0000000f, ad102_nvdec_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +90 -1
127 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/fifo/runl.h +5 -0
@@ -29,6 +29,11 @@ struct nvkm_engn {int fault; +struct { +u32 desc; +u32 size; + } rm; +struct list_head head; };
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild +4 -0
@@ -2,4 +2,8 @@ nvkm-y += nvkm/engine/nvdec/base.o nvkm-y += nvkm/engine/nvdec/gm107.o nvkm-y += nvkm/engine/nvdec/tu102.o +nvkm-y += nvkm/engine/nvdec/ga100.o nvkm-y += nvkm/engine/nvdec/ga102.o +nvkm-y += nvkm/engine/nvdec/ad102.o + +nvkm-y += nvkm/engine/nvdec/r535.o
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/ad102.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/ga100.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/ga102.c +11 -3
@@ -22,8 +22,16 @@#include "priv.h" #include <subdev/gsp.h> -#include <subdev/mc.h> -#include <subdev/timer.h> + +#include <nvif/class.h> + +static const struct nvkm_engine_func +ga102_nvdec_gsp = { + .sclass = { + {-1 ,-1 ,NVC7B0_VIDEO_DECODER }, + {} + } +};static const struct nvkm_falcon_func ga102_nvdec_flcn = {
@@ -59,7 +67,7 @@ ga102_nvdec_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst struct nvkm_nvdec **pnvdec) {if (nvkm_gsp_rm (device->gsp)) -return -ENODEV ; +return r535_nvdec_new (&ga102_nvdec_gsp, device, type, inst, pnvdec);return nvkm_nvdec_new_ (ga102_nvdec_fwif, device, type, inst,0x848000 , pnvdec); }
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/priv.h +5 -0
@@ -5,6 +5,8 @@struct nvkm_nvdec_func {const struct nvkm_falcon_func *flcn; + +struct nvkm_sclass sclass[]; };struct nvkm_nvdec_fwif {
@@ -18,4 +20,7 @@ extern const struct nvkm_nvdec_fwif gm107_nvdec_fwif[];int nvkm_nvdec_new_ (const struct nvkm_nvdec_fwif *fwif,struct nvkm_device *,enum nvkm_subdev_type ,int ,u32 addr,struct nvkm_nvdec **); + +int r535_nvdec_new (const struct nvkm_engine_func *,struct nvkm_device *, +enum nvkm_subdev_type ,int ,struct nvkm_nvdec **);#endif
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/r535.c new file +110 -0
110 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/tu102.c +11 -1
@@ -23,12 +23,22 @@#include <subdev/gsp.h> +#include <nvif/class.h> + +static const struct nvkm_engine_func +tu102_nvdec = { + .sclass = { + {-1 ,-1 ,NVC4B0_VIDEO_DECODER }, + {} + } +}; +int tu102_nvdec_new (struct nvkm_device *device,enum nvkm_subdev_type type,int inst,struct nvkm_nvdec **pnvdec) {if (nvkm_gsp_rm (device->gsp)) -return -ENODEV ; +return r535_nvdec_new (&tu102_nvdec, device, type, inst, pnvdec);return nvkm_nvdec_new_ (gm107_nvdec_fwif, device, type, inst,0 , pnvdec); }
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +4 -0
@@ -859,6 +859,10 @@ r535_gsp_intr_get_table(struct nvkm_gsp *gsp) type =NVKM_ENGINE_GR ; inst =0 ;break ; + case MC_ENGINE_IDX_NVDEC0 ... MC_ENGINE_IDX_NVDEC7: + type =NVKM_ENGINE_NVDEC ; + inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_NVDEC0 ; +break ;default :continue ; }
Signature · 1 line
2.41.0
PATCH 42/44 drm/nouveau/nvenc/r535: initial support
In reply to Ben SkeggsFrom: Ben Skeggs <[email protected]>
Adds support for allocating VIDEO_ENCODER classes from RM.
--- drivers/gpu/drm/nouveau/include/nvif/class.h | 4 + .../drm/nouveau/include/nvkm/engine/nvenc.h | 2 + .../535.54.03/common/sdk/nvidia/inc/nvos.h | 7 ++ .../nvidia/inc/kernel/gpu/intr/engine_idx.h | 4 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 10 ++ .../gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 1 + .../gpu/drm/nouveau/nvkm/engine/nvenc/Kbuild | 4 + .../gpu/drm/nouveau/nvkm/engine/nvenc/ad102.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/nvenc/ga102.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/nvenc/priv.h | 3 + .../gpu/drm/nouveau/nvkm/engine/nvenc/r535.c | 110 ++++++++++++++++++ .../gpu/drm/nouveau/nvkm/engine/nvenc/tu102.c | 12 +- .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 4 + 13 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ad102.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ga102.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c
drivers/gpu/drm/nouveau/include/nvif/class.h +4 -0
@@ -231,6 +231,10 @@#define AMPERE_DMA_COPY_A 0x0000c6b5#define AMPERE_DMA_COPY_B 0x0000c7b5 +#define NVC4B7_VIDEO_ENCODER 0x0000c4b7 +#define NVC7B7_VIDEO_ENCODER 0x0000c7b7 +#define NVC9B7_VIDEO_ENCODER 0x0000c9b7 +#define FERMI_DECOMPRESS 0x000090b8#define NV50_COMPUTE 0x000050c0
drivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h +2 -0
@@ -13,4 +13,6 @@ struct nvkm_nvenc {int gm107_nvenc_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvenc **);int tu102_nvenc_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvenc **); +int ga102_nvenc_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvenc **); +int ad102_nvenc_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_nvenc **);#endif
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/nvos.h +7 -0
@@ -112,6 +112,13 @@ typedef structNvU32 engineInstance;// Select NVDEC0 or NVDEC1 or NVDEC2 }NV_BSP_ALLOCATION_PARAMETERS ; +typedef struct +{ +NvU32 size; +NvU32 prohibitMultipleInstances;// Prohibit multiple allocations of MSENC? +NvU32 engineInstance;// Select MSENC/NVENC0 or NVENC1 or NVENC2 +}NV_MSENC_ALLOCATION_PARAMETERS ; + typedef struct { NvU32 index;
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h +4 -0
@@ -32,6 +32,10 @@#define MC_ENGINE_IDX_CE9 24 +#define MC_ENGINE_IDX_MSENC 38 + +#define MC_ENGINE_IDX_MSENC2 40 +#define MC_ENGINE_IDX_GSP 49#define MC_ENGINE_IDX_BSP 64
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +10 -0
@@ -2622,6 +2622,7 @@ nv172_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2652,6 +2653,7 @@ nv173_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2682,6 +2684,7 @@ nv174_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2712,6 +2715,7 @@ nv176_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2742,6 +2746,7 @@ nv177_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2765,6 +2770,7 @@ nv192_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2788,6 +2794,7 @@ nv193_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2811,6 +2818,7 @@ nv194_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2834,6 +2842,7 @@ nv196_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2857,6 +2866,7 @@ nv197_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +1 -0
@@ -596,6 +596,7 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo) engn =nvkm_runl_add (runl, nv2080, &r535_gr, type, inst);break ;case NVKM_ENGINE_NVDEC : +case NVKM_ENGINE_NVENC : engn =nvkm_runl_add (runl, nv2080, &r535_flcn, type, inst);break ;case NVKM_ENGINE_SW :
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/Kbuild +4 -0
@@ -2,3 +2,7 @@ nvkm-y += nvkm/engine/nvenc/base.o nvkm-y += nvkm/engine/nvenc/gm107.o nvkm-y += nvkm/engine/nvenc/tu102.o +nvkm-y += nvkm/engine/nvenc/ga102.o +nvkm-y += nvkm/engine/nvenc/ad102.o + +nvkm-y += nvkm/engine/nvenc/r535.o
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ad102.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ga102.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/priv.h +3 -0
@@ -18,4 +18,7 @@ extern const struct nvkm_nvenc_fwif gm107_nvenc_fwif[];int nvkm_nvenc_new_ (const struct nvkm_nvenc_fwif *,struct nvkm_device *,enum nvkm_subdev_type ,int ,struct nvkm_nvenc **pnvenc); + +int r535_nvenc_new (const struct nvkm_engine_func *,struct nvkm_device *, +enum nvkm_subdev_type ,int ,struct nvkm_nvenc **);#endif
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +110 -0
110 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/tu102.c +11 -1
@@ -23,12 +23,22 @@#include <subdev/gsp.h> +#include <nvif/class.h> + +static const struct nvkm_engine_func +tu102_nvenc = { + .sclass = { + {-1 ,-1 ,NVC4B7_VIDEO_ENCODER }, + {} + } +}; +int tu102_nvenc_new (struct nvkm_device *device,enum nvkm_subdev_type type,int inst,struct nvkm_nvenc **pnvenc) {if (nvkm_gsp_rm (device->gsp)) -return -ENODEV ; +return r535_nvenc_new (&tu102_nvenc, device, type, inst, pnvenc);return nvkm_nvenc_new_ (gm107_nvenc_fwif, device, type, inst, pnvenc); }
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +4 -0
@@ -863,6 +863,10 @@ r535_gsp_intr_get_table(struct nvkm_gsp *gsp) type =NVKM_ENGINE_NVDEC ; inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_NVDEC0 ;break ; + case MC_ENGINE_IDX_MSENC ... MC_ENGINE_IDX_MSENC2: + type =NVKM_ENGINE_NVENC ; + inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_MSENC ; +break ;default :continue ; }
Signature · 1 line
2.41.0
Re: [Nouveau] [PATCH 42/44] drm/nouveau/nvenc/r535: initial support
Quoted 472 lines · Ben Skeggs
From: Ben Skeggs <[email protected]>
Adds support for allocating
VIDEO_ENCODERclasses from RM.Signed-off-by Ben Skeggs <[email protected]>---
drivers/gpu/drm/nouveau/include/nvif/class.h | 4 + .../drm/nouveau/include/nvkm/engine/nvenc.h | 2 + .../535.54.03/common/sdk/nvidia/inc/nvos.h | 7 ++ .../nvidia/inc/kernel/gpu/intr/engine_idx.h | 4 +.../gpu/drm/nouveau/nvkm/engine/device/base.c| 10 ++ .../gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 1 + .../gpu/drm/nouveau/nvkm/engine/nvenc/Kbuild | 4 +.../gpu/drm/nouveau/nvkm/engine/nvenc/ad102.c| 44 +++++++.../gpu/drm/nouveau/nvkm/engine/nvenc/ga102.c| 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/nvenc/priv.h | 3 + .../gpu/drm/nouveau/nvkm/engine/nvenc/r535.c | 110
++++++++++++++++++
.../gpu/drm/nouveau/nvkm/engine/nvenc/tu102.c | 12 +- .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 4 +13 files changed, 248 insertions(+), 1 deletion(-)create mode 100644
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ad102.ccreate mode 100644drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ga102.ccreate mode 100644drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.cdrivers/gpu/drm/nouveau/include/nvif/class.h +0
-0@@ -231,6 +231,10 @@ #define AMPERE_DMA_COPY_A
0x0000c6b5
#defineAMPERE_DMA_COPY_B0x0000c7b5
+#defineNVC4B7_VIDEO_ENCODER0x0000c4b7
+#defineNVC7B7_VIDEO_ENCODER0x0000c7b7
+#defineNVC9B7_VIDEO_ENCODER0x0000c9b7
+
#defineFERMI_DECOMPRESS0x000090b8
#defineNV50_COMPUTE0x000050c0drivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h +0
-0@@ -13,4 +13,6 @@ struct nvkm_nvenc {
intgm107_nvenc_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvenc **);
inttu102_nvenc_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvenc **);
+intga102_nvenc_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvenc **);
+intad102_nvenc_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_nvenc **);
#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/nvos.hb/drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/nvos.h
index5c1cad9bc5db..61b98109a1c8100644
---
a/drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/nvos.h
+++
b/drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/nvos.hdrivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h +0
-0@@ -112,6 +112,13 @@ typedef structNvU32 engineInstance; // Select NVDEC0 or NVDEC1 or NVDEC2
}NV_BSP_ALLOCATION_PARAMETERS;drivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h +4
-0+typedef struct +{ + NvU32 size; + NvU32 prohibitMultipleInstances; // Prohibit multipleallocations of MSENC?
+ NvU32 engineInstance; // Select MSENC/NVENC0 or NVENC1 or NVENC2drivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h +2
-0+}NV_MSENC_ALLOCATION_PARAMETERS ; +typedef struct
{
NvU32 index;
diff --git a/drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.hb/drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h
indexb5cc77ab05a3..5ed292000036100644
---
a/drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h
+++
b/drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.hdrivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h +0
-0@@ -32,6 +32,10 @@
#define MC_ENGINE_IDX_CE9 24drivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h +4
-0+#define MC_ENGINE_IDX_MSENC 38 + +#define MC_ENGINE_IDX_MSENC2 40 +#define MC_ENGINE_IDX_GSP 49
#define MC_ENGINE_IDX_BSP 64drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2622,6 +2622,7 @@ nv172_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2652,6 +2653,7 @@ nv173_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2682,6 +2684,7 @@ nv174_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2712,6 +2715,7 @@ nv176_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2742,6 +2746,7 @@ nv177_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, + .nvenc = { 0x00000001, ga102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2765,6 +2770,7 @@ nv192_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2788,6 +2794,7 @@ nv193_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2811,6 +2818,7 @@ nv194_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2834,6 +2842,7 @@ nv196_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1
-0@@ -2857,6 +2866,7 @@ nv197_chipset = { .fifo = { 0x00000001, ga102_fifo_new }, .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, + .nvenc = { 0x00000007, ad102_nvenc_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +0
-0@@ -596,6 +596,7 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo) engn = nvkm_runl_add(runl, nv2080, &r535_gr, type, inst); break;case
NVKM_ENGINE_NVDEC:
+ caseNVKM_ENGINE_NVENC:
engn =nvkm_runl_add(runl, nv2080, &r535_flcn, type, inst);
break;
caseNVKM_ENGINE_SW:drivers/gpu/drm/nouveau/nvkm/engine/nvenc/Kbuild +0
-0@@ -2,3 +2,7 @@nvkm-y +=
nvkm/engine/nvenc/base.o
nvkm-y +=nvkm/engine/nvenc/gm107.o
nvkm-y +=nvkm/engine/nvenc/tu102.odrivers/gpu/drm/nouveau/nvkm/engine/nvenc/Kbuild +4
-0+nvkm-y += nvkm/engine/nvenc/ga102.o +nvkm-y += nvkm/engine/nvenc/ad102.o + +nvkm-y += nvkm/engine/nvenc/r535.odrivers/gpu/drm/nouveau/nvkm/engine/nvenc/ad102.c new file +4
-0@@ -0,0 +1,44 @@ +/* +* Copyright 2023 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.
+ */drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ad102.c new file +16
-0+#include "priv.h" + +#include <subdev/gsp.h> + +#include <nvif/class.h> + +static const struct nvkm_engine_func +ad102_nvenc = { + .sclass = { + { -1, -1, NVC9B7_VIDEO_ENCODER }, + {} + } +}; + +int +ad102_nvenc_new(struct nvkm_device *device, enum nvkm_subdev_typetype, int inst,
+ structnvkm_nvenc**pnvenc)
+{
+ if (nvkm_gsp_rm(device->gsp))
+ returnr535_nvenc_new(&ad102_nvenc, device, type, inst, pnvenc);drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ad102.c new file +3
-0+ + return -ENODEV; +}drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ga102.c new file +4
-0@@ -0,0 +1,44 @@ +/* +* Copyright 2023 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.
+ */drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ga102.c new file +16
-0+#include "priv.h" + +#include <subdev/gsp.h> + +#include <nvif/class.h> + +static const struct nvkm_engine_func +ga102_nvenc = { + .sclass = { + { -1, -1, NVC7B7_VIDEO_ENCODER }, + {} + } +}; + +int +ga102_nvenc_new(struct nvkm_device *device, enum nvkm_subdev_typetype, int inst,
+ structnvkm_nvenc**pnvenc)
+{
+ if (nvkm_gsp_rm(device->gsp))
+ returnr535_nvenc_new(&ga102_nvenc, device, type, inst, pnvenc);drivers/gpu/drm/nouveau/nvkm/engine/nvenc/ga102.c new file +3
-0+ + return -ENODEV; +}drivers/gpu/drm/nouveau/nvkm/engine/nvenc/priv.h +0
-0@@ -18,4 +18,7 @@ extern const struct nvkm_nvenc_fwif gm107_nvenc_fwif[];
int nvkm_nvenc_new_(const structnvkm_nvenc_fwif*, structnvkm_device*, enumnvkm_subdev_type,
int, structnvkm_nvenc**pnvenc);drivers/gpu/drm/nouveau/nvkm/engine/nvenc/priv.h +2
-0+ +int r535_nvenc_new(const struct nvkm_engine_func *, struct
nvkm_device*,
+ enumnvkm_subdev_type, int, structnvkm_nvenc**); #endifdrivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +4
-0@@ -0,0 +1,110 @@ +/* +* Copyright 2023 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.
+ */drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +18
-0+#include "priv.h" + +#include <core/object.h> +#include <subdev/gsp.h> +#include <engine/fifo.h> + +#include <nvrm/nvtypes.h> +#include <nvrm/535.54.03/common/sdk/nvidia/inc/nvos.h> + +struct r535_nvenc_obj { + struct nvkm_object object; + struct nvkm_gsp_object rm; +}; + +static void * +r535_nvenc_obj_dtor (struct nvkm_object *object) +{ + struct r535_nvenc_obj *obj = container_of(object,
typeof(*obj), object);drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +12
-0+ + nvkm_gsp_rm_free(&obj->rm); + return obj; +} + +static const struct nvkm_object_func +r535_nvenc_obj = { + .dtor = r535_nvenc_obj_dtor, +}; + +static int +r535_nvenc_obj_ctor(const struct nvkm_oclass *oclass, void *argv,u32 argc,
+ structnvkm_object**pobject)drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +12
-0+{ + struct nvkm_chan *chan = nvkm_uchan_chan(oclass->parent); + struct r535_nvenc_obj *obj; + NV_MSENC_ALLOCATION_PARAMETERS *args; + + if (!(obj = kzalloc(sizeof(*obj), GFP_KERNEL))) + return -ENOMEM; + + nvkm_object_ctor(&r535_nvenc_obj, oclass, &obj->object); + *pobject = &obj->object; + + args = nvkm_gsp_rm_alloc_get(&chan->rm.object, oclass-Quoted 1 line
handle,
oclass->base.oclass,+
sizeof(*args),&obj->rm); + if (WARN_ON(IS_ERR(args)))
+ returnPTR_ERR(args);drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +5
-0+ + args->size = sizeof(*args); + args->engineInstance = oclass->engine->subdev.inst; + + return nvkm_gsp_rm_alloc_wr(&obj->rm, args);
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c line 82
Quoted 10 lines
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +10
-0+} + +static void * +r535_nvenc_dtor (struct nvkm_engine *engine) +{ + struct nvkm_nvenc *nvenc = nvkm_nvenc(engine); + + kfree(nvenc->engine.func); + return nvenc; +}
Why is nvenc returned as void * when it's clearly always of type struct nvkm_nvenc * ?
If it's sometimes necessary to convert it to a void-pointer I think it would be better to do that by assigning to a void-pointer at the place where r535_nvenc_dtor() is actually called. This void-pointer's subsequent usage then would make it obvious why it's void *
Is it necessary to return it in an opaque form? If so, that should be commented.
Quoted 13 lines
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +3
-0+ +int +r535_nvenc_new(const struct nvkm_engine_func *hw, struct nvkm_device*device,
+ enumnvkm_subdev_typetype, int inst, structnvkm_nvenc**pnvenc)drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +7
-0+{ + struct nvkm_engine_func *rm; + int nclass; + + for (nclass = 0; hw->sclass[nclass].oclass; nclass++); + + if (!(rm = kzalloc(sizeof(*rm) + (nclass + 1) * sizeof(rm-
Quoted 1 line
Quoted 1 line
sclass[0]),
GFP_KERNEL)))
A variable for the size increases readability greatly here. e.g., size_t nvkm_engine_total_size = ...
Quoted 68 lines
+ return
-ENOMEM;drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +15
-0+ + rm->dtor = r535_nvenc_dtor; + for (int i = 0; i < nclass; i++) { + rm->sclass[i].minver = hw->sclass[i].minver; + rm->sclass[i].maxver = hw->sclass[i].maxver; + rm->sclass[i].oclass = hw->sclass[i].oclass; + rm->sclass[i].ctor = r535_nvenc_obj_ctor; + } + + if (!(*pnvenc = kzalloc(sizeof(**pnvenc), GFP_KERNEL))) { + kfree(rm); + return -ENOMEM; + } + + return nvkm_engine_ctor(rm, device, type, inst, true,&(*pnvenc)->engine);
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +1
-0+}drivers/gpu/drm/nouveau/nvkm/engine/nvenc/tu102.c +0
-0@@ -23,12 +23,22 @@
#include <subdev/gsp.h>drivers/gpu/drm/nouveau/nvkm/engine/nvenc/tu102.c +10
-0+#include <nvif/class.h> + +static const struct nvkm_engine_func +tu102_nvenc = { + .sclass = { + { -1, -1, NVC4B7_VIDEO_ENCODER }, + {} + } +}; +int
tu102_nvenc_new(structnvkm_device*device, enumnvkm_subdev_typetype, int inst,
structnvkm_nvenc**pnvenc)
{
if (nvkm_gsp_rm(device->gsp))
- return-ENODEV;
+ returnr535_nvenc_new(&tu102_nvenc, device, type, inst, pnvenc);
returnnvkm_nvenc_new_(gm107_nvenc_fwif, device, type, inst, pnvenc);
}drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +0
-0@@ -863,6 +863,10 @@ r535_gsp_intr_get_table(struct nvkm_gsp *gsp) type = NVKM_ENGINE_NVDEC;inst = ctrl->table[i].engineIdx -
MC_ENGINE_IDX_NVDEC0;
break;
+ caseMC_ENGINE_IDX_MSENC...MC_ENGINE_IDX_MSENC2:
+ type =NVKM_ENGINE_NVENC;
+ inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_MSENC;
+ break;
default:
continue;
}
Re: [Nouveau] [PATCH 42/44] drm/nouveau/nvenc/r535: initial support
Quoted 6 lines · Philipp Stanner
Quoted 5 lines · Ben Skeggs
From: Ben Skeggs <[email protected]>
Adds support for allocating
VIDEO_ENCODERclasses from RM.Signed-off-by Ben Skeggs <[email protected]>
[...]
Quoted 12 lines
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c line 82
Quoted 8 lines
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/r535.c new file +8
-0+static void * +r535_nvenc_dtor (struct nvkm_engine *engine) +{ + struct nvkm_nvenc *nvenc = nvkm_nvenc(engine); + + kfree(nvenc->engine.func); + return nvenc; +}Why is nvenc returned as void * when it's clearly always of type struct
nvkm_nvenc* ?
Quoted 7 lines
If it's sometimes necessary to convert it to a void-pointer I think it would be better to do that by assigning to a void-pointer at the place where
r535_nvenc_dtor()is actually called. This void-pointer's subsequent usage then would make it obvious why it's void *Is it necessary to return it in an opaque form? If so, that should be commented.
This is part of Nouveau's conventions for object-oriented programming. This would be part of the so-called "core". It's been a while since I worked with it, but the reason why it is a void * is because it makes other functions easier to write.
I hope this helps!
Cheers,
Martin
PS: I am not checking out Nouveau's mailing list often, so if anyone has some questions related to the kernel driver, feel free to ping me (mupuf) on #nouveau and I will try my best to provide some context or a pointer to someone else could be a good person to answer :)
PATCH 43/44 drm/nouveau/nvjpg/r535: initial support
In reply to Ben SkeggsFrom: Ben Skeggs <[email protected]>
Adds support for allocating NVJPG classes from RM.
--- drivers/gpu/drm/nouveau/include/nvif/cl0080.h | 1 + drivers/gpu/drm/nouveau/include/nvif/class.h | 3 + .../drm/nouveau/include/nvkm/engine/nvjpg.h | 8 ++ .../535.54.03/common/sdk/nvidia/inc/nvos.h | 7 ++ .../nvidia/inc/kernel/gpu/intr/engine_idx.h | 5 + drivers/gpu/drm/nouveau/nvkm/engine/Kbuild | 1 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 6 + .../gpu/drm/nouveau/nvkm/engine/device/priv.h | 1 + .../gpu/drm/nouveau/nvkm/engine/fifo/base.c | 1 + .../gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 1 + .../gpu/drm/nouveau/nvkm/engine/nvjpg/Kbuild | 5 + .../gpu/drm/nouveau/nvkm/engine/nvjpg/ad102.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/nvjpg/ga100.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/nvjpg/priv.h | 8 ++ .../gpu/drm/nouveau/nvkm/engine/nvjpg/r535.c | 107 ++++++++++++++++++ .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 4 + 16 files changed, 246 insertions(+) create mode 100644 drivers/gpu/drm/nouveau/include/nvkm/engine/nvjpg.h create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/Kbuild create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/ad102.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/ga100.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/priv.h create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/r535.c
drivers/gpu/drm/nouveau/include/nvif/cl0080.h +1 -0
@@ -91,6 +91,7 @@ struct nv_device_time_v0 {#define NV_DEVICE_HOST_RUNLIST_ENGINES_SEC2 0x00004000#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVDEC 0x00008000#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVENC 0x00010000 +#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVJPG 0x00020000/* Returns the number of available channels on runlist(data). */ #define NV_DEVICE_HOST_RUNLIST_CHANNELS NV_DEVICE_HOST(0x00000101)#endif
drivers/gpu/drm/nouveau/include/nvif/class.h +3 -0
@@ -253,4 +253,7 @@#define ADA_COMPUTE_A 0x0000c9c0#define NV74_CIPHER 0x000074c1 + +#define NVC4D1_VIDEO_NVJPG 0x0000c4d1 +#define NVC9D1_VIDEO_NVJPG 0x0000c9d1#endif
drivers/gpu/drm/nouveau/include/nvkm/engine/nvjpg.h new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef __NVKM_NVJPG_H__ +#define __NVKM_NVJPG_H__ +#include <core/engine.h> + +int ga100_nvjpg_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_engine **); +int ad102_nvjpg_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_engine **); +#endif
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/nvos.h +7 -0
@@ -119,6 +119,13 @@ typedef structNvU32 engineInstance;// Select MSENC/NVENC0 or NVENC1 or NVENC2 }NV_MSENC_ALLOCATION_PARAMETERS ; +typedef struct +{ +NvU32 size; +NvU32 prohibitMultipleInstances;// Prohibit multiple allocations of NVJPG? +NvU32 engineInstance; +}NV_NVJPG_ALLOCATION_PARAMETERS ; + typedef struct { NvU32 index;
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h +5 -0
@@ -37,6 +37,11 @@#define MC_ENGINE_IDX_MSENC2 40#define MC_ENGINE_IDX_GSP 49 +#define MC_ENGINE_IDX_NVJPG 50 +#define MC_ENGINE_IDX_NVJPEG MC_ENGINE_IDX_NVJPG +#define MC_ENGINE_IDX_NVJPEG0 MC_ENGINE_IDX_NVJPEG + +#define MC_ENGINE_IDX_NVJPEG7 57#define MC_ENGINE_IDX_BSP 64#define MC_ENGINE_IDX_NVDEC MC_ENGINE_IDX_BSP
drivers/gpu/drm/nouveau/nvkm/engine/Kbuild +1 -0
@@ -17,6 +17,7 @@ include $(src)/nvkm/engine/msppp/Kbuild include $(src)/nvkm/engine/msvld/Kbuild include $(src)/nvkm/engine/nvenc/Kbuild include $(src)/nvkm/engine/nvdec/Kbuild +include $(src)/nvkm/engine/nvjpg/Kbuild include $(src)/nvkm/engine/pm/Kbuild include $(src)/nvkm/engine/sec/Kbuild include $(src)/nvkm/engine/sec2/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +6 -0
@@ -2593,6 +2593,7 @@ nv170_chipset = { .ce = { 0x000003ff, ga100_ce_new }, .fifo = { 0x00000001, ga100_fifo_new }, .nvdec = { 0x0000001f, ga100_nvdec_new }, + .nvjpg = { 0x00000001, ga100_nvjpg_new }, }; static const struct nvkm_device_chip
@@ -2771,6 +2772,7 @@ nv192_chipset = { .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, + .nvjpg = { 0x0000000f, ad102_nvjpg_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2795,6 +2797,7 @@ nv193_chipset = { .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, + .nvjpg = { 0x0000000f, ad102_nvjpg_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2819,6 +2822,7 @@ nv194_chipset = { .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, + .nvjpg = { 0x0000000f, ad102_nvjpg_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2843,6 +2847,7 @@ nv196_chipset = { .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, + .nvjpg = { 0x0000000f, ad102_nvjpg_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2867,6 +2872,7 @@ nv197_chipset = { .gr = { 0x00000001, ad102_gr_new }, .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, + .nvjpg = { 0x0000000f, ad102_nvjpg_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h +1 -0
@@ -43,6 +43,7 @@#include <engine/msvld.h> #include <engine/nvenc.h> #include <engine/nvdec.h> +#include <engine/nvjpg.h> #include <engine/pm.h> #include <engine/sec.h> #include <engine/sec2.h>
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c +1 -0
@@ -210,6 +210,7 @@ nvkm_fifo_info(struct nvkm_engine *engine, u64 mthd, u64 *data)CASE (SEC2 );CASE (NVDEC );CASE (NVENC ); +CASE (NVJPG );default :WARN_ON (1 );break ;
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +1 -0
@@ -597,6 +597,7 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo)break ;case NVKM_ENGINE_NVDEC :case NVKM_ENGINE_NVENC : +case NVKM_ENGINE_NVJPG : engn =nvkm_runl_add (runl, nv2080, &r535_flcn, type, inst);break ;case NVKM_ENGINE_SW :
drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/Kbuild new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: MIT +nvkm-y += nvkm/engine/nvjpg/ga100.o +nvkm-y += nvkm/engine/nvjpg/ad102.o + +nvkm-y += nvkm/engine/nvjpg/r535.o
drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/ad102.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/ga100.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/priv.h new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef __NVKM_NVJPG_PRIV_H__ +#define __NVKM_NVJPG_PRIV_H__ +#include <engine/nvjpg.h> + +int r535_nvjpg_new (const struct nvkm_engine_func *,struct nvkm_device *, +enum nvkm_subdev_type ,int ,struct nvkm_engine **); +#endif
drivers/gpu/drm/nouveau/nvkm/engine/nvjpg/r535.c new file +107 -0
107 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +4 -0
@@ -867,6 +867,10 @@ r535_gsp_intr_get_table(struct nvkm_gsp *gsp) type =NVKM_ENGINE_NVENC ; inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_MSENC ;break ; + case MC_ENGINE_IDX_NVJPEG0 ... MC_ENGINE_IDX_NVJPEG7: + type =NVKM_ENGINE_NVJPG ; + inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_NVJPEG0 ; +break ;default :continue ; }
Signature · 1 line
2.41.0
PATCH 44/44 drm/nouveau/ofa/r535: initial support
In reply to Ben SkeggsFrom: Ben Skeggs <[email protected]>
Adds support for allocating OFA classes from RM.
--- drivers/gpu/drm/nouveau/include/nvif/cl0080.h | 1 + drivers/gpu/drm/nouveau/include/nvif/class.h | 4 + .../gpu/drm/nouveau/include/nvkm/engine/ofa.h | 9 ++ .../535.54.03/common/sdk/nvidia/inc/nvos.h | 6 + .../nvidia/inc/kernel/gpu/intr/engine_idx.h | 2 + drivers/gpu/drm/nouveau/nvkm/engine/Kbuild | 1 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 11 ++ .../gpu/drm/nouveau/nvkm/engine/device/priv.h | 1 + .../gpu/drm/nouveau/nvkm/engine/fifo/base.c | 1 + .../gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 1 + .../gpu/drm/nouveau/nvkm/engine/ofa/Kbuild | 6 + .../gpu/drm/nouveau/nvkm/engine/ofa/ad102.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/ofa/ga100.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/ofa/ga102.c | 44 +++++++ .../gpu/drm/nouveau/nvkm/engine/ofa/priv.h | 8 ++ .../gpu/drm/nouveau/nvkm/engine/ofa/r535.c | 107 ++++++++++++++++++ .../gpu/drm/nouveau/nvkm/subdev/gsp/r535.c | 4 + 17 files changed, 294 insertions(+) create mode 100644 drivers/gpu/drm/nouveau/include/nvkm/engine/ofa.h create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/ofa/Kbuild create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/ofa/ad102.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/ofa/ga100.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/ofa/ga102.c create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/ofa/priv.h create mode 100644 drivers/gpu/drm/nouveau/nvkm/engine/ofa/r535.c
drivers/gpu/drm/nouveau/include/nvif/cl0080.h +1 -0
@@ -92,6 +92,7 @@ struct nv_device_time_v0 {#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVDEC 0x00008000#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVENC 0x00010000#define NV_DEVICE_HOST_RUNLIST_ENGINES_NVJPG 0x00020000 +#define NV_DEVICE_HOST_RUNLIST_ENGINES_OFA 0x00040000/* Returns the number of available channels on runlist(data). */ #define NV_DEVICE_HOST_RUNLIST_CHANNELS NV_DEVICE_HOST(0x00000101)#endif
drivers/gpu/drm/nouveau/include/nvif/class.h +4 -0
@@ -256,4 +256,8 @@#define NVC4D1_VIDEO_NVJPG 0x0000c4d1#define NVC9D1_VIDEO_NVJPG 0x0000c9d1 + +#define NVC6FA_VIDEO_OFA 0x0000c6fa +#define NVC7FA_VIDEO_OFA 0x0000c7fa +#define NVC9FA_VIDEO_OFA 0x0000c9fa#endif
drivers/gpu/drm/nouveau/include/nvkm/engine/ofa.h new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef __NVKM_OFA_H__ +#define __NVKM_OFA_H__ +#include <core/engine.h> + +int ga100_ofa_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_engine **); +int ga102_ofa_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_engine **); +int ad102_ofa_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_engine **); +#endif
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/common/sdk/nvidia/inc/nvos.h +6 -0
@@ -126,6 +126,12 @@ typedef structNvU32 engineInstance; }NV_NVJPG_ALLOCATION_PARAMETERS ; +typedef struct +{ +NvU32 size; +NvU32 prohibitMultipleInstances;// Prohibit multiple allocations of OFA? +}NV_OFA_ALLOCATION_PARAMETERS ; + typedef struct { NvU32 index;
drivers/gpu/drm/nouveau/include/nvrm/535.54.03/nvidia/inc/kernel/gpu/intr/engine_idx.h +2 -0
@@ -49,6 +49,8 @@#define MC_ENGINE_IDX_NVDEC7 71 +#define MC_ENGINE_IDX_OFA0 80 +#define MC_ENGINE_IDX_GR 82#define MC_ENGINE_IDX_GR0 MC_ENGINE_IDX_GR
drivers/gpu/drm/nouveau/nvkm/engine/Kbuild +1 -0
@@ -18,6 +18,7 @@ include $(src)/nvkm/engine/msvld/Kbuild include $(src)/nvkm/engine/nvenc/Kbuild include $(src)/nvkm/engine/nvdec/Kbuild include $(src)/nvkm/engine/nvjpg/Kbuild +include $(src)/nvkm/engine/ofa/Kbuild include $(src)/nvkm/engine/pm/Kbuild include $(src)/nvkm/engine/sec/Kbuild include $(src)/nvkm/engine/sec2/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +11 -0
@@ -2594,6 +2594,7 @@ nv170_chipset = { .fifo = { 0x00000001, ga100_fifo_new }, .nvdec = { 0x0000001f, ga100_nvdec_new }, .nvjpg = { 0x00000001, ga100_nvjpg_new }, + .ofa = { 0x00000001, ga100_ofa_new }, }; static const struct nvkm_device_chip
@@ -2624,6 +2625,7 @@ nv172_chipset = { .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, .nvenc = { 0x00000001, ga102_nvenc_new }, + .ofa = { 0x00000001, ga102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2655,6 +2657,7 @@ nv173_chipset = { .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, .nvenc = { 0x00000001, ga102_nvenc_new }, + .ofa = { 0x00000001, ga102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2686,6 +2689,7 @@ nv174_chipset = { .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, .nvenc = { 0x00000001, ga102_nvenc_new }, + .ofa = { 0x00000001, ga102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2717,6 +2721,7 @@ nv176_chipset = { .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, .nvenc = { 0x00000001, ga102_nvenc_new }, + .ofa = { 0x00000001, ga102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2748,6 +2753,7 @@ nv177_chipset = { .gr = { 0x00000001, ga102_gr_new }, .nvdec = { 0x00000003, ga102_nvdec_new }, .nvenc = { 0x00000001, ga102_nvenc_new }, + .ofa = { 0x00000001, ga102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2773,6 +2779,7 @@ nv192_chipset = { .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, .nvjpg = { 0x0000000f, ad102_nvjpg_new }, + .ofa = { 0x00000001, ad102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2798,6 +2805,7 @@ nv193_chipset = { .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, .nvjpg = { 0x0000000f, ad102_nvjpg_new }, + .ofa = { 0x00000001, ad102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2823,6 +2831,7 @@ nv194_chipset = { .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, .nvjpg = { 0x0000000f, ad102_nvjpg_new }, + .ofa = { 0x00000001, ad102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2848,6 +2857,7 @@ nv196_chipset = { .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, .nvjpg = { 0x0000000f, ad102_nvjpg_new }, + .ofa = { 0x00000001, ad102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
@@ -2873,6 +2883,7 @@ nv197_chipset = { .nvdec = { 0x0000000f, ad102_nvdec_new }, .nvenc = { 0x00000007, ad102_nvenc_new }, .nvjpg = { 0x0000000f, ad102_nvjpg_new }, + .ofa = { 0x00000001, ad102_ofa_new }, .sec2 = { 0x00000001, ga102_sec2_new }, };
drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h +1 -0
@@ -44,6 +44,7 @@#include <engine/nvenc.h> #include <engine/nvdec.h> #include <engine/nvjpg.h> +#include <engine/ofa.h> #include <engine/pm.h> #include <engine/sec.h> #include <engine/sec2.h>
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c +1 -0
@@ -211,6 +211,7 @@ nvkm_fifo_info(struct nvkm_engine *engine, u64 mthd, u64 *data)CASE (NVDEC );CASE (NVENC );CASE (NVJPG ); +CASE (OFA );default :WARN_ON (1 );break ;
drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +1 -0
@@ -598,6 +598,7 @@ r535_fifo_runl_ctor(struct nvkm_fifo *fifo)case NVKM_ENGINE_NVDEC :case NVKM_ENGINE_NVENC :case NVKM_ENGINE_NVJPG : +case NVKM_ENGINE_OFA : engn =nvkm_runl_add (runl, nv2080, &r535_flcn, type, inst);break ;case NVKM_ENGINE_SW :
drivers/gpu/drm/nouveau/nvkm/engine/ofa/Kbuild new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: MIT +nvkm-y += nvkm/engine/ofa/ga100.o +nvkm-y += nvkm/engine/ofa/ga102.o +nvkm-y += nvkm/engine/ofa/ad102.o + +nvkm-y += nvkm/engine/ofa/r535.o
drivers/gpu/drm/nouveau/nvkm/engine/ofa/ad102.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/ofa/ga100.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/ofa/ga102.c new file +44 -0
44 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/engine/ofa/priv.h new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef __NVKM_OFA_PRIV_H__ +#define __NVKM_OFA_PRIV_H__ +#include <engine/ofa.h> + +int r535_ofa_new (const struct nvkm_engine_func *,struct nvkm_device *, +enum nvkm_subdev_type ,int ,struct nvkm_engine **); +#endif
drivers/gpu/drm/nouveau/nvkm/engine/ofa/r535.c new file +107 -0
107 lines not on this page · raw message
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/r535.c +4 -0
@@ -871,6 +871,10 @@ r535_gsp_intr_get_table(struct nvkm_gsp *gsp) type =NVKM_ENGINE_NVJPG ; inst = ctrl->table[i].engineIdx -MC_ENGINE_IDX_NVJPEG0 ;break ; +case MC_ENGINE_IDX_OFA0 : + type =NVKM_ENGINE_OFA ; + inst =0 ; +break ;default :continue ; }
Signature · 1 line
2.41.0