Skip to content

Commit 426cce5

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/vfn/tu102-: prepare for GSP-RM
- add R535 implementation of VFN, minus interrupt table 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 d4c9cd3 commit 426cce5

File tree

5 files changed

+68
-1
lines changed

5 files changed

+68
-1
lines changed

drivers/gpu/drm/nouveau/nvkm/subdev/vfn/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ nvkm-y += nvkm/subdev/vfn/uvfn.o
44
nvkm-y += nvkm/subdev/vfn/gv100.o
55
nvkm-y += nvkm/subdev/vfn/tu102.o
66
nvkm-y += nvkm/subdev/vfn/ga100.o
7+
8+
nvkm-y += nvkm/subdev/vfn/r535.o

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

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

24+
#include <subdev/gsp.h>
25+
2426
#include <nvif/class.h>
2527

2628
static const struct nvkm_intr_data
@@ -43,5 +45,8 @@ int
4345
ga100_vfn_new(struct nvkm_device *device,
4446
enum nvkm_subdev_type type, int inst, struct nvkm_vfn **pvfn)
4547
{
48+
if (nvkm_gsp_rm(device->gsp))
49+
return r535_vfn_new(&ga100_vfn, device, type, inst, 0xb80000, pvfn);
50+
4651
return nvkm_vfn_new_(&ga100_vfn, device, type, inst, 0xb80000, pvfn);
4752
}

drivers/gpu/drm/nouveau/nvkm/subdev/vfn/priv.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@
55
#include <subdev/vfn.h>
66

77
struct nvkm_vfn_func {
8+
void (*dtor)(struct nvkm_vfn *);
9+
810
const struct nvkm_intr_func *intr;
911
const struct nvkm_intr_data *intrs;
1012

1113
struct {
1214
u32 addr;
1315
u32 size;
14-
const struct nvkm_sclass base;
16+
struct nvkm_sclass base;
1517
} user;
1618
};
1719

20+
int r535_vfn_new(const struct nvkm_vfn_func *hw, struct nvkm_device *, enum nvkm_subdev_type, int,
21+
u32 addr, struct nvkm_vfn **);
22+
1823
int nvkm_vfn_new_(const struct nvkm_vfn_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
1924
u32 addr, struct nvkm_vfn **);
2025

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2023 Red Hat Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
#include "priv.h"
23+
24+
static void
25+
r535_vfn_dtor(struct nvkm_vfn *vfn)
26+
{
27+
kfree(vfn->func);
28+
}
29+
30+
int
31+
r535_vfn_new(const struct nvkm_vfn_func *hw,
32+
struct nvkm_device *device, enum nvkm_subdev_type type, int inst, u32 addr,
33+
struct nvkm_vfn **pvfn)
34+
{
35+
struct nvkm_vfn_func *rm;
36+
int ret;
37+
38+
if (!(rm = kzalloc(sizeof(*rm), GFP_KERNEL)))
39+
return -ENOMEM;
40+
41+
rm->dtor = r535_vfn_dtor;
42+
rm->intr = hw->intr;
43+
rm->user = hw->user;
44+
45+
ret = nvkm_vfn_new_(rm, device, type, inst, addr, pvfn);
46+
if (ret)
47+
kfree(rm);
48+
49+
return ret;
50+
}

drivers/gpu/drm/nouveau/nvkm/subdev/vfn/tu102.c

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

24+
#include <subdev/gsp.h>
25+
2426
#include <nvif/class.h>
2527

2628
static void
@@ -104,5 +106,8 @@ int
104106
tu102_vfn_new(struct nvkm_device *device,
105107
enum nvkm_subdev_type type, int inst, struct nvkm_vfn **pvfn)
106108
{
109+
if (nvkm_gsp_rm(device->gsp))
110+
return r535_vfn_new(&tu102_vfn, device, type, inst, 0xb80000, pvfn);
111+
107112
return nvkm_vfn_new_(&tu102_vfn, device, type, inst, 0xb80000, pvfn);
108113
}

0 commit comments

Comments
 (0)