Commit 2606f291 authored by Ben Skeggs's avatar Ben Skeggs
Browse files

drm/nouveau/mmu: support initialisation of client-managed address-spaces



NVKM is currently responsible for managing the allocation of a client's
GPU address-space, but there's various use-cases (ie. HMM address-space
mirroring) where giving a client more direct control is desirable.

This commit allows for a VMM to be created where the area allocated for
NVKM is limited to a client-specified window, the remainder of address-
space is controlled directly by the client.

Leaving a window is necessary to support various internal requirements,
but also to support existing allocation interfaces as not all of the HW
is capable of working with a HMM allocation.

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent ae5ea7f6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@
struct nvif_vmm_v0 {
	__u8  version;
	__u8  page_nr;
	__u8  pad02[6];
	__u8  managed;
	__u8  pad03[5];
	__u64 addr;
	__u64 size;
	__u8  data[];
+2 −2
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ struct nvif_vmm {
	int page_nr;
};

int nvif_vmm_init(struct nvif_mmu *, s32 oclass, u64 addr, u64 size,
		  void *argv, u32 argc, struct nvif_vmm *);
int nvif_vmm_init(struct nvif_mmu *, s32 oclass, bool managed, u64 addr,
		  u64 size, void *argv, u32 argc, struct nvif_vmm *);
void nvif_vmm_fini(struct nvif_vmm *);
int nvif_vmm_get(struct nvif_vmm *, enum nvif_vmm_get, bool sparse,
		 u8 page, u8 align, u64 size, struct nvif_vma *);
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ nouveau_vmm_fini(struct nouveau_vmm *vmm)
int
nouveau_vmm_init(struct nouveau_cli *cli, s32 oclass, struct nouveau_vmm *vmm)
{
	int ret = nvif_vmm_init(&cli->mmu, oclass, PAGE_SIZE, 0, NULL, 0,
	int ret = nvif_vmm_init(&cli->mmu, oclass, false, PAGE_SIZE, 0, NULL, 0,
				&vmm->vmm);
	if (ret)
		return ret;
+3 −2
Original line number Diff line number Diff line
@@ -112,8 +112,8 @@ nvif_vmm_fini(struct nvif_vmm *vmm)
}

int
nvif_vmm_init(struct nvif_mmu *mmu, s32 oclass, u64 addr, u64 size,
	      void *argv, u32 argc, struct nvif_vmm *vmm)
nvif_vmm_init(struct nvif_mmu *mmu, s32 oclass, bool managed, u64 addr,
	      u64 size, void *argv, u32 argc, struct nvif_vmm *vmm)
{
	struct nvif_vmm_v0 *args;
	u32 argn = sizeof(*args) + argc;
@@ -125,6 +125,7 @@ nvif_vmm_init(struct nvif_mmu *mmu, s32 oclass, u64 addr, u64 size,
	if (!(args = kmalloc(argn, GFP_KERNEL)))
		return -ENOMEM;
	args->version = 0;
	args->managed = managed;
	args->addr = addr;
	args->size = size;
	memcpy(args->data, argv, argc);
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ struct nvkm_mmu_func {

	struct {
		struct nvkm_sclass user;
		int (*ctor)(struct nvkm_mmu *, u64 addr, u64 size,
		int (*ctor)(struct nvkm_mmu *, bool managed, u64 addr, u64 size,
			    void *argv, u32 argc, struct lock_class_key *,
			    const char *name, struct nvkm_vmm **);
		bool global;
Loading