[PATCH 093/156] drm/nouveau/nvif: rework vmm "raw sparse" api
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:38:59 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/if000c.h | 16 ----------
drivers/gpu/drm/nouveau/nvif/vmm.c | 11 +------
.../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c | 32 +++----------------
4 files changed, 6 insertions(+), 54 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 1cea0a07b2e8..da5760df9e20 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -142,6 +142,7 @@ struct nvif_vmm_impl {
int (*map)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, void *, u32,
struct nvif_mem_priv *, u64 offset);
int (*unmap)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size, bool sparse);
+ int (*sparse)(struct nvif_vmm_priv *, u64 addr, u64 size, bool ref);
} raw;
};
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index 232cc1142798..61a12396e996 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -1,22 +1,6 @@
#ifndef __NVIF_IF000C_H__
#define __NVIF_IF000C_H__
-#define NVIF_VMM_V0_RAW 0x07
#define NVIF_VMM_V0_MTHD(i) ((i) + 0x80)
-struct nvif_vmm_raw_v0 {
- __u8 version;
-#define NVIF_VMM_RAW_V0_SPARSE 0x4
- __u8 op;
- __u8 sparse;
- __u8 ref;
- __u8 shift;
- __u32 argc;
- __u8 pad01[7];
- __u64 addr;
- __u64 size;
- __u64 offset;
- __u64 memory;
- __u64 argv;
-};
#endif
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index 16c6aaa81326..c3005f16a32e 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -94,16 +94,7 @@ nvif_vmm_raw_unmap(struct nvif_vmm *vmm, u64 addr, u64 size,
int
nvif_vmm_raw_sparse(struct nvif_vmm *vmm, u64 addr, u64 size, bool ref)
{
- struct nvif_vmm_raw_v0 args = {
- .version = 0,
- .op = NVIF_VMM_RAW_V0_SPARSE,
- .addr = addr,
- .size = size,
- .ref = ref,
- };
-
- return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
- &args, sizeof(args));
+ return vmm->impl->raw.sparse(vmm->priv, addr, size, ref);
}
void
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index 7c8a7a5dc3f9..079ebaa64668 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -29,8 +29,6 @@
#include <nvif/if000c.h>
#include <nvif/unpack.h>
-#define nvkm_uvmm nvif_vmm_priv
-
struct nvif_vmm_priv {
struct nvkm_object object;
struct nvkm_vmm *vmm;
@@ -348,36 +346,14 @@ nvkm_uvmm_raw_unmap(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size, bo
}
static int
-nvkm_uvmm_mthd_raw_sparse(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_sparse(struct nvif_vmm_priv *uvmm, u64 addr, u64 size, bool ref)
{
struct nvkm_vmm *vmm = uvmm->vmm;
- if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
- return -EINVAL;
-
- return nvkm_vmm_raw_sparse(vmm, args->addr, args->size, args->ref);
-}
-
-static int
-nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
-{
- union {
- struct nvif_vmm_raw_v0 v0;
- } *args = argv;
- int ret = -ENOSYS;
-
- if (!uvmm->vmm->managed.raw)
+ if (!nvkm_vmm_in_managed_range(vmm, addr, size))
return -EINVAL;
- if ((ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, true)))
- return ret;
-
- switch (args->v0.op) {
- case NVIF_VMM_RAW_V0_SPARSE:
- return nvkm_uvmm_mthd_raw_sparse(uvmm, &args->v0);
- default:
- return -EINVAL;
- };
+ return nvkm_vmm_raw_sparse(vmm, addr, size, ref);
}
static int
@@ -385,7 +361,6 @@ nvkm_uvmm_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
{
struct nvif_vmm_priv *uvmm = container_of(object, typeof(*uvmm), object);
switch (mthd) {
- case NVIF_VMM_V0_RAW : return nvkm_uvmm_mthd_raw (uvmm, argv, argc);
case NVIF_VMM_V0_MTHD(0x00) ... NVIF_VMM_V0_MTHD(0x7f):
if (uvmm->vmm->func->mthd) {
return uvmm->vmm->func->mthd(uvmm->vmm,
@@ -420,6 +395,7 @@ nvkm_uvmm_impl = {
.raw.put = nvkm_uvmm_raw_put,
.raw.map = nvkm_uvmm_raw_map,
.raw.unmap = nvkm_uvmm_raw_unmap,
+ .raw.sparse = nvkm_uvmm_raw_sparse,
};
static void *
--
2.41.0
More information about the Nouveau
mailing list