[PATCH 091/156] drm/nouveau/nvif: rework vmm "raw get"/"raw put" apis

Ben Skeggs bskeggs at nvidia.com
Tue Apr 16 23:38:57 UTC 2024


- transition from ioctl interfaces

Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  5 +++++
 drivers/gpu/drm/nouveau/include/nvif/if000c.h |  2 --
 drivers/gpu/drm/nouveau/nvif/vmm.c            | 22 ++-----------------
 .../gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c    | 22 +++++++++----------
 4 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index afca57d53c8c..65958649f08c 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -135,6 +135,11 @@ struct nvif_vmm_impl {
 #define NVIF_VMM_PFNMAP_NONE       0x0000000000000000ULL
 	int (*pfnmap)(struct nvif_vmm_priv *, u8 page, u64 addr, u64 size, u64 *phys);
 	int (*pfnclr)(struct nvif_vmm_priv *, u64 addr, u64 size);
+
+	struct {
+		int (*get)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
+		int (*put)(struct nvif_vmm_priv *, u8 shift, u64 addr, u64 size);
+	} raw;
 };
 
 struct nvif_mmu_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if000c.h b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
index 709837ffea4e..c81fae28395a 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if000c.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if000c.h
@@ -6,8 +6,6 @@
 
 struct nvif_vmm_raw_v0 {
 	__u8 version;
-#define NVIF_VMM_RAW_V0_GET	0x0
-#define NVIF_VMM_RAW_V0_PUT	0x1
 #define NVIF_VMM_RAW_V0_MAP	0x2
 #define NVIF_VMM_RAW_V0_UNMAP	0x3
 #define NVIF_VMM_RAW_V0_SPARSE	0x4
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c
index 6821d8657e12..d7ca6afaeb04 100644
--- a/drivers/gpu/drm/nouveau/nvif/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -68,31 +68,13 @@ int
 nvif_vmm_raw_get(struct nvif_vmm *vmm, u64 addr, u64 size,
 		 u8 shift)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_GET,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.get(vmm->priv, shift, addr, size);
 }
 
 int
 nvif_vmm_raw_put(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift)
 {
-	struct nvif_vmm_raw_v0 args = {
-		.version = 0,
-		.op = NVIF_VMM_RAW_V0_PUT,
-		.addr = addr,
-		.size = size,
-		.shift = shift,
-	};
-
-	return nvif_object_mthd(&vmm->object, NVIF_VMM_V0_RAW,
-				&args, sizeof(args));
+	return vmm->impl->raw.put(vmm->priv, shift, addr, size);
 }
 
 int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
index b1bd1dd3d5dd..51c7e0fd7876 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
@@ -260,37 +260,37 @@ nvkm_uvmm_page_index(struct nvif_vmm_priv *uvmm, u64 size, u8 shift, u8 *refd)
 }
 
 static int
-nvkm_uvmm_mthd_raw_get(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_get(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
-	return nvkm_vmm_raw_get(vmm, args->addr, args->size, refd);
+	return nvkm_vmm_raw_get(vmm, addr, size, refd);
 }
 
 static int
-nvkm_uvmm_mthd_raw_put(struct nvkm_uvmm *uvmm, struct nvif_vmm_raw_v0 *args)
+nvkm_uvmm_raw_put(struct nvif_vmm_priv *uvmm, u8 shift, u64 addr, u64 size)
 {
 	struct nvkm_vmm *vmm = uvmm->vmm;
 	u8 refd;
 	int ret;
 
-	if (!nvkm_vmm_in_managed_range(vmm, args->addr, args->size))
+	if (!nvkm_vmm_in_managed_range(vmm, addr, size))
 		return -EINVAL;
 
-	ret = nvkm_uvmm_page_index(uvmm, args->size, args->shift, &refd);
+	ret = nvkm_uvmm_page_index(uvmm, size, shift, &refd);
 	if (ret)
 		return ret;
 
-	nvkm_vmm_raw_put(vmm, args->addr, args->size, refd);
+	nvkm_vmm_raw_put(vmm, addr, size, refd);
 
 	return 0;
 }
@@ -382,10 +382,6 @@ nvkm_uvmm_mthd_raw(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
 		return ret;
 
 	switch (args->v0.op) {
-	case NVIF_VMM_RAW_V0_GET:
-		return nvkm_uvmm_mthd_raw_get(uvmm, &args->v0);
-	case NVIF_VMM_RAW_V0_PUT:
-		return nvkm_uvmm_mthd_raw_put(uvmm, &args->v0);
 	case NVIF_VMM_RAW_V0_MAP:
 		return nvkm_uvmm_mthd_raw_map(uvmm, &args->v0);
 	case NVIF_VMM_RAW_V0_UNMAP:
@@ -433,6 +429,8 @@ nvkm_uvmm_impl = {
 	.unmap = nvkm_uvmm_unmap,
 	.pfnmap = nvkm_uvmm_pfnmap,
 	.pfnclr = nvkm_uvmm_pfnclr,
+	.raw.get = nvkm_uvmm_raw_get,
+	.raw.put = nvkm_uvmm_raw_put,
 };
 
 static void *
-- 
2.41.0



More information about the Nouveau mailing list