Skip to content

Commit 830531e

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/gsp/r535: add interrupt handling
Fetches the interrupt table from RM, and hooks up the GSP interrupt handler to message queue processing to catch async messages. Signed-off-by: Ben Skeggs <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 37e328a commit 830531e

File tree

13 files changed

+291
-1
lines changed

13 files changed

+291
-1
lines changed

drivers/gpu/drm/nouveau/include/nvkm/core/falcon.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ int nvkm_falcon_pio_rd(struct nvkm_falcon *, u8 port, enum nvkm_falcon_mem type,
4949
int nvkm_falcon_dma_wr(struct nvkm_falcon *, const u8 *img, u64 dma_addr, u32 dma_base,
5050
enum nvkm_falcon_mem mem_type, u32 mem_base, int len, bool sec);
5151
bool nvkm_falcon_riscv_active(struct nvkm_falcon *);
52+
void nvkm_falcon_intr_retrigger(struct nvkm_falcon *);
5253

5354
int gm200_flcn_reset_wait_mem_scrubbing(struct nvkm_falcon *);
5455
int gm200_flcn_disable(struct nvkm_falcon *);
@@ -64,6 +65,8 @@ extern const struct nvkm_falcon_func_pio gp102_flcn_emem_pio;
6465

6566
bool tu102_flcn_riscv_active(struct nvkm_falcon *);
6667

68+
void ga100_flcn_intr_retrigger(struct nvkm_falcon *);
69+
6770
int ga102_flcn_select(struct nvkm_falcon *);
6871
int ga102_flcn_reset_prep(struct nvkm_falcon *);
6972
int ga102_flcn_reset_wait_mem_scrubbing(struct nvkm_falcon *);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct nvkm_falcon_func {
6262
int (*enable)(struct nvkm_falcon *);
6363
int (*select)(struct nvkm_falcon *);
6464
u32 addr2;
65+
u32 riscv_irqmask;
6566
bool reset_pmc;
6667
int (*reset_eng)(struct nvkm_falcon *);
6768
int (*reset_prep)(struct nvkm_falcon *);
@@ -88,6 +89,7 @@ struct nvkm_falcon_func {
8889
} cmdq, msgq;
8990

9091
bool (*riscv_active)(struct nvkm_falcon *);
92+
void (*intr_retrigger)(struct nvkm_falcon *);
9193

9294
struct {
9395
u32 *data;

drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct nvkm_gsp {
128128
void *priv;
129129
} ntfy[16];
130130
int ntfy_nr;
131+
struct work_struct work;
131132
} msgq;
132133

133134
bool running;
@@ -150,6 +151,14 @@ struct nvkm_gsp {
150151
} device;
151152
} internal;
152153

154+
struct {
155+
enum nvkm_subdev_type type;
156+
int inst;
157+
u32 stall;
158+
u32 nonstall;
159+
} intr[32];
160+
int intr_nr;
161+
153162
const struct nvkm_gsp_rm {
154163
void *(*rpc_get)(struct nvkm_gsp *, u32 fn, u32 argc);
155164
void *(*rpc_push)(struct nvkm_gsp *, void *argv, bool wait, u32 repc);
@@ -378,6 +387,9 @@ nvkm_gsp_client_device_ctor(struct nvkm_gsp *gsp,
378387
return ret;
379388
}
380389

390+
int nvkm_gsp_intr_stall(struct nvkm_gsp *, enum nvkm_subdev_type, int);
391+
int nvkm_gsp_intr_nonstall(struct nvkm_gsp *, enum nvkm_subdev_type, int);
392+
381393
int gv100_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
382394
int tu102_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
383395
int tu116_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#ifndef __src_common_sdk_nvidia_inc_ctrl_ctrl2080_ctrl2080internal_h__
2+
#define __src_common_sdk_nvidia_inc_ctrl_ctrl2080_ctrl2080internal_h__
3+
4+
/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */
5+
6+
/*
7+
* SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
8+
* SPDX-License-Identifier: MIT
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a
11+
* copy of this software and associated documentation files (the "Software"),
12+
* to deal in the Software without restriction, including without limitation
13+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
* and/or sell copies of the Software, and to permit persons to whom the
15+
* Software is furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
* DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#define NV2080_CTRL_CMD_INTERNAL_INTR_GET_KERNEL_TABLE (0x20800a5c) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_PARAMS_MESSAGE_ID" */
30+
31+
#define NV2080_CTRL_INTERNAL_INTR_MAX_TABLE_SIZE 128
32+
33+
typedef enum NV2080_INTR_CATEGORY {
34+
NV2080_INTR_CATEGORY_DEFAULT = 0,
35+
NV2080_INTR_CATEGORY_ESCHED_DRIVEN_ENGINE = 1,
36+
NV2080_INTR_CATEGORY_ESCHED_DRIVEN_ENGINE_NOTIFICATION = 2,
37+
NV2080_INTR_CATEGORY_RUNLIST = 3,
38+
NV2080_INTR_CATEGORY_RUNLIST_NOTIFICATION = 4,
39+
NV2080_INTR_CATEGORY_UVM_OWNED = 5,
40+
NV2080_INTR_CATEGORY_UVM_SHARED = 6,
41+
NV2080_INTR_CATEGORY_ENUM_COUNT = 7,
42+
} NV2080_INTR_CATEGORY;
43+
44+
typedef struct NV2080_INTR_CATEGORY_SUBTREE_MAP {
45+
NvU8 subtreeStart;
46+
NvU8 subtreeEnd;
47+
} NV2080_INTR_CATEGORY_SUBTREE_MAP;
48+
49+
typedef struct NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_ENTRY {
50+
NvU16 engineIdx;
51+
NvU32 pmcIntrMask;
52+
NvU32 vectorStall;
53+
NvU32 vectorNonStall;
54+
} NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_ENTRY;
55+
56+
typedef struct NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_PARAMS {
57+
NvU32 tableLen;
58+
NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_ENTRY table[NV2080_CTRL_INTERNAL_INTR_MAX_TABLE_SIZE];
59+
NV2080_INTR_CATEGORY_SUBTREE_MAP subtreeMap[NV2080_INTR_CATEGORY_ENUM_COUNT];
60+
} NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_PARAMS;
61+
62+
#endif
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef __src_nvidia_inc_kernel_gpu_intr_engine_idx_h__
2+
#define __src_nvidia_inc_kernel_gpu_intr_engine_idx_h__
3+
4+
/* Excerpt of RM headers from https://github.com/NVIDIA/open-gpu-kernel-modules/tree/535.54.03 */
5+
6+
/*
7+
* SPDX-FileCopyrightText: Copyright (c) 1993-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
8+
* SPDX-License-Identifier: MIT
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a
11+
* copy of this software and associated documentation files (the "Software"),
12+
* to deal in the Software without restriction, including without limitation
13+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
* and/or sell copies of the Software, and to permit persons to whom the
15+
* Software is furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
* DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
#define MC_ENGINE_IDX_GSP 49
30+
31+
#endif

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,7 @@ nv192_chipset = {
27532753
.gsp = { 0x00000001, ad102_gsp_new },
27542754
.pci = { 0x00000001, gp100_pci_new },
27552755
.timer = { 0x00000001, gk20a_timer_new },
2756+
.vfn = { 0x00000001, ga100_vfn_new },
27562757
.sec2 = { 0x00000001, ga102_sec2_new },
27572758
};
27582759

@@ -2765,6 +2766,7 @@ nv193_chipset = {
27652766
.gsp = { 0x00000001, ad102_gsp_new },
27662767
.pci = { 0x00000001, gp100_pci_new },
27672768
.timer = { 0x00000001, gk20a_timer_new },
2769+
.vfn = { 0x00000001, ga100_vfn_new },
27682770
.sec2 = { 0x00000001, ga102_sec2_new },
27692771
};
27702772

@@ -2777,6 +2779,7 @@ nv194_chipset = {
27772779
.gsp = { 0x00000001, ad102_gsp_new },
27782780
.pci = { 0x00000001, gp100_pci_new },
27792781
.timer = { 0x00000001, gk20a_timer_new },
2782+
.vfn = { 0x00000001, ga100_vfn_new },
27802783
.sec2 = { 0x00000001, ga102_sec2_new },
27812784
};
27822785

@@ -2789,6 +2792,7 @@ nv196_chipset = {
27892792
.gsp = { 0x00000001, ad102_gsp_new },
27902793
.pci = { 0x00000001, gp100_pci_new },
27912794
.timer = { 0x00000001, gk20a_timer_new },
2795+
.vfn = { 0x00000001, ga100_vfn_new },
27922796
.sec2 = { 0x00000001, ga102_sec2_new },
27932797
};
27942798

@@ -2801,6 +2805,7 @@ nv197_chipset = {
28012805
.gsp = { 0x00000001, ad102_gsp_new },
28022806
.pci = { 0x00000001, gp100_pci_new },
28032807
.timer = { 0x00000001, gk20a_timer_new },
2808+
.vfn = { 0x00000001, ga100_vfn_new },
28042809
.sec2 = { 0x00000001, ga102_sec2_new },
28052810
};
28062811

drivers/gpu/drm/nouveau/nvkm/falcon/base.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
#include <subdev/timer.h>
2626
#include <subdev/top.h>
2727

28+
void
29+
nvkm_falcon_intr_retrigger(struct nvkm_falcon *falcon)
30+
{
31+
if (falcon->func->intr_retrigger)
32+
falcon->func->intr_retrigger(falcon);
33+
}
34+
2835
bool
2936
nvkm_falcon_riscv_active(struct nvkm_falcon *falcon)
3037
{

drivers/gpu/drm/nouveau/nvkm/falcon/ga100.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
*/
2222
#include "priv.h"
2323

24+
void
25+
ga100_flcn_intr_retrigger(struct nvkm_falcon *falcon)
26+
{
27+
nvkm_falcon_wr32(falcon, 0x3e8, 0x00000001);
28+
}
29+
2430
int
2531
ga100_flcn_fw_signature(struct nvkm_falcon_fw *fw, u32 *src_base_src)
2632
{

drivers/gpu/drm/nouveau/nvkm/subdev/gsp/base.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,36 @@
2121
*/
2222
#include "priv.h"
2323

24+
int
25+
nvkm_gsp_intr_nonstall(struct nvkm_gsp *gsp, enum nvkm_subdev_type type, int inst)
26+
{
27+
for (int i = 0; i < gsp->intr_nr; i++) {
28+
if (gsp->intr[i].type == type && gsp->intr[i].inst == inst) {
29+
if (gsp->intr[i].nonstall != ~0)
30+
return gsp->intr[i].nonstall;
31+
32+
return -EINVAL;
33+
}
34+
}
35+
36+
return -ENOENT;
37+
}
38+
39+
int
40+
nvkm_gsp_intr_stall(struct nvkm_gsp *gsp, enum nvkm_subdev_type type, int inst)
41+
{
42+
for (int i = 0; i < gsp->intr_nr; i++) {
43+
if (gsp->intr[i].type == type && gsp->intr[i].inst == inst) {
44+
if (gsp->intr[i].stall != ~0)
45+
return gsp->intr[i].stall;
46+
47+
return -EINVAL;
48+
}
49+
}
50+
51+
return -ENOENT;
52+
}
53+
2454
static int
2555
nvkm_gsp_fini(struct nvkm_subdev *subdev, bool suspend)
2656
{

drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga100.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,26 @@
2121
*/
2222
#include "priv.h"
2323

24+
static const struct nvkm_falcon_func
25+
ga100_gsp_flcn = {
26+
.disable = gm200_flcn_disable,
27+
.enable = gm200_flcn_enable,
28+
.addr2 = 0x1000,
29+
.riscv_irqmask = 0x2b4,
30+
.reset_eng = gp102_flcn_reset_eng,
31+
.reset_wait_mem_scrubbing = gm200_flcn_reset_wait_mem_scrubbing,
32+
.bind_inst = gm200_flcn_bind_inst,
33+
.bind_stat = gm200_flcn_bind_stat,
34+
.bind_intr = true,
35+
.imem_pio = &gm200_flcn_imem_pio,
36+
.dmem_pio = &gm200_flcn_dmem_pio,
37+
.riscv_active = tu102_flcn_riscv_active,
38+
.intr_retrigger = ga100_flcn_intr_retrigger,
39+
};
40+
2441
static const struct nvkm_gsp_func
2542
ga100_gsp_r535_54_03 = {
26-
.flcn = &tu102_gsp_flcn,
43+
.flcn = &ga100_gsp_flcn,
2744
.fwsec = &tu102_gsp_fwsec,
2845

2946
.sig_section = ".fwsignature_ga100",

0 commit comments

Comments
 (0)