[PATCH 076/156] drm/nouveau/nvif: rework usermode "map" api
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:38:42 UTC 2024
- transition from "ioctl" interface
Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
.../gpu/drm/nouveau/include/nvif/driverif.h | 1 +
drivers/gpu/drm/nouveau/include/nvif/user.h | 1 +
drivers/gpu/drm/nouveau/nvif/user.c | 9 ++++++++-
drivers/gpu/drm/nouveau/nvif/userc361.c | 8 ++++----
drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c | 18 ++++--------------
5 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 35a5869eb036..3f481d19e7c6 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -72,6 +72,7 @@ struct nvif_control_impl {
struct nvif_usermode_impl {
void (*del)(struct nvif_usermode_priv *);
+ struct nvif_mapinfo map;
};
struct nvif_device_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/user.h b/drivers/gpu/drm/nouveau/include/nvif/user.h
index 51104955c1e3..4214492b617b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/user.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/user.h
@@ -7,6 +7,7 @@ struct nvif_user {
const struct nvif_usermode_impl *impl;
struct nvif_usermode_priv *priv;
struct nvif_object object;
+ struct nvif_map map;
const struct nvif_user_func *func;
};
diff --git a/drivers/gpu/drm/nouveau/nvif/user.c b/drivers/gpu/drm/nouveau/nvif/user.c
index 878883aff9c5..dbeae9f1e6d2 100644
--- a/drivers/gpu/drm/nouveau/nvif/user.c
+++ b/drivers/gpu/drm/nouveau/nvif/user.c
@@ -30,6 +30,8 @@ void
nvif_user_dtor(struct nvif_device *device)
{
if (device->user.impl) {
+ nvif_object_unmap_cpu(&device->user.map);
+
device->user.impl->del(device->user.priv);
device->user.impl = NULL;
device->user.func = NULL;
@@ -64,6 +66,11 @@ nvif_user_ctor(struct nvif_device *device, const char *name)
nvif_object_ctor(&device->object, name ?: "nvifUsermode", 0, oclass, &device->user.object);
device->user.func = func;
- nvif_object_map(&device->user.object, NULL, 0);
+ ret = nvif_object_map_cpu(&device->user.object, &device->user.impl->map, &device->user.map);
+ if (ret) {
+ nvif_user_dtor(device);
+ return ret;
+ }
+
return 0;
}
diff --git a/drivers/gpu/drm/nouveau/nvif/userc361.c b/drivers/gpu/drm/nouveau/nvif/userc361.c
index 1116f871b272..2431b162b3c9 100644
--- a/drivers/gpu/drm/nouveau/nvif/userc361.c
+++ b/drivers/gpu/drm/nouveau/nvif/userc361.c
@@ -27,9 +27,9 @@ nvif_userc361_time(struct nvif_user *user)
u32 hi, lo;
do {
- hi = nvif_rd32(&user->object, 0x084);
- lo = nvif_rd32(&user->object, 0x080);
- } while (hi != nvif_rd32(&user->object, 0x084));
+ hi = nvif_rd32(user, 0x084);
+ lo = nvif_rd32(user, 0x080);
+ } while (hi != nvif_rd32(user, 0x084));
return ((u64)hi << 32 | lo);
}
@@ -37,7 +37,7 @@ nvif_userc361_time(struct nvif_user *user)
static void
nvif_userc361_doorbell(struct nvif_user *user, u32 token)
{
- nvif_wr32(&user->object, 0x90, token);
+ nvif_wr32(user, 0x90, token);
}
const struct nvif_user_func
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
index 6b0ddeb1f568..f00490e5aa7b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/vfn/uvfn.c
@@ -31,19 +31,6 @@ struct nvif_usermode_priv {
struct nvif_usermode_impl impl;
};
-static int
-nvkm_uvfn_map(struct nvkm_object *object, void *argv, u32 argc,
- enum nvkm_object_map *type, u64 *addr, u64 *size)
-{
- struct nvkm_vfn *vfn = container_of(object, struct nvif_usermode_priv, object)->vfn;
- struct nvkm_device *device = vfn->subdev.device;
-
- *addr = device->func->resource_addr(device, 0) + vfn->addr.user;
- *size = vfn->func->user.size;
- *type = NVKM_OBJECT_MAP_IO;
- return 0;
-}
-
static void
nvkm_uvfn_del(struct nvif_usermode_priv *uvfn)
{
@@ -59,13 +46,13 @@ nvkm_uvfn_impl = {
static const struct nvkm_object_func
nvkm_uvfn = {
- .map = nvkm_uvfn_map,
};
int
nvkm_uvfn_new(struct nvkm_device *device, const struct nvif_usermode_impl **pimpl,
struct nvif_usermode_priv **ppriv, struct nvkm_object **pobject)
{
+ struct nvkm_vfn *vfn = device->vfn;
struct nvif_usermode_priv *uvfn;
if (!(uvfn = kzalloc(sizeof(*uvfn), GFP_KERNEL)))
@@ -75,6 +62,9 @@ nvkm_uvfn_new(struct nvkm_device *device, const struct nvif_usermode_impl **pimp
uvfn->vfn = device->vfn;
uvfn->impl = nvkm_uvfn_impl;
+ uvfn->impl.map.type = NVIF_MAP_IO;
+ uvfn->impl.map.handle = device->func->resource_addr(device, 0) + vfn->addr.user;
+ uvfn->impl.map.length = vfn->func->user.size;
*pimpl = &uvfn->impl;
*ppriv = uvfn;
--
2.41.0
More information about the Nouveau
mailing list