Commit 58c3d3c8 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/vfn: move NV_USERMODE class from host

- uses proper class IDs for Turing/Ampere
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent f83d1c31
...@@ -63,6 +63,8 @@ ...@@ -63,6 +63,8 @@
#define NV04_DISP /* cl0046.h */ 0x00000046 #define NV04_DISP /* cl0046.h */ 0x00000046
#define VOLTA_USERMODE_A 0x0000c361 #define VOLTA_USERMODE_A 0x0000c361
#define TURING_USERMODE_A 0x0000c461
#define AMPERE_USERMODE_A 0x0000c561
#define MAXWELL_FAULT_BUFFER_A /* clb069.h */ 0x0000b069 #define MAXWELL_FAULT_BUFFER_A /* clb069.h */ 0x0000b069
#define VOLTA_FAULT_BUFFER_A /* clb069.h */ 0x0000c369 #define VOLTA_FAULT_BUFFER_A /* clb069.h */ 0x0000c369
......
...@@ -9,7 +9,10 @@ struct nvkm_vfn { ...@@ -9,7 +9,10 @@ struct nvkm_vfn {
struct { struct {
u32 priv; u32 priv;
u32 user;
} addr; } addr;
struct nvkm_device_oclass user;
}; };
int gv100_vfn_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_vfn **); int gv100_vfn_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_vfn **);
......
...@@ -41,7 +41,9 @@ nvif_user_ctor(struct nvif_device *device, const char *name) ...@@ -41,7 +41,9 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
int version; int version;
const struct nvif_user_func *func; const struct nvif_user_func *func;
} users[] = { } users[] = {
{ VOLTA_USERMODE_A, -1, &nvif_userc361 }, { AMPERE_USERMODE_A, -1, &nvif_userc361 },
{ TURING_USERMODE_A, -1, &nvif_userc361 },
{ VOLTA_USERMODE_A, -1, &nvif_userc361 },
{} {}
}; };
int cid, ret; int cid, ret;
......
...@@ -342,6 +342,8 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index, ...@@ -342,6 +342,8 @@ nvkm_udevice_child_get(struct nvkm_object *object, int index,
sclass = &device->mmu->user; sclass = &device->mmu->user;
else if (device->fault && index-- == 0) else if (device->fault && index-- == 0)
sclass = &device->fault->user; sclass = &device->fault->user;
else if (device->vfn && index-- == 0)
sclass = &device->vfn->user;
else else
return -EINVAL; return -EINVAL;
......
...@@ -35,6 +35,3 @@ nvkm-y += nvkm/engine/fifo/gpfifogf100.o ...@@ -35,6 +35,3 @@ nvkm-y += nvkm/engine/fifo/gpfifogf100.o
nvkm-y += nvkm/engine/fifo/gpfifogk104.o nvkm-y += nvkm/engine/fifo/gpfifogk104.o
nvkm-y += nvkm/engine/fifo/gpfifogv100.o nvkm-y += nvkm/engine/fifo/gpfifogv100.o
nvkm-y += nvkm/engine/fifo/gpfifotu102.o nvkm-y += nvkm/engine/fifo/gpfifotu102.o
nvkm-y += nvkm/engine/fifo/usergv100.o
nvkm-y += nvkm/engine/fifo/usertu102.o
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#define ga102_fifo(p) container_of((p), struct ga102_fifo, base.engine) #define ga102_fifo(p) container_of((p), struct ga102_fifo, base.engine)
#define ga102_chan(p) container_of((p), struct ga102_chan, object) #define ga102_chan(p) container_of((p), struct ga102_chan, object)
#include <engine/fifo.h> #include <engine/fifo.h>
#include "user.h"
#include <core/memory.h> #include <core/memory.h>
#include <subdev/mmu.h> #include <subdev/mmu.h>
...@@ -242,33 +241,16 @@ ga102_chan_oclass = { ...@@ -242,33 +241,16 @@ ga102_chan_oclass = {
.ctor = ga102_chan_new, .ctor = ga102_chan_new,
}; };
static int
ga102_user_new(struct nvkm_device *device,
const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nvkm_object **pobject)
{
return tu102_fifo_user_new(oclass, argv, argc, pobject);
}
static const struct nvkm_device_oclass
ga102_user_oclass = {
.ctor = ga102_user_new,
};
static int static int
ga102_fifo_sclass(struct nvkm_oclass *oclass, int index, const struct nvkm_device_oclass **class) ga102_fifo_sclass(struct nvkm_oclass *oclass, int index, const struct nvkm_device_oclass **class)
{ {
if (index == 0) { if (index == 0) {
oclass->base = (struct nvkm_sclass) { -1, -1, VOLTA_USERMODE_A };
*class = &ga102_user_oclass;
return 0;
} else
if (index == 1) {
oclass->base = (struct nvkm_sclass) { 0, 0, AMPERE_CHANNEL_GPFIFO_B }; oclass->base = (struct nvkm_sclass) { 0, 0, AMPERE_CHANNEL_GPFIFO_B };
*class = &ga102_chan_oclass; *class = &ga102_chan_oclass;
return 0; return 0;
} }
return 2; return 1;
} }
static int static int
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "gk104.h" #include "gk104.h"
#include "cgrp.h" #include "cgrp.h"
#include "changk104.h" #include "changk104.h"
#include "user.h"
#include <core/gpuobj.h> #include <core/gpuobj.h>
...@@ -295,7 +294,6 @@ gv100_fifo = { ...@@ -295,7 +294,6 @@ gv100_fifo = {
.fault.hubclient = gv100_fifo_fault_hubclient, .fault.hubclient = gv100_fifo_fault_hubclient,
.fault.gpcclient = gv100_fifo_fault_gpcclient, .fault.gpcclient = gv100_fifo_fault_gpcclient,
.runlist = &gv100_fifo_runlist, .runlist = &gv100_fifo_runlist,
.user = {{-1,-1,VOLTA_USERMODE_A }, gv100_fifo_user_new },
.chan = {{ 0, 0,VOLTA_CHANNEL_GPFIFO_A}, gv100_fifo_gpfifo_new }, .chan = {{ 0, 0,VOLTA_CHANNEL_GPFIFO_A}, gv100_fifo_gpfifo_new },
.cgrp_force = true, .cgrp_force = true,
}; };
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "gk104.h" #include "gk104.h"
#include "cgrp.h" #include "cgrp.h"
#include "changk104.h" #include "changk104.h"
#include "user.h"
#include <core/client.h> #include <core/client.h>
#include <core/gpuobj.h> #include <core/gpuobj.h>
...@@ -110,7 +109,6 @@ tu102_fifo = { ...@@ -110,7 +109,6 @@ tu102_fifo = {
.fault.hubclient = gv100_fifo_fault_hubclient, .fault.hubclient = gv100_fifo_fault_hubclient,
.fault.gpcclient = gv100_fifo_fault_gpcclient, .fault.gpcclient = gv100_fifo_fault_gpcclient,
.runlist = &tu102_fifo_runlist, .runlist = &tu102_fifo_runlist,
.user = {{-1,-1,VOLTA_USERMODE_A }, tu102_fifo_user_new },
.chan = {{ 0, 0,TURING_CHANNEL_GPFIFO_A}, tu102_fifo_gpfifo_new }, .chan = {{ 0, 0,TURING_CHANNEL_GPFIFO_A}, tu102_fifo_gpfifo_new },
.cgrp_force = true, .cgrp_force = true,
}; };
......
#ifndef __NVKM_FIFO_USER_H__
#define __NVKM_FIFO_USER_H__
#include "priv.h"
int gv100_fifo_user_new(const struct nvkm_oclass *, void *, u32,
struct nvkm_object **);
int tu102_fifo_user_new(const struct nvkm_oclass *, void *, u32,
struct nvkm_object **);
#endif
/*
* Copyright 2018 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 "user.h"
static int
tu102_fifo_user_map(struct nvkm_object *object, void *argv, u32 argc,
enum nvkm_object_map *type, u64 *addr, u64 *size)
{
struct nvkm_device *device = object->engine->subdev.device;
*addr = 0xbb0000 + device->func->resource_addr(device, 0);
*size = 0x010000;
*type = NVKM_OBJECT_MAP_IO;
return 0;
}
static const struct nvkm_object_func
tu102_fifo_user = {
.map = tu102_fifo_user_map,
};
int
tu102_fifo_user_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
struct nvkm_object **pobject)
{
return nvkm_object_new_(&tu102_fifo_user, oclass, argv, argc, pobject);
}
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
nvkm-y += nvkm/subdev/vfn/base.o nvkm-y += nvkm/subdev/vfn/base.o
nvkm-y += nvkm/subdev/vfn/uvfn.o
nvkm-y += nvkm/subdev/vfn/gv100.o nvkm-y += nvkm/subdev/vfn/gv100.o
nvkm-y += nvkm/subdev/vfn/tu102.o nvkm-y += nvkm/subdev/vfn/tu102.o
nvkm-y += nvkm/subdev/vfn/ga100.o nvkm-y += nvkm/subdev/vfn/ga100.o
...@@ -44,5 +44,9 @@ nvkm_vfn_new_(const struct nvkm_vfn_func *func, struct nvkm_device *device, ...@@ -44,5 +44,9 @@ nvkm_vfn_new_(const struct nvkm_vfn_func *func, struct nvkm_device *device,
nvkm_subdev_ctor(&nvkm_vfn, device, type, inst, &vfn->subdev); nvkm_subdev_ctor(&nvkm_vfn, device, type, inst, &vfn->subdev);
vfn->func = func; vfn->func = func;
vfn->addr.priv = addr; vfn->addr.priv = addr;
vfn->addr.user = vfn->addr.priv + func->user.addr;
vfn->user.ctor = nvkm_uvfn_new;
vfn->user.base = func->user.base;
return 0; return 0;
} }
...@@ -21,8 +21,11 @@ ...@@ -21,8 +21,11 @@
*/ */
#include "priv.h" #include "priv.h"
#include <nvif/class.h>
static const struct nvkm_vfn_func static const struct nvkm_vfn_func
ga100_vfn = { ga100_vfn = {
.user = { 0x030000, 0x010000, { -1, -1, AMPERE_USERMODE_A } },
}; };
int int
......
...@@ -21,8 +21,11 @@ ...@@ -21,8 +21,11 @@
*/ */
#include "priv.h" #include "priv.h"
#include <nvif/class.h>
static const struct nvkm_vfn_func static const struct nvkm_vfn_func
gv100_vfn = { gv100_vfn = {
.user = { 0x810000, 0x010000, { -1, -1, VOLTA_USERMODE_A } },
}; };
int int
......
...@@ -5,8 +5,16 @@ ...@@ -5,8 +5,16 @@
#include <subdev/vfn.h> #include <subdev/vfn.h>
struct nvkm_vfn_func { struct nvkm_vfn_func {
struct {
u32 addr;
u32 size;
const struct nvkm_sclass base;
} user;
}; };
int nvkm_vfn_new_(const struct nvkm_vfn_func *, struct nvkm_device *, enum nvkm_subdev_type, int, int nvkm_vfn_new_(const struct nvkm_vfn_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
u32 addr, struct nvkm_vfn **); u32 addr, struct nvkm_vfn **);
int nvkm_uvfn_new(struct nvkm_device *, const struct nvkm_oclass *, void *, u32,
struct nvkm_object **);
#endif #endif
...@@ -21,8 +21,11 @@ ...@@ -21,8 +21,11 @@
*/ */
#include "priv.h" #include "priv.h"
#include <nvif/class.h>
static const struct nvkm_vfn_func static const struct nvkm_vfn_func
tu102_vfn = { tu102_vfn = {
.user = { 0x030000, 0x010000, { -1, -1, TURING_USERMODE_A } },
}; };
int int
......
/* /*
* Copyright 2018 Red Hat Inc. * Copyright 2021 Red Hat Inc.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
...@@ -19,27 +19,49 @@ ...@@ -19,27 +19,49 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "user.h" #define nvkm_uvfn(p) container_of((p), struct nvkm_uvfn, object)
#include "priv.h"
#include <core/object.h>
struct nvkm_uvfn {
struct nvkm_object object;
struct nvkm_vfn *vfn;
};
static int static int
gv100_fifo_user_map(struct nvkm_object *object, void *argv, u32 argc, nvkm_uvfn_map(struct nvkm_object *object, void *argv, u32 argc,
enum nvkm_object_map *type, u64 *addr, u64 *size) enum nvkm_object_map *type, u64 *addr, u64 *size)
{ {
struct nvkm_device *device = object->engine->subdev.device; struct nvkm_vfn *vfn = nvkm_uvfn(object)->vfn;
*addr = 0x810000 + device->func->resource_addr(device, 0); struct nvkm_device *device = vfn->subdev.device;
*size = 0x010000;
*addr = device->func->resource_addr(device, 0) + vfn->addr.user;
*size = vfn->func->user.size;
*type = NVKM_OBJECT_MAP_IO; *type = NVKM_OBJECT_MAP_IO;
return 0; return 0;
} }
static const struct nvkm_object_func static const struct nvkm_object_func
gv100_fifo_user = { nvkm_uvfn = {
.map = gv100_fifo_user_map, .map = nvkm_uvfn_map,
}; };
int int
gv100_fifo_user_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, nvkm_uvfn_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
struct nvkm_object **pobject) void *argv, u32 argc, struct nvkm_object **pobject)
{ {
return nvkm_object_new_(&gv100_fifo_user, oclass, argv, argc, pobject); struct nvkm_uvfn *uvfn;
if (argc != 0)
return -ENOSYS;
if (!(uvfn = kzalloc(sizeof(*uvfn), GFP_KERNEL)))
return -ENOMEM;
nvkm_object_ctor(&nvkm_uvfn, oclass, &uvfn->object);
uvfn->vfn = device->vfn;
*pobject = &uvfn->object;
return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment